Exemple #1
0
def retrieve_flavor(name):
    manager = get_manager()
    try:
        flavor = manager.storage.find_flavor(name)
    except storage.FlavorNotFoundError:
        return "flavor not found", 404
    return json.dumps(flavor.to_dict())
Exemple #2
0
 def test_find_flavor(self):
     flavor = self.storage.find_flavor("vanilla")
     expected = {"name": "vanilla", "description": "nginx 1.10",
                 "config": {"nginx_version": "1.10"}}
     self.assertEqual(expected, flavor.to_dict())
     with self.assertRaises(storage.FlavorNotFoundError):
         self.storage.find_flavor("something that doesn't exist")
Exemple #3
0
def retrieve_flavor(name):
    manager = get_manager()
    try:
        flavor = manager.storage.find_flavor(name)
    except storage.FlavorNotFoundError:
        return "flavor not found", 404
    return json.dumps(flavor.to_dict())
Exemple #4
0
 def store_flavor(self, flavor):
     flavor.validate()
     d = flavor.to_dict()
     d["_id"] = d["name"]
     del d["name"]
     try:
         self.db[self.flavors_collection].insert(d)
     except pymongo.errors.DuplicateKeyError:
         raise DuplicateError(flavor.name)
Exemple #5
0
 def store_flavor(self, flavor):
     flavor.validate()
     d = flavor.to_dict()
     d["_id"] = d["name"]
     del d["name"]
     try:
         self.db[self.flavors_collection].insert(d)
     except pymongo.errors.DuplicateKeyError:
         raise DuplicateError(flavor.name)