diff options
| author | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-12-01 15:53:27 -0600 |
|---|---|---|
| committer | Michael Gundlach <michael.gundlach@rackspace.com> | 2010-12-01 15:53:27 -0600 |
| commit | f53f5880c08994d04a552a41ce6f88dfbd867946 (patch) | |
| tree | 1a6c7bb4a9f187b48909eae576a0f682c739819f /nova/compute | |
| parent | fdf0aa30a1127eb8311a599dfdad9653ac699154 (diff) | |
| download | nova-f53f5880c08994d04a552a41ce6f88dfbd867946.tar.gz nova-f53f5880c08994d04a552a41ce6f88dfbd867946.tar.xz nova-f53f5880c08994d04a552a41ce6f88dfbd867946.zip | |
Oops, internal_id isn't available until after a save. This code saves twice; if I moved it into the DB layer we could do it in one save. However, we're moving to one sqlite db per compute worker, so I'd rather have two saves in order to keep the logic in the right layer.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/manager.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0893db9fc..6fc5c5186 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -99,10 +99,14 @@ class ComputeManager(manager.Manager): that has just been created """ - # Set sane defaults if not specified - kwargs.setdefault('display_name', "Server %s" % kwargs['internal_id']) instance_ref = self.db.instance_create(context, kwargs) inst_id = instance_ref['id'] + # Set sane defaults if not specified + if 'display_name' not in kwargs: + display_name = "Server %s" % instance_ref['internal_id'] + instance_ref['display_name'] = display_name + self.db.instance_update(context, inst_id, + { 'display_name': display_name }) elevated = context.elevated() if not security_groups: |
