Return key name with server API
Change-Id: Ia8d7c917afc3bae04997161f8bb55c30cd196d60 Closes-Bug: #1712234
This commit is contained in:
parent
30a16bc608
commit
3b026239f9
@ -71,6 +71,7 @@ Response
|
|||||||
- created_at: created_at
|
- created_at: created_at
|
||||||
- metadata: metadata
|
- metadata: metadata
|
||||||
- affinity_zone: affinity_zone
|
- affinity_zone: affinity_zone
|
||||||
|
- key_name: key_name
|
||||||
|
|
||||||
**Example Create Server: JSON response**
|
**Example Create Server: JSON response**
|
||||||
|
|
||||||
@ -222,6 +223,7 @@ Response
|
|||||||
- launched_at: launched_at
|
- launched_at: launched_at
|
||||||
- metadata: metadata
|
- metadata: metadata
|
||||||
- affinity_zone: affinity_zone
|
- affinity_zone: affinity_zone
|
||||||
|
- key_name: key_name
|
||||||
|
|
||||||
**Example Detailed list of Servers: JSON response**
|
**Example Detailed list of Servers: JSON response**
|
||||||
|
|
||||||
@ -275,6 +277,7 @@ Response
|
|||||||
- launched_at: launched_at
|
- launched_at: launched_at
|
||||||
- metadata: metadata
|
- metadata: metadata
|
||||||
- affinity_zone: affinity_zone
|
- affinity_zone: affinity_zone
|
||||||
|
- key_name: key_name
|
||||||
|
|
||||||
**Example Server Details: JSON response**
|
**Example Server Details: JSON response**
|
||||||
|
|
||||||
@ -335,6 +338,7 @@ Response
|
|||||||
- created_at: created_at
|
- created_at: created_at
|
||||||
- metadata: metadata
|
- metadata: metadata
|
||||||
- affinity_zone: affinity_zone
|
- affinity_zone: affinity_zone
|
||||||
|
- key_name: key_name
|
||||||
|
|
||||||
**Example Update Server: JSON response**
|
**Example Update Server: JSON response**
|
||||||
|
|
||||||
|
@ -456,6 +456,9 @@ class Server(base.APIBase):
|
|||||||
affinity_zone = wtypes.text
|
affinity_zone = wtypes.text
|
||||||
"""The affinity zone of the server"""
|
"""The affinity zone of the server"""
|
||||||
|
|
||||||
|
key_name = wtypes.text
|
||||||
|
"""The ssh key name of the server"""
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(Server, self).__init__(**kwargs)
|
super(Server, self).__init__(**kwargs)
|
||||||
self.fields = []
|
self.fields = []
|
||||||
@ -472,7 +475,6 @@ class Server(base.APIBase):
|
|||||||
if not pecan.request.context.is_admin:
|
if not pecan.request.context.is_admin:
|
||||||
setattr(self, field, wtypes.Unset)
|
setattr(self, field, wtypes.Unset)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Skip fields we do not expose.
|
# Skip fields we do not expose.
|
||||||
if not hasattr(self, field):
|
if not hasattr(self, field):
|
||||||
continue
|
continue
|
||||||
@ -703,7 +705,6 @@ class ServerController(ServerControllerBase):
|
|||||||
flavor = objects.Flavor.get(pecan.request.context, flavor_uuid)
|
flavor = objects.Flavor.get(pecan.request.context, flavor_uuid)
|
||||||
if flavor.disabled:
|
if flavor.disabled:
|
||||||
raise exception.FlavorDisabled(flavor_id=flavor.uuid)
|
raise exception.FlavorDisabled(flavor_id=flavor.uuid)
|
||||||
|
|
||||||
servers = pecan.request.engine_api.create(
|
servers = pecan.request.engine_api.create(
|
||||||
pecan.request.context,
|
pecan.request.context,
|
||||||
flavor,
|
flavor,
|
||||||
|
@ -237,7 +237,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
|
|||||||
try:
|
try:
|
||||||
self.ironicclient.call("node.vif_detach", node.uuid,
|
self.ironicclient.call("node.vif_detach", node.uuid,
|
||||||
port_id)
|
port_id)
|
||||||
except ironic.exc.BadRequest:
|
except ironic_exc.BadRequest:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"VIF %(vif)s isn't attached to Ironic node %(node)s",
|
"VIF %(vif)s isn't attached to Ironic node %(node)s",
|
||||||
{'vif': port_id, 'node': node.uuid})
|
{'vif': port_id, 'node': node.uuid})
|
||||||
|
@ -79,6 +79,7 @@ def upgrade():
|
|||||||
sa.Column('locked', sa.Boolean(), nullable=True),
|
sa.Column('locked', sa.Boolean(), nullable=True),
|
||||||
sa.Column('affinity_zone', sa.String(length=255), nullable=True),
|
sa.Column('affinity_zone', sa.String(length=255), nullable=True),
|
||||||
sa.Column('locked_by', sa.Enum('admin', 'owner'), nullable=True),
|
sa.Column('locked_by', sa.Enum('admin', 'owner'), nullable=True),
|
||||||
|
sa.Column('key_name', sa.String(length=255), nullable=True),
|
||||||
sa.PrimaryKeyConstraint('id'),
|
sa.PrimaryKeyConstraint('id'),
|
||||||
sa.UniqueConstraint('uuid', name='uniq_servers0uuid'),
|
sa.UniqueConstraint('uuid', name='uniq_servers0uuid'),
|
||||||
mysql_ENGINE='InnoDB',
|
mysql_ENGINE='InnoDB',
|
||||||
|
@ -91,6 +91,7 @@ class Server(Base):
|
|||||||
locked = Column(Boolean)
|
locked = Column(Boolean)
|
||||||
locked_by = Column(Enum('owner', 'admin'))
|
locked_by = Column(Enum('owner', 'admin'))
|
||||||
affinity_zone = Column(String(255), nullable=True)
|
affinity_zone = Column(String(255), nullable=True)
|
||||||
|
key_name = Column(String(255), nullable=True)
|
||||||
|
|
||||||
|
|
||||||
class ServerNic(Base):
|
class ServerNic(Base):
|
||||||
|
@ -119,7 +119,8 @@ class API(object):
|
|||||||
'description': description,
|
'description': description,
|
||||||
'locked': False,
|
'locked': False,
|
||||||
'metadata': metadata or {},
|
'metadata': metadata or {},
|
||||||
'availability_zone': availability_zone}
|
'availability_zone': availability_zone,
|
||||||
|
'key_name': key_name}
|
||||||
|
|
||||||
# return the validated options
|
# return the validated options
|
||||||
return base_options, max_network_count, key_pair
|
return base_options, max_network_count, key_pair
|
||||||
@ -335,7 +336,6 @@ class API(object):
|
|||||||
azs = self.list_availability_zones(context)
|
azs = self.list_availability_zones(context)
|
||||||
if availability_zone not in azs['availability_zones']:
|
if availability_zone not in azs['availability_zones']:
|
||||||
raise exception.AZNotFound
|
raise exception.AZNotFound
|
||||||
|
|
||||||
return self._create_server(context, flavor,
|
return self._create_server(context, flavor,
|
||||||
image_uuid, name, description,
|
image_uuid, name, description,
|
||||||
availability_zone, metadata,
|
availability_zone, metadata,
|
||||||
|
@ -223,7 +223,6 @@ class GenerateConfigDriveTask(flow_utils.MoganTask):
|
|||||||
|
|
||||||
i_meta = server_metadata.ServerMetadata(
|
i_meta = server_metadata.ServerMetadata(
|
||||||
server, content=files, user_data=user_data, key_pair=key_pair)
|
server, content=files, user_data=user_data, key_pair=key_pair)
|
||||||
|
|
||||||
with tempfile.NamedTemporaryFile() as uncompressed:
|
with tempfile.NamedTemporaryFile() as uncompressed:
|
||||||
with configdrive.ConfigDriveBuilder(server_md=i_meta) as cdb:
|
with configdrive.ConfigDriveBuilder(server_md=i_meta) as cdb:
|
||||||
cdb.make_drive(uncompressed.name)
|
cdb.make_drive(uncompressed.name)
|
||||||
|
@ -55,6 +55,7 @@ class Server(base.MoganObject, object_base.VersionedObjectDictCompat):
|
|||||||
'locked': object_fields.BooleanField(default=False),
|
'locked': object_fields.BooleanField(default=False),
|
||||||
'locked_by': object_fields.StringField(nullable=True),
|
'locked_by': object_fields.StringField(nullable=True),
|
||||||
'affinity_zone': object_fields.StringField(nullable=True),
|
'affinity_zone': object_fields.StringField(nullable=True),
|
||||||
|
'key_name': object_fields.StringField(nullable=True),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, context=None, **kwargs):
|
def __init__(self, context=None, **kwargs):
|
||||||
|
@ -204,7 +204,7 @@ class TestServers(v1_test.APITestV1):
|
|||||||
resps = self.get_json('/servers/detail',
|
resps = self.get_json('/servers/detail',
|
||||||
headers=headers)['servers']
|
headers=headers)['servers']
|
||||||
self.assertEqual(4, len(resps))
|
self.assertEqual(4, len(resps))
|
||||||
self.assertEqual(16, len(resps[0].keys()))
|
self.assertEqual(17, len(resps[0].keys()))
|
||||||
self.assertEqual('test_server_0', resps[0]['name'])
|
self.assertEqual('test_server_0', resps[0]['name'])
|
||||||
self.assertEqual('just test server 0', resps[0]['description'])
|
self.assertEqual('just test server 0', resps[0]['description'])
|
||||||
self.assertEqual('building', resps[0]['status'])
|
self.assertEqual('building', resps[0]['status'])
|
||||||
|
@ -62,7 +62,8 @@ def get_test_server(**kw):
|
|||||||
'created_at': kw.get('created_at'),
|
'created_at': kw.get('created_at'),
|
||||||
'locked': kw.get('locked', False),
|
'locked': kw.get('locked', False),
|
||||||
'locked_by': kw.get('locked_by', None),
|
'locked_by': kw.get('locked_by', None),
|
||||||
'affinity_zone': kw.get('affinity_zone', 'ZON1')
|
'affinity_zone': kw.get('affinity_zone', 'ZON1'),
|
||||||
|
'key_name': kw.get('key_name', 'test_key')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ class _TestObject(object):
|
|||||||
# version bump. It is md5 hash of object fields and remotable methods.
|
# version bump. It is md5 hash of object fields and remotable methods.
|
||||||
# The fingerprint values should only be changed if there is a version bump.
|
# The fingerprint values should only be changed if there is a version bump.
|
||||||
expected_object_fingerprints = {
|
expected_object_fingerprints = {
|
||||||
'Server': '1.0-6d6a620781fe8da4feaec11272e3e5d3',
|
'Server': '1.0-10767895d6aa0397ef2391d8ca2f8327',
|
||||||
'ServerFault': '1.0-74349ff701259e4834b4e9dc2dac1b12',
|
'ServerFault': '1.0-74349ff701259e4834b4e9dc2dac1b12',
|
||||||
'ServerFaultList': '1.0-43e8aad0258652921f929934e9e048fd',
|
'ServerFaultList': '1.0-43e8aad0258652921f929934e9e048fd',
|
||||||
'Flavor': '1.0-9f7166aa387d89ec40cd699019d0c9a9',
|
'Flavor': '1.0-9f7166aa387d89ec40cd699019d0c9a9',
|
||||||
|
Loading…
Reference in New Issue
Block a user