diff options
| author | jaypipes@gmail.com <> | 2010-10-21 14:29:34 -0400 |
|---|---|---|
| committer | jaypipes@gmail.com <> | 2010-10-21 14:29:34 -0400 |
| commit | 198af0ef9e65bc4c2efe74b9d93cf40210eb77bc (patch) | |
| tree | 974d5017f6f41a5909457d85e0c039dfabd62efe /nova/compute | |
| parent | 4de2079303a25a1e6a60d3110788ebb35fcdf37e (diff) | |
Moves db writes into compute manager class. Cleans up sqlalchemy model/api to remove redundant calls for updating what is really a dict.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 523bb8893..c752d954b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -67,6 +67,41 @@ class ComputeManager(manager.Manager): def refresh_security_group(self, context, security_group_id, **_kwargs): yield self.driver.refresh_security_group(security_group_id) + + def create_instance(self, context, instance_data, security_groups=[]): + """Creates the instance in the datastore and returns the + new instance as a mapping + + :param context: The security context + :param instance_data: mapping of instance options + :param security_groups: list of security group ids to + attach to the instance + + :retval Returns a mapping of the instance information + that has just been created + + """ + instance_ref = self.db.instance_create(context, instance_data) + inst_id = instance_ref['id'] + + elevated = context.elevated() + for security_group_id in security_groups: + self.db.instance_add_security_group(elevated, + inst_id, + security_group_id) + return instance_ref + + def update_instance(self, context, instance_id, instance_data): + """Updates the instance in the datastore + + :param context: The security context + :param instance_data: mapping of instance options + + :retval None + + """ + self.db.instance_update(context, instance_id, instance_data) + @defer.inlineCallbacks @exception.wrap_exception def run_instance(self, context, instance_id, **_kwargs): |
