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
67dfe4a2
Commit
67dfe4a2
authored
Nov 29, 2013
by
Stavros Sachtouris
Browse files
Remove waiters from networks, except port
Refs: #4624
parent
9b3c8fd9
Changes
2
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/network.py
View file @
67dfe4a2
...
...
@@ -60,14 +60,6 @@ about_authentication = '\nUser Authentication:\
\n
* to set authentication token: /config set cloud.<cloud>.token <token>'
class
_network_wait
(
_service_wait
):
def
_wait
(
self
,
net_id
,
current_status
,
timeout
=
60
):
super
(
_network_wait
,
self
).
_wait
(
'Network'
,
net_id
,
self
.
client
.
wait_network
,
current_status
,
timeout
=
timeout
)
class
_port_wait
(
_service_wait
):
def
_wait
(
self
,
port_id
,
current_status
,
timeout
=
60
):
...
...
@@ -76,14 +68,6 @@ class _port_wait(_service_wait):
timeout
=
timeout
)
class
_port_wait
(
_service_wait
):
def
_wait
(
self
,
net_id
,
current_status
,
timeout
=
60
):
super
(
_network_wait
,
self
).
_wait
(
'Network'
,
net_id
,
self
.
client
.
wait_network
,
current_status
,
timeout
=
timeout
)
class
_init_network
(
_command_init
):
@
errors
.
generic
.
all
@
addLogSettings
...
...
@@ -190,7 +174,7 @@ class NetworkTypeArgument(ValueArgument):
@
command
(
network_cmds
)
class
network_create
(
_init_network
,
_optional_json
,
_network_wait
):
class
network_create
(
_init_network
,
_optional_json
):
"""Create a new network"""
arguments
=
dict
(
...
...
@@ -199,8 +183,7 @@ class network_create(_init_network, _optional_json, _network_wait):
'Make network shared (special privileges required)'
,
'--shared'
),
network_type
=
NetworkTypeArgument
(
'Valid network types: %s'
%
(
', '
.
join
(
NetworkTypeArgument
.
types
)),
'--type'
),
wait
=
FlagArgument
(
'Wait network to build'
,
(
'-w'
,
'--wait'
)),
'--type'
)
)
required
=
(
'network_type'
,
)
...
...
@@ -210,8 +193,6 @@ class network_create(_init_network, _optional_json, _network_wait):
def
_run
(
self
,
network_type
):
net
=
self
.
client
.
create_network
(
network_type
,
name
=
self
[
'name'
],
shared
=
self
[
'shared'
])
if
self
[
'wait'
]:
self
.
_wait
(
net
[
'id'
],
net
[
'status'
])
self
.
_print
(
net
,
self
.
print_dict
)
def
main
(
self
):
...
...
@@ -254,33 +235,6 @@ class network_modify(_init_network, _optional_json):
self
.
_run
(
network_id
=
network_id
)
@
command
(
network_cmds
)
class
network_wait
(
_init_network
,
_network_wait
):
"""Wait for network to finish [PENDING, ACTIVE, DELETED]"""
arguments
=
dict
(
timeout
=
IntArgument
(
'Wait limit in seconds (default: 60)'
,
'--timeout'
,
default
=
60
)
)
@
errors
.
generic
.
all
@
errors
.
cyclades
.
connection
@
errors
.
cyclades
.
network_id
def
_run
(
self
,
network_id
,
current_status
):
net
=
self
.
client
.
get_network_details
(
network_id
)
if
net
[
'status'
].
lower
()
==
current_status
.
lower
():
self
.
_wait
(
network_id
,
current_status
,
timeout
=
self
[
'timeout'
])
else
:
self
.
error
(
'Network %s: Cannot wait for status %s, '
'status is already %s'
%
(
network_id
,
current_status
,
net
[
'status'
]))
def
main
(
self
,
network_id
,
current_status
=
'PENDING'
):
super
(
self
.
__class__
,
self
).
_run
()
self
.
_run
(
network_id
=
network_id
,
current_status
=
current_status
)
@
command
(
subnet_cmds
)
class
subnet_list
(
_init_network
,
_optional_json
,
_name_filter
,
_id_filter
):
"""List subnets
...
...
@@ -532,7 +486,7 @@ class port_create(_init_network, _optional_json, _port_wait):
@
command
(
port_cmds
)
class
port_wait
(
_init_network
,
_port_wait
):
"""Wait for port to finish [
PENDING, ACTIVE, DELETED
]"""
"""Wait for port to finish [
ACTIVE, DOWN, BUILD, ERROR
]"""
arguments
=
dict
(
timeout
=
IntArgument
(
...
...
@@ -551,7 +505,7 @@ class port_wait(_init_network, _port_wait):
'status is already %s'
%
(
port_id
,
current_status
,
port
[
'status'
]))
def
main
(
self
,
port_id
,
current_status
=
'
PENDING
'
):
def
main
(
self
,
port_id
,
current_status
=
'
BUILD
'
):
super
(
self
.
__class__
,
self
).
_run
()
self
.
_run
(
port_id
=
port_id
,
current_status
=
current_status
)
...
...
kamaki/clients/network/__init__.py
View file @
67dfe4a2
...
...
@@ -365,31 +365,9 @@ class NetworkClient(NetworkRestClient, Waiter):
# Wait methods
def
wait_network
(
self
,
net_id
,
current_status
=
'PENDING'
,
delay
=
1
,
max_wait
=
100
,
wait_cb
=
None
):
def
get_status
(
self
,
net_id
):
r
=
self
.
get_network_details
(
net_id
)
return
r
[
'status'
],
None
return
self
.
_wait
(
net_id
,
current_status
,
get_status
,
delay
,
max_wait
,
wait_cb
)
def
wait_subnet
(
self
,
subnet_id
,
current_status
=
'PENDING'
,
delay
=
1
,
max_wait
=
100
,
wait_cb
=
None
):
def
get_status
(
self
,
subnet_id
):
r
=
self
.
get_subnet_details
(
subnet_id
)
return
r
[
'status'
],
None
return
self
.
_wait
(
subnet_id
,
current_status
,
get_status
,
delay
,
max_wait
,
wait_cb
)
def
wait_port
(
self
,
port_id
,
current_status
=
'
PENDING
'
,
delay
=
1
,
max_wait
=
100
,
wait_cb
=
None
):
current_status
=
'
BUILD
'
,
delay
=
1
,
max_wait
=
100
,
wait_cb
=
None
):
def
get_status
(
self
,
net_id
):
r
=
self
.
get_port_details
(
port_id
)
...
...
@@ -397,15 +375,3 @@ class NetworkClient(NetworkRestClient, Waiter):
return
self
.
_wait
(
port_id
,
current_status
,
get_status
,
delay
,
max_wait
,
wait_cb
)
def
wait_floatingip
(
self
,
floatingip_id
,
current_status
=
'PENDING'
,
delay
=
1
,
max_wait
=
100
,
wait_cb
=
None
):
def
get_status
(
self
,
floatingip_id
):
r
=
self
.
get_network_details
(
floatingip_id
)
return
r
[
'status'
],
None
return
self
.
_wait
(
floatingip_id
,
current_status
,
get_status
,
delay
,
max_wait
,
wait_cb
)
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