summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaypipes@gmail.com <>2010-10-27 11:10:50 -0400
committerjaypipes@gmail.com <>2010-10-27 11:10:50 -0400
commit79acdcca7d37e81d626be7a3369394ef9dface1b (patch)
treea690a6d5cce1fe4dba85680febcaad5b1aed7ff0
parent24e19b43af5efe193bf28bed468e85ee57ce76df (diff)
downloadnova-79acdcca7d37e81d626be7a3369394ef9dface1b.tar.gz
nova-79acdcca7d37e81d626be7a3369394ef9dface1b.tar.xz
nova-79acdcca7d37e81d626be7a3369394ef9dface1b.zip
Style cleanups and review from Eric.
-rw-r--r--nova/api/ec2/cloud.py23
-rw-r--r--nova/compute/manager.py15
2 files changed, 24 insertions, 14 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 51e972aa7..9084958a1 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -836,29 +836,30 @@ class CloudController(object):
elevated = context.elevated()
for num in range(num_instances):
-
+
instance_data = base_options
- instance_data['mac_address'] = utils.generate_mac()
- instance_data['launch_index'] = num
instance_ref = self.compute_manager.create_instance(context,
- instance_data,
- security_groups)
+ instance_data,
+ security_groups,
+ mac_address=utils.generate_mac(),
+ launch_index=num)
+ inst_id = instance_ref['id']
internal_id = instance_ref['internal_id']
ec2_id = internal_id_to_ec2_id(internal_id)
- instance_ref['hostname'] = ec2_id
self.compute_manager.update_instance(context,
- instance_ref['id'],
- instance_ref)
+ inst_id,
+ instance_ref,
+ hostname=ec2_id)
# TODO(vish): This probably should be done in the scheduler
# or in compute as a call. The network should be
# allocated after the host is assigned and setup
# can happen at the same time.
address = self.network_manager.allocate_fixed_ip(context,
- instance_ref['id'],
+ inst_id,
vpn)
network_topic = self._get_network_topic(context)
rpc.cast(elevated,
@@ -870,9 +871,9 @@ class CloudController(object):
FLAGS.scheduler_topic,
{"method": "run_instance",
"args": {"topic": FLAGS.compute_topic,
- "instance_id": instance_ref['id']}})
+ "instance_id": inst_id}})
logging.debug("Casting to scheduler for %s/%s's instance %s" %
- (context.project.name, context.user.name, instance_ref['id']))
+ (context.project.name, context.user.name, inst_id))
return self._format_run_instances(context, reservation_id)
def terminate_instances(self, context, instance_id, **kwargs):
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index d99d938af..c04dd213a 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -69,8 +69,8 @@ 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=[]):
+ def create_instance(self, context, instance_data, security_groups=[],
+ **kwargs):
"""Creates the instance in the datastore and returns the
new instance as a mapping
@@ -78,11 +78,15 @@ class ComputeManager(manager.Manager):
:param instance_data: mapping of instance options
:param security_groups: list of security group ids to
attach to the instance
+ :param **kwargs: All additional keyword args are treated
+ as data fields of the instance to be
+ created
:retval Returns a mapping of the instance information
that has just been created
"""
+ instance_data.update(kwargs)
instance_ref = self.db.instance_create(context, instance_data)
inst_id = instance_ref['id']
@@ -93,15 +97,20 @@ class ComputeManager(manager.Manager):
security_group_id)
return instance_ref
- def update_instance(self, context, instance_id, instance_data):
+ def update_instance(self, context, instance_id, instance_data,
+ **kwargs):
"""Updates the instance in the datastore
:param context: The security context
:param instance_data: mapping of instance options
+ :param **kwargs: All additional keyword args are treated
+ as data fields of the instance to be
+ updated
:retval None
"""
+ instance_data.update(kwargs)
self.db.instance_update(context, instance_id, instance_data)
@defer.inlineCallbacks