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
df790bc6
Commit
df790bc6
authored
Jun 14, 2013
by
Kostas Papadimitriou
Browse files
helpdesk: Detect existing accounts with no active vms
parent
a02e3525
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/helpdesk/views.py
View file @
df790bc6
...
...
@@ -173,6 +173,8 @@ def account(request, search_query):
show_deleted
=
bool
(
int
(
request
.
GET
.
get
(
'deleted'
,
SHOW_DELETED_VMS
)))
account_exists
=
True
# flag to indicate successfull astakos calls
account_resolved
=
False
vms
=
[]
networks
=
[]
is_ip
=
IP_SEARCH_REGEX
.
match
(
search_query
)
...
...
@@ -205,20 +207,29 @@ def account(request, search_query):
retry
=
2
,
use_pool
=
True
,
logger
=
logger
)
account
=
None
if
is_uuid
:
account
=
search_query
account_name
=
astakos_client
.
get_username
(
auth_token
,
account
)
try
:
account_name
=
astakos_client
.
get_username
(
auth_token
,
account
)
except
:
logger
.
info
(
"Failed to resolve '%s' into account"
%
account
)
if
account_exists
and
not
is_uuid
:
account_name
=
search_query
account
=
astakos_client
.
get_uuid
(
auth_token
,
account_name
)
try
:
account
=
astakos_client
.
get_uuid
(
auth_token
,
account_name
)
except
:
logger
.
info
(
"Failed to resolve '%s' into account"
%
account_name
)
if
not
account
:
account_exists
=
False
else
:
account_resolved
=
True
filter_extra
=
{}
if
not
show_deleted
:
filter_extra
[
'deleted'
]
=
False
filter_extra
[
'deleted'
]
=
False
,
# all user vms
vms
=
VirtualMachine
.
objects
.
filter
(
userid
=
account
,
...
...
@@ -232,7 +243,8 @@ def account(request, search_query):
**
filter_extra
).
order_by
(
'state'
)
networks
=
list
(
public_networks
)
+
list
(
private_networks
)
if
vms
.
count
()
==
0
and
private_networks
.
count
()
==
0
:
if
vms
.
count
()
==
0
and
private_networks
.
count
()
==
0
and
not
\
account_resolved
:
account_exists
=
False
user_context
=
{
...
...
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