Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
806ecf3e
authored
Mar 12, 2018
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
initial implementation of add interface operation
parent
ba26b3e5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
12 deletions
+14
-12
.idea/workspace.xml
+0
-0
circle/dashboard/forms.py
+2
-2
circle/dashboard/views/vm.py
+7
-7
circle/openstack_api/nova.py
+3
-0
circle/vm/operations.py
+2
-3
No files found.
.idea/workspace.xml
View file @
806ecf3e
This diff is collapsed.
Click to expand it.
circle/dashboard/forms.py
View file @
806ecf3e
...
...
@@ -997,8 +997,8 @@ class VmAddInterfaceForm(OperationForm):
choices
=
kwargs
.
pop
(
'choices'
)
super
(
VmAddInterfaceForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
field
=
forms
.
Model
ChoiceField
(
queryset
=
choices
,
required
=
False
,
field
=
forms
.
ChoiceField
(
choices
=
choices
,
required
=
False
,
label
=
self
.
label
)
if
not
choices
:
field
.
widget
.
attrs
[
'disabled'
]
=
'disabled'
...
...
circle/dashboard/views/vm.py
View file @
806ecf3e
...
...
@@ -350,13 +350,13 @@ class VmAddInterfaceView(FormOperationMixin, VmOperationView):
with_reload
=
True
def
get_form_kwargs
(
self
):
inst
=
self
.
get_op
()
.
instance
choices
=
Vlan
.
get_objects_with_level
(
"user"
,
self
.
request
.
user
)
.
exclude
(
vm_interface__instance__in
=
[
inst
])
val
=
super
(
VmAddInterfaceView
,
self
)
.
get_form_kwargs
()
val
.
update
({
'choices'
:
choices
})
return
val
context
=
super
(
VmAddInterfaceView
,
self
)
.
get_form_kwargs
()
networks
=
openstack_api
.
neutron
.
network_list_for_tenant
(
self
.
request
,
self
.
request
.
user
.
tenant_id
)
choices
=
((
n
.
id
,
n
.
name
)
for
n
in
networks
)
context
.
update
({
'choices'
:
choices
})
return
context
#
# class VmDiskModifyView(FormOperationMixin, VmOperationView):
...
...
circle/openstack_api/nova.py
View file @
806ecf3e
...
...
@@ -159,6 +159,9 @@ class Server(base.APIResourceWrapper):
def
host_server
(
self
):
return
getattr
(
self
,
'OS-EXT-SRV-ATTR:host'
,
''
)
def
__repr__
(
self
):
return
self
.
name
class
Hypervisor
(
base
.
APIDictWrapper
):
"""Simple wrapper around novaclient.hypervisors.Hypervisor."""
...
...
circle/vm/operations.py
View file @
806ecf3e
...
...
@@ -186,9 +186,8 @@ class AddInterfaceOperation(InstanceOperation):
accept_states
=
(
'SHUTOFF'
,
'ACTIVE'
)
#TODO: try other states
os_policy_actions
=
((
"compute"
,
"compute:attach_interface"
),)
def
_operation
(
self
,
activity
,
user
,
system
,
vlan
,
managed
=
None
):
print
(
"Adding interface"
)
def
_operation
(
self
,
request
,
user
,
system
,
vlan
,
managed
=
None
):
openstack_api
.
nova
.
interface_attach
(
request
,
self
.
instance
,
net_id
=
vlan
)
@register_operation
class
CreateDiskOperation
(
InstanceOperation
):
...
...
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