20
20
from nova import log as logging
22
22
from nova.auth import manager
23
from nova.api.openstack import common
24
23
from nova.api.openstack import faults
24
from nova.api.openstack import wsgi
26
27
FLAGS = flags.FLAGS
27
28
LOG = logging.getLogger('nova.api.openstack')
34
35
manager=account.project_manager_id)
37
class Controller(common.OpenstackController):
39
_serialization_metadata = {
42
"account": ["id", "name", "description", "manager"]}}}
38
class Controller(object):
44
40
def __init__(self):
45
41
self.manager = manager.AuthManager()
66
62
self.manager.delete_project(id)
69
def create(self, req):
65
def create(self, req, body):
70
66
"""We use update with create-or-update semantics
71
67
because the id comes from an external source"""
72
68
raise faults.Fault(webob.exc.HTTPNotImplemented())
74
def update(self, req, id):
70
def update(self, req, id, body):
75
71
"""This is really create or update."""
76
72
self._check_admin(req.environ['nova.context'])
77
env = self._deserialize(req.body, req.get_content_type())
78
description = env['account'].get('description')
79
manager = env['account'].get('manager')
73
description = body['account'].get('description')
74
manager = body['account'].get('manager')
81
76
account = self.manager.get_project(id)
82
77
self.manager.modify_project(id, manager, description)
83
78
except exception.NotFound:
84
79
account = self.manager.create_project(id, manager, description)
85
80
return dict(account=_translate_keys(account))
83
def create_resource():
86
"account": ["id", "name", "description", "manager"],
91
'application/xml': wsgi.XMLDictSerializer(metadata=metadata),
94
return wsgi.Resource(Controller(), serializers=serializers)