Client support port name
This patch implements port name support for the client. Change-Id: Ida51028fbfdb52de0731ed55e4458ec67f41037b Story: 2003091 Task: 23180
This commit is contained in:
parent
bc19ec26d1
commit
0357ed5436
@ -37,7 +37,7 @@ from ironicclient import exc
|
||||
# http://specs.openstack.org/openstack/ironic-specs/specs/kilo/api-microversions.html # noqa
|
||||
# for full details.
|
||||
DEFAULT_VER = '1.9'
|
||||
LAST_KNOWN_API_VERSION = 87
|
||||
LAST_KNOWN_API_VERSION = 88
|
||||
LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -106,6 +106,12 @@ class CreateBaremetalPort(command.ShowOne):
|
||||
action='store_true',
|
||||
help=_("Indicates whether this Port is a Smart NIC port"))
|
||||
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
dest='name',
|
||||
metavar='<port name>',
|
||||
help=_("Name of the port."))
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -231,6 +237,12 @@ class UnsetBaremetalPort(command.Command):
|
||||
action='store_true',
|
||||
help=_("Set Port as not Smart NIC port"))
|
||||
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
dest='name',
|
||||
action='store_true',
|
||||
help=_("Unset the name for this port"))
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -251,6 +263,9 @@ class UnsetBaremetalPort(command.Command):
|
||||
if parsed_args.is_smartnic:
|
||||
properties.extend(utils.args_array_to_patch(
|
||||
'add', ["is_smartnic=False"]))
|
||||
if parsed_args.name:
|
||||
properties.extend(utils.args_array_to_patch('remove',
|
||||
['name']))
|
||||
|
||||
if properties:
|
||||
baremetal_client.port.update(parsed_args.port, properties)
|
||||
@ -336,6 +351,12 @@ class SetBaremetalPort(command.Command):
|
||||
action='store_true',
|
||||
help=_("Set port to be Smart NIC port"))
|
||||
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
metavar='<name>',
|
||||
dest='name',
|
||||
help=_("Set name for this port"))
|
||||
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -372,6 +393,9 @@ class SetBaremetalPort(command.Command):
|
||||
if parsed_args.is_smartnic:
|
||||
is_smartnic = ["is_smartnic=%s" % parsed_args.is_smartnic]
|
||||
properties.extend(utils.args_array_to_patch('add', is_smartnic))
|
||||
if parsed_args.name:
|
||||
port_name = ["name=%s" % parsed_args.name]
|
||||
properties.extend(utils.args_array_to_patch('add', port_name))
|
||||
|
||||
if properties:
|
||||
baremetal_client.port.update(parsed_args.port, properties)
|
||||
|
@ -750,7 +750,8 @@ class TestBaremetalPortList(TestBaremetalPort):
|
||||
collist = ('UUID', 'Address', 'Created At', 'Extra', 'Node UUID',
|
||||
'Local Link Connection', 'Portgroup UUID',
|
||||
'PXE boot enabled', 'Physical Network', 'Updated At',
|
||||
'Internal Info', 'Is Smart NIC port')
|
||||
'Internal Info', 'Is Smart NIC port',
|
||||
'Port Name')
|
||||
self.assertEqual(collist, columns)
|
||||
|
||||
datalist = ((
|
||||
@ -765,7 +766,8 @@ class TestBaremetalPortList(TestBaremetalPort):
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
''
|
||||
'',
|
||||
'',
|
||||
), )
|
||||
self.assertEqual(datalist, tuple(data))
|
||||
|
||||
|
@ -30,7 +30,8 @@ PORT = {'uuid': '11111111-2222-3333-4444-555555555555',
|
||||
'portgroup_uuid': '55555555-4444-3333-2222-111111111111',
|
||||
'physical_network': 'physnet1',
|
||||
'is_smartnic': False,
|
||||
'extra': {}}
|
||||
'extra': {},
|
||||
'name': 'port_name'}
|
||||
|
||||
PORT2 = {'uuid': '55555555-4444-3333-2222-111111111111',
|
||||
'node_uuid': '55555555-4444-3333-2222-111111111111',
|
||||
@ -40,7 +41,8 @@ PORT2 = {'uuid': '55555555-4444-3333-2222-111111111111',
|
||||
'portgroup_uuid': '55555555-4444-3333-2222-111111111111',
|
||||
'physical_network': 'physnet2',
|
||||
'is_smartnic': True,
|
||||
'extra': {}}
|
||||
'extra': {},
|
||||
'name': 'port2_name'}
|
||||
|
||||
CREATE_PORT = copy.deepcopy(PORT)
|
||||
del CREATE_PORT['uuid']
|
||||
@ -306,6 +308,7 @@ class PortManagerTest(testtools.TestCase):
|
||||
self.assertEqual(PORT['portgroup_uuid'], port.portgroup_uuid)
|
||||
self.assertEqual(PORT['physical_network'], port.physical_network)
|
||||
self.assertEqual(PORT['is_smartnic'], port.is_smartnic)
|
||||
self.assertEqual(PORT['name'], port.name)
|
||||
|
||||
def test_ports_show_by_address(self):
|
||||
port = self.mgr.get_by_address(PORT['address'])
|
||||
|
@ -29,7 +29,7 @@ class PortManager(base.CreateManager):
|
||||
resource_class = Port
|
||||
_creation_attributes = ['address', 'extra', 'local_link_connection',
|
||||
'node_uuid', 'physical_network', 'portgroup_uuid',
|
||||
'pxe_enabled', 'uuid', 'is_smartnic']
|
||||
'pxe_enabled', 'uuid', 'is_smartnic', 'name']
|
||||
_resource_name = 'ports'
|
||||
|
||||
def list(self, address=None, limit=None, marker=None, sort_key=None,
|
||||
|
@ -157,6 +157,7 @@ class Resource(object):
|
||||
'parent_node': 'Parent Node',
|
||||
'children': 'Child Nodes',
|
||||
'firmware_interface': 'Firmware Interface',
|
||||
'port_name': 'Port Name',
|
||||
}
|
||||
|
||||
def __init__(self, field_ids, sort_excluded=None, override_labels=None):
|
||||
@ -345,6 +346,7 @@ PORT_DETAILED_RESOURCE = Resource(
|
||||
'updated_at',
|
||||
'internal_info',
|
||||
'is_smartnic',
|
||||
'port_name',
|
||||
],
|
||||
sort_excluded=[
|
||||
'extra',
|
||||
|
4
releasenotes/notes/port-name-6b1bf35a3939bedb.yaml
Normal file
4
releasenotes/notes/port-name-6b1bf35a3939bedb.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Adds ``name`` field support, which is introduced in ironic API 1.88.
|
Loading…
Reference in New Issue
Block a user