Beispiel #1
0
def retrieve_plan(name):
    manager = get_manager()
    try:
        plan = manager.storage.find_plan(name)
    except storage.PlanNotFoundError:
        return "plan not found", 404
    return json.dumps(plan.to_dict())
Beispiel #2
0
def retrieve_plan(name):
    manager = get_manager()
    try:
        plan = manager.storage.find_plan(name)
    except storage.PlanNotFoundError:
        return "plan not found", 404
    return json.dumps(plan.to_dict())
Beispiel #3
0
 def test_find_plan(self):
     plan = self.storage.find_plan("small")
     expected = {"name": "small", "description": "some cool plan",
                 "config": {"serviceofferingid": "abcdef123456"}}
     self.assertEqual(expected, plan.to_dict())
     with self.assertRaises(storage.PlanNotFoundError):
         self.storage.find_plan("something that doesn't exist")
Beispiel #4
0
 def test_find_plan(self):
     plan = self.storage.find_plan("small")
     expected = {"name": "small", "description": "some cool plan",
                 "config": {"serviceofferingid": "abcdef123456"}}
     self.assertEqual(expected, plan.to_dict())
     with self.assertRaises(storage.PlanNotFoundError):
         self.storage.find_plan("something that doesn't exist")
Beispiel #5
0
 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)
Beispiel #6
0
 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)