diff options
| author | Jesse Andrews <anotherjesse@gmail.com> | 2011-08-18 15:05:35 -0700 |
|---|---|---|
| committer | Jesse Andrews <anotherjesse@gmail.com> | 2011-08-18 15:05:35 -0700 |
| commit | 805c1cec609b39ee5a0ba1517bf2f1d41e0c4fa9 (patch) | |
| tree | f2fc444ce97bfaf127b96d3b7eb3d7a868ab7499 | |
| parent | b4c46652fda699d18ddb8f197e8fdda168d7ed0e (diff) | |
allow specification of key pair/security group info via metadata
extract metadata about keypair / security group configuration from server
metadata sent on create. This allows users to use these extensions with
their existing api implementations.
Also remove the code that choose the first key pair in the tenant - since
it seems to have been used during the development of os api
| -rw-r--r-- | nova/api/openstack/create_instance_helper.py | 21 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 1 |
2 files changed, 8 insertions, 14 deletions
diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py index b4a08dac0..031b06921 100644 --- a/nova/api/openstack/create_instance_helper.py +++ b/nova/api/openstack/create_instance_helper.py @@ -73,20 +73,15 @@ class CreateInstanceHelper(object): if not 'server' in body: raise exc.HTTPUnprocessableEntity() - server_dict = body['server'] context = req.environ['nova.context'] + server_dict = body['server'] + metadata = server_dict.get('metadata', {}) password = self.controller._get_server_admin_password(server_dict) - key_name = None - key_data = None - # TODO(vish): Key pair access should move into a common library - # instead of being accessed directly from the db. - key_pairs = db.key_pair_get_all_by_user(context.elevated(), - context.user_id) - if key_pairs: - key_pair = key_pairs[0] - key_name = key_pair['name'] - key_data = key_pair['public_key'] + # NOTE(ja): extract key_name and security_group from metadata + # to use in os extensions for firewall & keypairs + key_name = metadata.get('key_name') + security_group = metadata.get('security_group') image_href = self.controller._image_ref_from_req_data(body) # If the image href was generated by nova api, strip image_href @@ -155,8 +150,8 @@ class CreateInstanceHelper(object): display_name=name, display_description=name, key_name=key_name, - key_data=key_data, - metadata=server_dict.get('metadata', {}), + security_group=security_group, + metadata=metadata, injected_files=injected_files, admin_password=password, zone_blob=zone_blob, diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 335ecad86..2cf4e3eda 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -146,7 +146,6 @@ class Controller(object): def create(self, req, body): """ Creates a new server for a given user """ extra_values = None - result = None extra_values, instances = self.helper.create_instance( req, body, self.compute_api.create) |
