Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9c20e518
authored
Oct 21, 2015
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'flake8fixes' into 'master'
Fix flake8 warnings Closes #429 See merge request !355
parents
0282e224
46323c27
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
70 additions
and
69 deletions
+70
-69
circle/acl/models.py
+2
-2
circle/circle/wsgi.py
+1
-1
circle/common/models.py
+4
-4
circle/dashboard/autocomplete_light_registry.py
+4
-4
circle/dashboard/forms.py
+4
-4
circle/dashboard/management/commands/init.py
+2
-2
circle/dashboard/tests/selenium/util.py
+2
-2
circle/dashboard/views/user.py
+2
-2
circle/dashboard/views/vm.py
+7
-6
circle/firewall/fields.py
+4
-4
circle/firewall/models.py
+2
-2
circle/manager/scheduler.py
+2
-2
circle/monitor/tasks/local_periodic_tasks.py
+3
-3
circle/network/views.py
+2
-2
circle/vm/models/activity.py
+2
-2
circle/vm/models/common.py
+2
-2
circle/vm/models/instance.py
+2
-2
circle/vm/operations.py
+23
-23
No files found.
circle/acl/models.py
View file @
9c20e518
...
@@ -246,8 +246,8 @@ class AclBase(Model):
...
@@ -246,8 +246,8 @@ class AclBase(Model):
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
super
(
AclBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
super
(
AclBase
,
self
)
.
save
(
*
args
,
**
kwargs
)
if
'owner'
in
dict
(
self
.
ACL_LEVELS
)
and
(
hasattr
(
self
,
'owner'
)
if
'owner'
in
dict
(
self
.
ACL_LEVELS
)
and
(
hasattr
(
self
,
'owner'
)
and
and
self
.
owner
):
self
.
owner
):
self
.
set_user_level
(
self
.
owner
,
'owner'
)
self
.
set_user_level
(
self
.
owner
,
'owner'
)
class
Meta
:
class
Meta
:
...
...
circle/circle/wsgi.py
View file @
9c20e518
...
@@ -46,7 +46,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "circle.settings.production")
...
@@ -46,7 +46,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "circle.settings.production")
# This application object is used by any WSGI server configured to use this
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
# setting points here.
from
django.core.wsgi
import
get_wsgi_application
from
django.core.wsgi
import
get_wsgi_application
# noqa
_application
=
get_wsgi_application
()
_application
=
get_wsgi_application
()
...
...
circle/common/models.py
View file @
9c20e518
...
@@ -97,7 +97,7 @@ def has_prefix(activity_code, *prefixes):
...
@@ -97,7 +97,7 @@ def has_prefix(activity_code, *prefixes):
>>> assert has_prefix('foo.bar.buz', 'foo', 'bar', 'buz')
>>> assert has_prefix('foo.bar.buz', 'foo', 'bar', 'buz')
>>> assert not has_prefix('foo.bar.buz', 'foo', 'buz')
>>> assert not has_prefix('foo.bar.buz', 'foo', 'buz')
"""
"""
equal
=
lambda
a
,
b
:
a
==
b
def
equal
(
a
,
b
):
return
a
==
b
act_code_parts
=
split_activity_code
(
activity_code
)
act_code_parts
=
split_activity_code
(
activity_code
)
prefixes
=
chain
(
*
imap
(
split_activity_code
,
prefixes
))
prefixes
=
chain
(
*
imap
(
split_activity_code
,
prefixes
))
return
all
(
imap
(
equal
,
act_code_parts
,
prefixes
))
return
all
(
imap
(
equal
,
act_code_parts
,
prefixes
))
...
@@ -112,7 +112,7 @@ def has_suffix(activity_code, *suffixes):
...
@@ -112,7 +112,7 @@ def has_suffix(activity_code, *suffixes):
>>> assert has_suffix('foo.bar.buz', 'foo', 'bar', 'buz')
>>> assert has_suffix('foo.bar.buz', 'foo', 'bar', 'buz')
>>> assert not has_suffix('foo.bar.buz', 'foo', 'buz')
>>> assert not has_suffix('foo.bar.buz', 'foo', 'buz')
"""
"""
equal
=
lambda
a
,
b
:
a
==
b
def
equal
(
a
,
b
):
return
a
==
b
act_code_parts
=
split_activity_code
(
activity_code
)
act_code_parts
=
split_activity_code
(
activity_code
)
suffixes
=
list
(
chain
(
*
imap
(
split_activity_code
,
suffixes
)))
suffixes
=
list
(
chain
(
*
imap
(
split_activity_code
,
suffixes
)))
return
all
(
imap
(
equal
,
reversed
(
act_code_parts
),
reversed
(
suffixes
)))
return
all
(
imap
(
equal
,
reversed
(
act_code_parts
),
reversed
(
suffixes
)))
...
@@ -441,8 +441,8 @@ class HumanReadableObject(object):
...
@@ -441,8 +441,8 @@ class HumanReadableObject(object):
@classmethod
@classmethod
def
create
(
cls
,
user_text_template
,
admin_text_template
=
None
,
**
params
):
def
create
(
cls
,
user_text_template
,
admin_text_template
=
None
,
**
params
):
return
cls
(
user_text_template
=
user_text_template
,
return
cls
(
user_text_template
=
user_text_template
,
admin_text_template
=
(
admin_text_template
admin_text_template
=
(
admin_text_template
or
or
user_text_template
),
params
=
params
)
user_text_template
),
params
=
params
)
def
set
(
self
,
user_text_template
,
admin_text_template
=
None
,
**
params
):
def
set
(
self
,
user_text_template
,
admin_text_template
=
None
,
**
params
):
self
.
_set_values
(
user_text_template
,
self
.
_set_values
(
user_text_template
,
...
...
circle/dashboard/autocomplete_light_registry.py
View file @
9c20e518
...
@@ -38,10 +38,10 @@ def highlight(field, q, none_wo_match=True):
...
@@ -38,10 +38,10 @@ def highlight(field, q, none_wo_match=True):
match
=
None
match
=
None
if
q
and
match
is
not
None
:
if
q
and
match
is
not
None
:
match_end
=
match
+
len
(
q
)
match_end
=
match
+
len
(
q
)
return
(
escape
(
field
[:
match
])
return
(
escape
(
field
[:
match
])
+
+
'<span class="autocomplete-hl">'
'<span class="autocomplete-hl">'
+
+
escape
(
field
[
match
:
match_end
])
escape
(
field
[
match
:
match_end
])
+
+
'</span>'
+
escape
(
field
[
match_end
:]))
'</span>'
+
escape
(
field
[
match_end
:]))
elif
none_wo_match
:
elif
none_wo_match
:
return
None
return
None
else
:
else
:
...
...
circle/dashboard/forms.py
View file @
9c20e518
...
@@ -506,8 +506,8 @@ class TemplateForm(forms.ModelForm):
...
@@ -506,8 +506,8 @@ class TemplateForm(forms.ModelForm):
self
.
allowed_fields
=
(
self
.
allowed_fields
=
(
'name'
,
'access_method'
,
'description'
,
'system'
,
'tags'
,
'name'
,
'access_method'
,
'description'
,
'system'
,
'tags'
,
'arch'
,
'lease'
,
'has_agent'
)
'arch'
,
'lease'
,
'has_agent'
)
if
(
self
.
user
.
has_perm
(
'vm.change_template_resources'
)
if
(
self
.
user
.
has_perm
(
'vm.change_template_resources'
)
or
or
not
self
.
instance
.
pk
):
not
self
.
instance
.
pk
):
self
.
allowed_fields
+=
tuple
(
set
(
self
.
fields
.
keys
())
-
self
.
allowed_fields
+=
tuple
(
set
(
self
.
fields
.
keys
())
-
set
([
'raw_data'
]))
set
([
'raw_data'
]))
if
self
.
user
.
is_superuser
:
if
self
.
user
.
is_superuser
:
...
@@ -523,8 +523,8 @@ class TemplateForm(forms.ModelForm):
...
@@ -523,8 +523,8 @@ class TemplateForm(forms.ModelForm):
self
.
initial
[
'max_ram_size'
]
=
512
self
.
initial
[
'max_ram_size'
]
=
512
lease_queryset
=
(
lease_queryset
=
(
Lease
.
get_objects_with_level
(
"operator"
,
self
.
user
)
.
distinct
()
Lease
.
get_objects_with_level
(
"operator"
,
self
.
user
)
.
distinct
()
|
|
Lease
.
objects
.
filter
(
pk
=
self
.
instance
.
lease_id
)
.
distinct
())
Lease
.
objects
.
filter
(
pk
=
self
.
instance
.
lease_id
)
.
distinct
())
self
.
fields
[
"lease"
]
.
queryset
=
lease_queryset
self
.
fields
[
"lease"
]
.
queryset
=
lease_queryset
...
...
circle/dashboard/management/commands/init.py
View file @
9c20e518
...
@@ -64,8 +64,8 @@ class Command(BaseCommand):
...
@@ -64,8 +64,8 @@ class Command(BaseCommand):
def
handle
(
self
,
*
args
,
**
options
):
def
handle
(
self
,
*
args
,
**
options
):
self
.
changed
=
False
self
.
changed
=
False
if
(
DataStore
.
objects
.
exists
()
and
Vlan
.
objects
.
exists
()
if
(
DataStore
.
objects
.
exists
()
and
Vlan
.
objects
.
exists
()
and
and
not
options
[
'force'
]):
not
options
[
'force'
]):
return
self
.
print_state
()
return
self
.
print_state
()
admin
=
self
.
create
(
User
,
'username'
,
username
=
options
[
'admin_user'
],
admin
=
self
.
create
(
User
,
'username'
,
username
=
options
[
'admin_user'
],
...
...
circle/dashboard/tests/selenium/util.py
View file @
9c20e518
...
@@ -601,8 +601,8 @@ class CircleSeleniumMixin(SeleniumMixin):
...
@@ -601,8 +601,8 @@ class CircleSeleniumMixin(SeleniumMixin):
choices
=
self
.
driver
.
find_elements_by_css_selector
(
choices
=
self
.
driver
.
find_elements_by_css_selector
(
"input[type='radio']"
)
"input[type='radio']"
)
choice_list
=
[
item
for
item
in
choices
if
(
choice_list
=
[
item
for
item
in
choices
if
(
'test'
not
in
item
.
get_attribute
(
'value'
)
'test'
not
in
item
.
get_attribute
(
'value'
)
and
and
item
.
get_attribute
(
'value'
)
!=
'base_vm'
)]
item
.
get_attribute
(
'value'
)
!=
'base_vm'
)]
chosen
=
random
.
randint
(
0
,
len
(
choice_list
)
-
1
)
chosen
=
random
.
randint
(
0
,
len
(
choice_list
)
-
1
)
choice_list
[
chosen
]
.
click
()
choice_list
[
chosen
]
.
click
()
self
.
driver
.
find_element_by_id
(
self
.
driver
.
find_element_by_id
(
...
...
circle/dashboard/views/user.py
View file @
9c20e518
...
@@ -545,8 +545,8 @@ class UserList(LoginRequiredMixin, PermissionRequiredMixin, SingleTableView):
...
@@ -545,8 +545,8 @@ class UserList(LoginRequiredMixin, PermissionRequiredMixin, SingleTableView):
q
=
self
.
search_form
.
cleaned_data
.
get
(
's'
)
q
=
self
.
search_form
.
cleaned_data
.
get
(
's'
)
if
q
:
if
q
:
filters
=
(
Q
(
username__icontains
=
q
)
|
Q
(
email__icontains
=
q
)
filters
=
(
Q
(
username__icontains
=
q
)
|
Q
(
email__icontains
=
q
)
|
|
Q
(
profile__org_id__icontains
=
q
))
Q
(
profile__org_id__icontains
=
q
))
for
w
in
q
.
split
()[:
3
]:
for
w
in
q
.
split
()[:
3
]:
filters
|=
(
filters
|=
(
Q
(
first_name__icontains
=
w
)
|
Q
(
last_name__icontains
=
w
))
Q
(
first_name__icontains
=
w
)
|
Q
(
last_name__icontains
=
w
))
...
...
circle/dashboard/views/vm.py
View file @
9c20e518
...
@@ -150,8 +150,8 @@ class VmDetailView(GraphMixin, CheckedDetailView):
...
@@ -150,8 +150,8 @@ class VmDetailView(GraphMixin, CheckedDetailView):
# resources forms
# resources forms
can_edit
=
(
can_edit
=
(
instance
.
has_level
(
user
,
"owner"
)
instance
.
has_level
(
user
,
"owner"
)
and
and
self
.
request
.
user
.
has_perm
(
"vm.change_resources"
))
self
.
request
.
user
.
has_perm
(
"vm.change_resources"
))
context
[
'resources_form'
]
=
VmResourcesForm
(
context
[
'resources_form'
]
=
VmResourcesForm
(
can_edit
=
can_edit
,
instance
=
instance
)
can_edit
=
can_edit
,
instance
=
instance
)
...
@@ -569,8 +569,8 @@ class VmResourcesChangeView(VmOperationView):
...
@@ -569,8 +569,8 @@ class VmResourcesChangeView(VmOperationView):
content_type
=
"application=json"
content_type
=
"application=json"
)
)
else
:
else
:
return
HttpResponseRedirect
(
instance
.
get_absolute_url
()
return
HttpResponseRedirect
(
instance
.
get_absolute_url
()
+
+
"#resources"
)
"#resources"
)
else
:
else
:
extra
=
form
.
cleaned_data
extra
=
form
.
cleaned_data
extra
[
'max_ram_size'
]
=
extra
[
'ram_size'
]
extra
[
'max_ram_size'
]
=
extra
[
'ram_size'
]
...
@@ -1261,8 +1261,9 @@ def vm_activity(request, pk):
...
@@ -1261,8 +1261,9 @@ def vm_activity(request, pk):
response
[
'status'
]
=
instance
.
status
response
[
'status'
]
=
instance
.
status
response
[
'icon'
]
=
instance
.
get_status_icon
()
response
[
'icon'
]
=
instance
.
get_status_icon
()
latest
=
instance
.
get_latest_activity_in_progress
()
latest
=
instance
.
get_latest_activity_in_progress
()
response
[
'is_new_state'
]
=
(
latest
and
latest
.
resultant_state
is
not
None
response
[
'is_new_state'
]
=
(
latest
and
and
instance
.
status
!=
latest
.
resultant_state
)
latest
.
resultant_state
is
not
None
and
instance
.
status
!=
latest
.
resultant_state
)
context
=
{
context
=
{
'instance'
:
instance
,
'instance'
:
instance
,
...
...
circle/firewall/fields.py
View file @
9c20e518
...
@@ -188,11 +188,11 @@ class IPNetworkField(models.Field):
...
@@ -188,11 +188,11 @@ class IPNetworkField(models.Field):
if
isinstance
(
value
,
IPNetwork
):
if
isinstance
(
value
,
IPNetwork
):
if
self
.
version
==
4
:
if
self
.
version
==
4
:
return
(
'.'
.
join
(
"
%03
d"
%
x
for
x
in
value
.
ip
.
words
)
return
(
'.'
.
join
(
"
%03
d"
%
x
for
x
in
value
.
ip
.
words
)
+
+
'/
%02
d'
%
value
.
prefixlen
)
'/
%02
d'
%
value
.
prefixlen
)
else
:
else
:
return
(
':'
.
join
(
"
%04
X"
%
x
for
x
in
value
.
ip
.
words
)
return
(
':'
.
join
(
"
%04
X"
%
x
for
x
in
value
.
ip
.
words
)
+
+
'/
%03
d'
%
value
.
prefixlen
)
'/
%03
d'
%
value
.
prefixlen
)
return
value
return
value
def
formfield
(
self
,
**
kwargs
):
def
formfield
(
self
,
**
kwargs
):
...
...
circle/firewall/models.py
View file @
9c20e518
...
@@ -700,8 +700,8 @@ class Host(models.Model):
...
@@ -700,8 +700,8 @@ class Host(models.Model):
return
self
.
vlan
.
network_type
!=
'public'
return
self
.
vlan
.
network_type
!=
'public'
def
clean
(
self
):
def
clean
(
self
):
if
(
self
.
external_ipv4
and
not
self
.
shared_ip
and
self
.
behind_nat
if
(
self
.
external_ipv4
and
not
self
.
shared_ip
and
self
.
behind_nat
and
and
Host
.
objects
.
exclude
(
id
=
self
.
id
)
.
filter
(
Host
.
objects
.
exclude
(
id
=
self
.
id
)
.
filter
(
external_ipv4
=
self
.
external_ipv4
)):
external_ipv4
=
self
.
external_ipv4
)):
raise
ValidationError
(
_
(
"If shared_ip has been checked, "
raise
ValidationError
(
_
(
"If shared_ip has been checked, "
"external_ipv4 has to be unique."
))
"external_ipv4 has to be unique."
))
...
...
circle/manager/scheduler.py
View file @
9c20e518
...
@@ -55,8 +55,8 @@ def select_node(instance, nodes):
...
@@ -55,8 +55,8 @@ def select_node(instance, nodes):
'''
'''
# check required traits
# check required traits
nodes
=
[
n
for
n
in
nodes
nodes
=
[
n
for
n
in
nodes
if
n
.
schedule_enabled
and
n
.
online
if
n
.
schedule_enabled
and
n
.
online
and
and
has_traits
(
instance
.
req_traits
.
all
(),
n
)]
has_traits
(
instance
.
req_traits
.
all
(),
n
)]
if
not
nodes
:
if
not
nodes
:
logger
.
warning
(
'select_node: no usable node for
%
s'
,
unicode
(
instance
))
logger
.
warning
(
'select_node: no usable node for
%
s'
,
unicode
(
instance
))
raise
TraitsUnsatisfiableException
()
raise
TraitsUnsatisfiableException
()
...
...
circle/monitor/tasks/local_periodic_tasks.py
View file @
9c20e518
...
@@ -54,7 +54,7 @@ def measure_response_time():
...
@@ -54,7 +54,7 @@ def measure_response_time():
@celery.task
(
ignore_result
=
True
)
@celery.task
(
ignore_result
=
True
)
def
check_celery_queues
():
def
check_celery_queues
():
graphite_string
=
lambda
component
,
hostname
,
celery
,
is_alive
,
time
:
(
def
graphite_string
(
component
,
hostname
,
celery
,
is_alive
,
time
):
return
(
"
%
s.
%
s.celery-queues.
%
s
%
d
%
s"
%
(
"
%
s.
%
s.celery-queues.
%
s
%
d
%
s"
%
(
component
,
hostname
,
celery
,
1
if
is_alive
else
0
,
time
)
component
,
hostname
,
celery
,
1
if
is_alive
else
0
,
time
)
)
)
...
@@ -92,7 +92,7 @@ def check_celery_queues():
...
@@ -92,7 +92,7 @@ def check_celery_queues():
@celery.task
(
ignore_result
=
True
)
@celery.task
(
ignore_result
=
True
)
def
instance_per_template
():
def
instance_per_template
():
graphite_string
=
lambda
pk
,
state
,
val
,
time
:
(
def
graphite_string
(
pk
,
state
,
val
,
time
):
return
(
"template.
%
d.instances.
%
s
%
d
%
s"
%
(
"template.
%
d.instances.
%
s
%
d
%
s"
%
(
pk
,
state
,
val
,
time
)
pk
,
state
,
val
,
time
)
)
)
...
@@ -111,7 +111,7 @@ def instance_per_template():
...
@@ -111,7 +111,7 @@ def instance_per_template():
@celery.task
(
ignore_result
=
True
)
@celery.task
(
ignore_result
=
True
)
def
allocated_memory
():
def
allocated_memory
():
graphite_string
=
lambda
hostname
,
val
,
time
:
(
def
graphite_string
(
hostname
,
val
,
time
):
return
(
"circle.
%
s.memory.allocated
%
d
%
s"
%
(
"circle.
%
s.memory.allocated
%
d
%
s"
%
(
hostname
,
val
,
time
)
hostname
,
val
,
time
)
)
)
...
...
circle/network/views.py
View file @
9c20e518
...
@@ -979,8 +979,8 @@ def remove_switch_port_device(request, **kwargs):
...
@@ -979,8 +979,8 @@ def remove_switch_port_device(request, **kwargs):
def
add_switch_port_device
(
request
,
**
kwargs
):
def
add_switch_port_device
(
request
,
**
kwargs
):
device_name
=
request
.
POST
.
get
(
'device_name'
)
device_name
=
request
.
POST
.
get
(
'device_name'
)
if
(
request
.
method
==
"POST"
and
device_name
and
len
(
device_name
)
>
0
if
(
request
.
method
==
"POST"
and
device_name
and
len
(
device_name
)
>
0
and
and
EthernetDevice
.
objects
.
filter
(
name
=
device_name
)
.
count
()
==
0
):
EthernetDevice
.
objects
.
filter
(
name
=
device_name
)
.
count
()
==
0
):
switch_port
=
SwitchPort
.
objects
.
get
(
pk
=
kwargs
[
'pk'
])
switch_port
=
SwitchPort
.
objects
.
get
(
pk
=
kwargs
[
'pk'
])
new_device
=
EthernetDevice
(
name
=
device_name
,
switch_port
=
switch_port
)
new_device
=
EthernetDevice
(
name
=
device_name
,
switch_port
=
switch_port
)
...
...
circle/vm/models/activity.py
View file @
9c20e518
...
@@ -145,8 +145,8 @@ class InstanceActivity(ActivityModel):
...
@@ -145,8 +145,8 @@ class InstanceActivity(ActivityModel):
def
has_percentage
(
self
):
def
has_percentage
(
self
):
op
=
self
.
instance
.
get_operation_from_activity_code
(
self
.
activity_code
)
op
=
self
.
instance
.
get_operation_from_activity_code
(
self
.
activity_code
)
return
(
self
.
task_uuid
and
op
and
op
.
has_percentage
return
(
self
.
task_uuid
and
op
and
op
.
has_percentage
and
and
not
self
.
finished
)
not
self
.
finished
)
def
get_percentage
(
self
):
def
get_percentage
(
self
):
"""Returns the percentage of the running operation if available.
"""Returns the percentage of the running operation if available.
...
...
circle/vm/models/common.py
View file @
9c20e518
...
@@ -174,6 +174,6 @@ class Trait(Model):
...
@@ -174,6 +174,6 @@ class Trait(Model):
@property
@property
def
in_use
(
self
):
def
in_use
(
self
):
return
(
return
(
self
.
instance_set
.
exists
()
or
self
.
node_set
.
exists
()
self
.
instance_set
.
exists
()
or
self
.
node_set
.
exists
()
or
or
self
.
instancetemplate_set
.
exists
()
self
.
instancetemplate_set
.
exists
()
)
)
circle/vm/models/instance.py
View file @
9c20e518
...
@@ -852,8 +852,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -852,8 +852,8 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
is_in_status_change
(
self
):
def
is_in_status_change
(
self
):
latest
=
self
.
get_latest_activity_in_progress
()
latest
=
self
.
get_latest_activity_in_progress
()
return
(
latest
and
latest
.
resultant_state
is
not
None
return
(
latest
and
latest
.
resultant_state
is
not
None
and
and
self
.
status
!=
latest
.
resultant_state
)
self
.
status
!=
latest
.
resultant_state
)
@property
@property
def
metric_prefix
(
self
):
def
metric_prefix
(
self
):
...
...
circle/vm/operations.py
View file @
9c20e518
...
@@ -133,8 +133,8 @@ class InstanceOperation(Operation):
...
@@ -133,8 +133,8 @@ class InstanceOperation(Operation):
super
(
InstanceOperation
,
self
)
.
check_auth
(
user
=
user
)
super
(
InstanceOperation
,
self
)
.
check_auth
(
user
=
user
)
if
(
self
.
instance
.
node
and
not
self
.
instance
.
node
.
online
if
(
self
.
instance
.
node
and
not
self
.
instance
.
node
.
online
and
and
not
user
.
is_superuser
):
not
user
.
is_superuser
):
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
create_activity
(
self
,
parent
,
user
,
kwargs
):
def
create_activity
(
self
,
parent
,
user
,
kwargs
):
...
@@ -534,8 +534,8 @@ class MigrateOperation(RemoteInstanceOperation):
...
@@ -534,8 +534,8 @@ class MigrateOperation(RemoteInstanceOperation):
remote_timeout
=
1000
remote_timeout
=
1000
def
_get_remote_args
(
self
,
to_node
,
live_migration
,
**
kwargs
):
def
_get_remote_args
(
self
,
to_node
,
live_migration
,
**
kwargs
):
return
(
super
(
MigrateOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
MigrateOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
to_node
.
host
.
hostname
,
live_migration
])
[
to_node
.
host
.
hostname
,
live_migration
])
def
rollback
(
self
,
activity
):
def
rollback
(
self
,
activity
):
with
activity
.
sub_activity
(
with
activity
.
sub_activity
(
...
@@ -908,8 +908,8 @@ class SleepOperation(InstanceOperation):
...
@@ -908,8 +908,8 @@ class SleepOperation(InstanceOperation):
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
return
(
super
(
SleepOperation
.
SuspendVmOperation
,
self
)
return
(
super
(
SleepOperation
.
SuspendVmOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
self
.
instance
.
mem_dump
[
'path'
]])
[
self
.
instance
.
mem_dump
[
'path'
]])
@register_operation
@register_operation
...
@@ -962,8 +962,8 @@ class WakeUpOperation(InstanceOperation):
...
@@ -962,8 +962,8 @@ class WakeUpOperation(InstanceOperation):
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
return
(
super
(
WakeUpOperation
.
WakeUpVmOperation
,
self
)
return
(
super
(
WakeUpOperation
.
WakeUpVmOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
self
.
instance
.
mem_dump
[
'path'
]])
[
self
.
instance
.
mem_dump
[
'path'
]])
@register_operation
@register_operation
...
@@ -1408,9 +1408,9 @@ class PasswordResetOperation(RemoteAgentOperation):
...
@@ -1408,9 +1408,9 @@ class PasswordResetOperation(RemoteAgentOperation):
task
=
agent_tasks
.
change_password
task
=
agent_tasks
.
change_password
required_perms
=
()
required_perms
=
()
def
_get_remote_args
(
self
,
password
,
**
kw
a
rgs
):
def
_get_remote_args
(
self
,
password
,
**
kwrgs
):
return
(
super
(
PasswordResetOperation
,
self
)
.
_get_remote_args
(
**
kw
args
)
return
(
super
(
PasswordResetOperation
,
self
)
.
_get_remote_args
(
**
kw
rgs
)
+
+
[
password
])
[
password
])
def
_operation
(
self
,
password
=
None
):
def
_operation
(
self
,
password
=
None
):
if
not
password
:
if
not
password
:
...
@@ -1433,8 +1433,8 @@ class InstallKeysOperation(RemoteAgentOperation):
...
@@ -1433,8 +1433,8 @@ class InstallKeysOperation(RemoteAgentOperation):
def
_get_remote_args
(
self
,
user
,
keys
=
None
,
**
kwargs
):
def
_get_remote_args
(
self
,
user
,
keys
=
None
,
**
kwargs
):
if
keys
is
None
:
if
keys
is
None
:
keys
=
list
(
user
.
userkey_set
.
values_list
(
'key'
,
flat
=
True
))
keys
=
list
(
user
.
userkey_set
.
values_list
(
'key'
,
flat
=
True
))
return
(
super
(
InstallKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
InstallKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
keys
])
[
keys
])
@register_operation
@register_operation
...
@@ -1446,8 +1446,8 @@ class RemoveKeysOperation(RemoteAgentOperation):
...
@@ -1446,8 +1446,8 @@ class RemoveKeysOperation(RemoteAgentOperation):
required_perms
=
()
required_perms
=
()
def
_get_remote_args
(
self
,
user
,
keys
,
**
kwargs
):
def
_get_remote_args
(
self
,
user
,
keys
,
**
kwargs
):
return
(
super
(
RemoveKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
RemoveKeysOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
keys
])
[
keys
])
@register_operation
@register_operation
...
@@ -1541,8 +1541,8 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1541,8 +1541,8 @@ class AgentStartedOperation(InstanceOperation):
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
cls
=
AgentStartedOperation
.
SetTimeOperation
cls
=
AgentStartedOperation
.
SetTimeOperation
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
time
.
time
()])
[
time
.
time
()])
@register_operation
@register_operation
class
SetHostnameOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
SetHostnameOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
...
@@ -1552,8 +1552,8 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1552,8 +1552,8 @@ class AgentStartedOperation(InstanceOperation):
def
_get_remote_args
(
self
,
**
kwargs
):
def
_get_remote_args
(
self
,
**
kwargs
):
cls
=
AgentStartedOperation
.
SetHostnameOperation
cls
=
AgentStartedOperation
.
SetHostnameOperation
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
self
.
instance
.
short_hostname
])
[
self
.
instance
.
short_hostname
])
@register_operation
@register_operation
class
RestartNetworkingOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
class
RestartNetworkingOperation
(
SubOperationMixin
,
RemoteAgentOperation
):
...
@@ -1572,8 +1572,8 @@ class AgentStartedOperation(InstanceOperation):
...
@@ -1572,8 +1572,8 @@ class AgentStartedOperation(InstanceOperation):
interfaces
=
{
str
(
host
.
mac
):
host
.
get_network_config
()
interfaces
=
{
str
(
host
.
mac
):
host
.
get_network_config
()
for
host
in
hosts
}
for
host
in
hosts
}
cls
=
AgentStartedOperation
.
ChangeIpOperation
cls
=
AgentStartedOperation
.
ChangeIpOperation
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
cls
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
interfaces
,
settings
.
FIREWALL_SETTINGS
[
'rdns_ip'
]])
[
interfaces
,
settings
.
FIREWALL_SETTINGS
[
'rdns_ip'
]])
@register_operation
@register_operation
...
@@ -1697,8 +1697,8 @@ class AbstractDiskOperation(SubOperationMixin, RemoteInstanceOperation):
...
@@ -1697,8 +1697,8 @@ class AbstractDiskOperation(SubOperationMixin, RemoteInstanceOperation):
required_perms
=
()
required_perms
=
()
def
_get_remote_args
(
self
,
disk
,
**
kwargs
):
def
_get_remote_args
(
self
,
disk
,
**
kwargs
):
return
(
super
(
AbstractDiskOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
return
(
super
(
AbstractDiskOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
+
[
disk
.
get_vmdisk_desc
()])
[
disk
.
get_vmdisk_desc
()])
@register_operation
@register_operation
...
...
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