Merge "Map some of the SDK field names"
This commit is contained in:
commit
d31c301bd3
openstackclient
@ -39,6 +39,17 @@ _formatters = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_columns(item):
|
||||||
|
columns = item.keys()
|
||||||
|
if 'tenant_id' in columns:
|
||||||
|
columns.remove('tenant_id')
|
||||||
|
columns.append('project_id')
|
||||||
|
if 'router:external' in columns:
|
||||||
|
columns.remove('router:external')
|
||||||
|
columns.append('router_external')
|
||||||
|
return tuple(sorted(columns))
|
||||||
|
|
||||||
|
|
||||||
class CreateNetwork(show.ShowOne):
|
class CreateNetwork(show.ShowOne):
|
||||||
"""Create new network"""
|
"""Create new network"""
|
||||||
|
|
||||||
@ -91,9 +102,9 @@ class CreateNetwork(show.ShowOne):
|
|||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
body = self.get_body(parsed_args)
|
body = self.get_body(parsed_args)
|
||||||
obj = client.create_network(**body)
|
obj = client.create_network(**body)
|
||||||
columns = sorted(obj.keys())
|
columns = _get_columns(obj)
|
||||||
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
||||||
return (tuple(columns), data)
|
return (columns, data)
|
||||||
|
|
||||||
def get_body(self, parsed_args):
|
def get_body(self, parsed_args):
|
||||||
body = {'name': str(parsed_args.name),
|
body = {'name': str(parsed_args.name),
|
||||||
@ -290,6 +301,6 @@ class ShowNetwork(show.ShowOne):
|
|||||||
self.log.debug('take_action(%s)' % parsed_args)
|
self.log.debug('take_action(%s)' % parsed_args)
|
||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
obj = client.find_network(parsed_args.identifier, ignore_missing=False)
|
obj = client.find_network(parsed_args.identifier, ignore_missing=False)
|
||||||
columns = sorted(obj.keys())
|
columns = _get_columns(obj)
|
||||||
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
data = utils.get_item_properties(obj, columns, formatters=_formatters)
|
||||||
return (tuple(columns), data)
|
return (columns, data)
|
||||||
|
@ -73,11 +73,12 @@ class FakeNetwork(object):
|
|||||||
router_external, status, subnets, tenant_id
|
router_external, status, subnets, tenant_id
|
||||||
"""
|
"""
|
||||||
# Set default attributes.
|
# Set default attributes.
|
||||||
|
project_id = 'project-id-' + uuid.uuid4().hex
|
||||||
network_attrs = {
|
network_attrs = {
|
||||||
'id': 'network-id-' + uuid.uuid4().hex,
|
'id': 'network-id-' + uuid.uuid4().hex,
|
||||||
'name': 'network-name-' + uuid.uuid4().hex,
|
'name': 'network-name-' + uuid.uuid4().hex,
|
||||||
'status': 'ACTIVE',
|
'status': 'ACTIVE',
|
||||||
'tenant_id': 'project-id-' + uuid.uuid4().hex,
|
'tenant_id': project_id,
|
||||||
'admin_state_up': True,
|
'admin_state_up': True,
|
||||||
'shared': False,
|
'shared': False,
|
||||||
'subnets': ['a', 'b'],
|
'subnets': ['a', 'b'],
|
||||||
@ -101,6 +102,8 @@ class FakeNetwork(object):
|
|||||||
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
network = fakes.FakeResource(info=copy.deepcopy(network_attrs),
|
||||||
methods=copy.deepcopy(network_methods),
|
methods=copy.deepcopy(network_methods),
|
||||||
loaded=True)
|
loaded=True)
|
||||||
|
network.project_id = project_id
|
||||||
|
|
||||||
return network
|
return network
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -44,20 +44,20 @@ class TestCreateNetworkIdentityV3(TestNetwork):
|
|||||||
'admin_state_up',
|
'admin_state_up',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
|
'project_id',
|
||||||
'router_external',
|
'router_external',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
'tenant_id',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
network._format_admin_state(_network.admin_state_up),
|
network._format_admin_state(_network.admin_state_up),
|
||||||
_network.id,
|
_network.id,
|
||||||
_network.name,
|
_network.name,
|
||||||
|
_network.project_id,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
_network.tenant_id,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -186,20 +186,20 @@ class TestCreateNetworkIdentityV2(TestNetwork):
|
|||||||
'admin_state_up',
|
'admin_state_up',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
|
'project_id',
|
||||||
'router_external',
|
'router_external',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
'tenant_id',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
network._format_admin_state(_network.admin_state_up),
|
network._format_admin_state(_network.admin_state_up),
|
||||||
_network.id,
|
_network.id,
|
||||||
_network.name,
|
_network.name,
|
||||||
|
_network.project_id,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
_network.tenant_id,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -340,7 +340,7 @@ class TestListNetwork(TestNetwork):
|
|||||||
net.id,
|
net.id,
|
||||||
net.name,
|
net.name,
|
||||||
net.status,
|
net.status,
|
||||||
net.tenant_id,
|
net.project_id,
|
||||||
network._format_admin_state(net.admin_state_up),
|
network._format_admin_state(net.admin_state_up),
|
||||||
net.shared,
|
net.shared,
|
||||||
utils.format_list(net.subnets),
|
utils.format_list(net.subnets),
|
||||||
@ -485,20 +485,20 @@ class TestShowNetwork(TestNetwork):
|
|||||||
'admin_state_up',
|
'admin_state_up',
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
|
'project_id',
|
||||||
'router_external',
|
'router_external',
|
||||||
'status',
|
'status',
|
||||||
'subnets',
|
'subnets',
|
||||||
'tenant_id',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
data = (
|
data = (
|
||||||
network._format_admin_state(_network.admin_state_up),
|
network._format_admin_state(_network.admin_state_up),
|
||||||
_network.id,
|
_network.id,
|
||||||
_network.name,
|
_network.name,
|
||||||
|
_network.project_id,
|
||||||
network._format_router_external(_network.router_external),
|
network._format_router_external(_network.router_external),
|
||||||
_network.status,
|
_network.status,
|
||||||
utils.format_list(_network.subnets),
|
utils.format_list(_network.subnets),
|
||||||
_network.tenant_id,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user