Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
kamaki
Commits
737995ed
Commit
737995ed
authored
Nov 07, 2013
by
Stavros Sachtouris
Browse files
Add name to port create
Refs: #4563
parent
ccdd1b82
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/clients/cyclades/__init__.py
View file @
737995ed
...
...
@@ -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'
]
kamaki/clients/cyclades/test.py
View file @
737995ed
...
...
@@ -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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment