# Path: rpaas/plan.py
# class InvalidPlanError(Exception):
# class Plan(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):
# 
# Path: rpaas/flavor.py
# class InvalidFlavorError(Exception):
# class Flavor(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):


import datetime
import pymongo.errors
from hm import storage
from rpaas import plan, flavor
            self.db[self.tasks_collection].update({'_id': name}, {'$set': {'task_id': task_id_or_spec}})

    def find_task(self, query):
        if isinstance(query, dict):
            return self.db[self.tasks_collection].find(query)
        else:
            return self.db[self.tasks_collection].find({"_id": query})

    def store_instance_metadata(self, instance_name, **data):
        data['_id'] = instance_name
        self.db[self.instance_metadata_collection].update({'_id': instance_name},
                                                          data, upsert=True)

    def find_instance_metadata(self, instance_name):
        return self.db[self.instance_metadata_collection].find_one({'_id': instance_name})

    def find_host_id(self, name):
        return self.db[self.hosts_collection].find_one({'dns_name': name})

    def remove_instance_metadata(self, instance_name):
        self.db[self.instance_metadata_collection].remove({'_id': instance_name})

    def store_plan(self, plan):
        plan.validate()
        d = plan.to_dict()
        d["_id"] = d["name"]
        del d["name"]
        try:
            self.db[self.plans_collection].insert(d)
        except pymongo.errors.DuplicateKeyError:

# Path: rpaas/plan.py
# class InvalidPlanError(Exception):
# class Plan(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):
# 
# Path: rpaas/flavor.py
# class InvalidFlavorError(Exception):
# class Flavor(object):
#     def __init__(self, field):
#     def __unicode__(self):
#     def __init__(self, name, description, config):
#     def validate(self):
#     def to_dict(self):


# Path: rpaas/storage.py
import datetime
import pymongo.errors
from hm import storage
from rpaas import plan, flavor

            self.db[self.tasks_collection].update({'_id': name}, {'$set': {'task_id': task_id_or_spec}})

    def find_task(self, query):
        if isinstance(query, dict):
            return self.db[self.tasks_collection].find(query)
        else:
            return self.db[self.tasks_collection].find({"_id": query})

    def store_instance_metadata(self, instance_name, **data):
        data['_id'] = instance_name
        self.db[self.instance_metadata_collection].update({'_id': instance_name},
                                                          data, upsert=True)

    def find_instance_metadata(self, instance_name):
        return self.db[self.instance_metadata_collection].find_one({'_id': instance_name})

    def find_host_id(self, name):
        return self.db[self.hosts_collection].find_one({'dns_name': name})

    def remove_instance_metadata(self, instance_name):
        self.db[self.instance_metadata_collection].remove({'_id': instance_name})

    def store_plan(self, plan):
        plan.validate()
        d = plan.to_dict()
        d["_id"] = d["name"]
        del d["name"]
        try:
            self.db[self.plans_collection].insert(d)
        except pymongo.errors.DuplicateKeyError:

            raise DuplicateError(plan.name)