Commit 737995ed authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Add name to port create

Refs: #4563
parent ccdd1b82
......@@ -526,9 +526,12 @@ class CycladesNetworkClient(NetworkClient):
r = self.networks_post(json_data=req, success=201)
return r.json['network']
def create_port(self, network_id, device_id, security_groups=None):
def create_port(
self, network_id, device_id, security_groups=None, name=None):
port = dict(network_id=network_id, device_id=device_id)
if security_groups:
port['security_groups'] = security_groups
if name:
port['name'] = name
r = self.ports_post(json_data=dict(port=port), success=201)
return r.json['port']
......@@ -282,14 +282,17 @@ class CycladesNetworkClient(TestCase):
return_value=FR)
def test_create_port(self, ports_post):
network_id, device_id, FR.json = 'netid', 'devid', dict(port='ret v')
for security_groups in ([1, 2, 3], None):
for name, sec_grp in product(('port name', None), ([1, 2, 3], None)):
self.assertEqual(
self.client.create_port(
network_id, device_id, security_groups=security_groups),
network_id, device_id,
name=name, security_groups=sec_grp),
'ret v')
req = dict(network_id=network_id, device_id=device_id)
if security_groups:
req['security_groups'] = security_groups
if sec_grp:
req['security_groups'] = sec_grp
if name:
req['name'] = name
expargs = dict(json_data=dict(port=req), success=201)
self.assertEqual(ports_post.mock_calls[-1], call(**expargs))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment