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
a382ea56
Commit
a382ea56
authored
Jan 03, 2013
by
Stavros Sachtouris
Browse files
Add since arg in server_list
parent
3fe56be4
Changes
3
Hide whitespace changes
Inline
Side-by-side
kamaki/cli/commands/cyclades_cli.py
View file @
a382ea56
...
...
@@ -69,7 +69,10 @@ class server_list(_init_cyclades):
"""List servers"""
arguments
=
dict
(
detail
=
FlagArgument
(
'show detailed output'
,
'-l'
)
detail
=
FlagArgument
(
'show detailed output'
,
'-l'
),
since
=
ValueArgument
(
'show only items since date (
\'
d/m/Y H:M:S
\'
)'
,
'--since'
)
)
def
_info_print
(
self
,
server
):
...
...
@@ -98,8 +101,14 @@ class server_list(_init_cyclades):
def
main
(
self
):
super
(
self
.
__class__
,
self
).
main
()
try
:
servers
=
self
.
client
.
list_servers
(
self
[
'detail'
])
servers
=
self
.
client
.
list_servers
(
self
[
'detail'
]
,
self
[
'since'
]
)
self
.
_print
(
servers
)
except
ClientError
as
ce
:
if
ce
.
status
==
400
and
'changes-since'
in
(
'%s'
%
ce
):
raiseCLIError
(
None
,
'Incorrect date format for --since'
,
details
=
[
'Accepted date format: d/m/y'
])
raiseCLIError
(
ce
)
except
Exception
as
err
:
raiseCLIError
(
err
)
...
...
kamaki/clients/cyclades.py
View file @
a382ea56
...
...
@@ -93,6 +93,18 @@ class CycladesClient(CycladesClientApi):
r
=
self
.
servers_post
(
server_id
,
'action'
,
json_data
=
req
,
success
=
202
)
r
.
release
()
def
list_servers
(
self
,
detail
=
False
,
changes_since
=
None
):
"""
:param detail: (bool) append full server details to each item if true
:param changes_since: (date)
:returns: list of server ids and names
"""
detail
=
'detail'
if
detail
else
''
r
=
self
.
servers_get
(
command
=
detail
,
changes_since
=
changes_since
)
return
r
.
json
[
'servers'
][
'values'
]
def
list_server_nics
(
self
,
server_id
):
"""
:param server_id: integer (str or int)
...
...
kamaki/clients/cyclades_rest_api.py
View file @
a382ea56
...
...
@@ -39,6 +39,30 @@ import json
class
CycladesClientApi
(
ComputeClient
):
"""GRNet Cyclades REST API Client"""
def
servers_get
(
self
,
server_id
=
''
,
command
=
''
,
success
=
200
,
changes_since
=
None
,
**
kwargs
):
"""GET base_url/servers[/server_id][/command] request
:param server_id: integer (as int or str)
:param command: 'ips', 'stats', or ''
:param success: success code or list or tupple of accepted success
codes. if server response code is not in this list, a ClientError
raises
:param changes_since: (date)
:returns: request response
"""
path
=
path4url
(
'servers'
,
server_id
,
command
)
self
.
set_param
(
'changes-since'
,
changes_since
,
changes_since
)
return
self
.
get
(
path
,
success
=
success
,
**
kwargs
)
def
networks_get
(
self
,
network_id
=
''
,
command
=
''
,
success
=
(
200
,
203
),
**
kwargs
):
"""GET base_url/networks[/network_id][/command] request
...
...
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