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
synnefo
Commits
287c45c2
Commit
287c45c2
authored
Apr 17, 2013
by
Giorgos Korfiatis
Browse files
Update resource-list management command
parent
4e8083bd
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-astakos-app/astakos/im/management/commands/resource-list.py
View file @
287c45c2
...
...
@@ -31,42 +31,21 @@
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
from
optparse
import
make_option
from
django.core.management.base
import
NoArgsCommand
from
astakos.im.models
import
Resource
from
synnefo.webproject.management.commands
import
ListCommand
class
Command
(
NoArgs
Command
):
class
Command
(
List
Command
):
help
=
"List resources"
option_list
=
NoArgsCommand
.
option_list
+
(
make_option
(
'-c'
,
action
=
'store_true'
,
dest
=
'csv'
,
default
=
False
,
help
=
"Use pipes to separate values"
),
)
def
handle_noargs
(
self
,
**
options
):
resources
=
Resource
.
objects
.
select_related
().
all
()
labels
=
(
'id'
,
'service'
,
'name'
)
columns
=
(
3
,
40
,
40
)
if
not
options
[
'csv'
]:
line
=
' '
.
join
(
l
.
rjust
(
w
)
for
l
,
w
in
zip
(
labels
,
columns
))
self
.
stdout
.
write
(
line
+
'
\n
'
)
sep
=
'-'
*
len
(
line
)
self
.
stdout
.
write
(
sep
+
'
\n
'
)
for
r
in
resources
:
fields
=
(
str
(
r
.
id
),
r
.
service
.
name
,
r
.
name
)
if
options
[
'csv'
]:
line
=
'|'
.
join
(
fields
)
else
:
line
=
' '
.
join
(
f
.
rjust
(
w
)
for
f
,
w
in
zip
(
fields
,
columns
))
self
.
stdout
.
write
(
line
+
'
\n
'
)
object_class
=
Resource
FIELDS
=
{
"id"
:
(
"id"
,
"ID"
),
"name"
:
(
"name"
,
"Resource Name"
),
"service"
:
(
"service"
,
"Service"
),
"unit"
:
(
"unit"
,
"Unit"
),
"limit"
:
(
"uplimit"
,
"Base Quota"
),
"description"
:
(
"desc"
,
"Description"
),
}
fields
=
[
"id"
,
"name"
,
"service"
,
"unit"
,
"limit"
,
"description"
]
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