Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e70e0f22
authored
Oct 11, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update public IP's of NICs on resume, show public ip of NIC on
dashboard
parent
654dbc54
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
91 additions
and
37 deletions
+91
-37
circle/vm/migrations/0010_instance_public_ip.py
+19
-0
circle/vm/migrations/0011_interface_public_ip_name.py
+19
-0
circle/vm/migrations/0012_auto_20161011_1414.py
+23
-0
circle/vm/models/instance.py
+5
-11
circle/vm/models/network.py
+8
-4
circle/vm/operations.py
+17
-22
No files found.
circle/vm/migrations/0010_instance_public_ip.py
0 → 100644
View file @
e70e0f22
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0009_auto_20161011_1328'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'instance'
,
name
=
'public_ip'
,
field
=
models
.
TextField
(
blank
=
True
),
),
]
circle/vm/migrations/0011_interface_public_ip_name.py
0 → 100644
View file @
e70e0f22
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0010_instance_public_ip'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'interface'
,
name
=
'public_ip_name'
,
field
=
models
.
TextField
(
null
=
True
),
),
]
circle/vm/migrations/0012_auto_20161011_1414.py
0 → 100644
View file @
e70e0f22
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0011_interface_public_ip_name'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'instance'
,
name
=
'public_ip'
,
),
migrations
.
AddField
(
model_name
=
'interface'
,
name
=
'public_ip'
,
field
=
models
.
TextField
(
blank
=
True
),
),
]
circle/vm/models/instance.py
View file @
e70e0f22
...
...
@@ -560,21 +560,15 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
def
get_connect_port
(
self
,
use_ipv6
=
False
):
"""Get public port number for default access method.
"""
port
,
proto
=
ACCESS_PROTOCOLS
[
self
.
access_method
][
1
:
3
]
if
self
.
primary_host
:
endpoints
=
self
.
primary_host
.
get_public_endpoints
(
port
,
proto
)
endpoint
=
endpoints
[
'ipv6'
]
if
use_ipv6
else
endpoints
[
'ipv4'
]
return
endpoint
[
1
]
if
endpoint
else
None
else
:
return
None
return
"22"
def
get_connect_host
(
self
,
use_ipv6
=
False
):
"""Get public hostname.
"""
if
not
self
.
primary_host
:
return
None
proto
=
'ipv6'
if
use_ipv6
else
'ipv4'
return
self
.
primary_host
.
get_hostname
(
proto
=
proto
)
for
i
in
self
.
interface_set
.
all
()
:
if
i
.
public_ip
!=
""
:
return
i
.
public_ip
return
None
def
get_connect_command
(
self
,
use_ipv6
=
False
):
"""Returns a formatted connect string.
...
...
circle/vm/models/network.py
View file @
e70e0f22
...
...
@@ -73,6 +73,8 @@ class Interface(Model):
related_name
=
'interface_set'
)
model
=
CharField
(
max_length
=
10
,
choices
=
MODEL_TYPES
,
default
=
'virtio'
)
azure_id
=
TextField
(
null
=
True
)
public_ip_name
=
TextField
(
null
=
True
)
public_ip
=
TextField
(
blank
=
True
)
class
Meta
:
app_label
=
'vm'
...
...
@@ -166,13 +168,15 @@ class Interface(Model):
iface
.
save
()
logger
.
debug
(
"sending task to create azure interface"
)
azure_id
=
net_tasks
.
create_azure_interface
.
apply_async
(
result
=
net_tasks
.
create_azure_interface
.
apply_async
(
args
=
[
iface
.
pk
,
vlan
.
name
],
queue
=
"localhost.net.fast"
)
.
get
()
if
azure_id
:
logger
.
debug
(
"created azure interface with id:
%
s"
%
azure_id
)
iface
.
azure_id
=
azure_id
if
result
[
"azure_id"
]:
logger
.
debug
(
"created azure interface with id:
%
s"
%
(
result
[
"azure_id"
]))
iface
.
azure_id
=
result
[
"azure_id"
]
iface
.
public_ip_name
=
result
[
"public_ip_name"
]
iface
.
save
()
return
iface
...
...
circle/vm/operations.py
View file @
e70e0f22
...
...
@@ -369,7 +369,7 @@ class DeployOperation(InstanceOperation):
self
.
instance
.
STATUS
.
ERROR
)
def
on_abort
(
self
,
activity
,
error
):
activity
.
resultant_state
=
'
STOPPED
'
activity
.
resultant_state
=
'
PENDING
'
def
on_commit
(
self
,
activity
):
activity
.
resultant_state
=
'RUNNING'
...
...
@@ -432,30 +432,25 @@ class DeployOperation(InstanceOperation):
self
.
instance
.
name
))
@register_operation
class
DeployDisksOperation
(
SubOperationMixin
,
InstanceOperation
):
id
=
"_deploy_disks"
name
=
_
(
"deploy disks"
)
description
=
_
(
"Deploy all associated disks."
)
def
_operation
(
self
):
devnums
=
list
(
ascii_lowercase
)
# a-z
for
disk
in
self
.
instance
.
disks
.
all
():
# assign device numbers
if
disk
.
dev_num
in
devnums
:
devnums
.
remove
(
disk
.
dev_num
)
else
:
disk
.
dev_num
=
devnums
.
pop
(
0
)
disk
.
save
()
# deploy disk
disk
.
deploy
()
@register_operation
class
ResumeVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
class
ResumeVmOperation
(
SubOperationMixin
,
InstanceOperation
):
id
=
"_resume_vm"
name
=
_
(
"boot virtual machine"
)
remote_queue
=
(
"vm"
,
"slow"
)
task
=
vm_tasks
.
resume
def
_operation
(
self
):
#TODO: implement resume functionality too
nics
=
[{
"id"
:
nic
.
id
,
"public_ip_name"
:
nic
.
public_ip_name
,
}
for
nic
in
self
.
instance
.
interface_set
.
all
()]
result
=
vm_tasks
.
resume
.
apply_async
(
args
=
[
nics
],
queue
=
"localhost.vm.fast"
)
.
get
(
timeout
=
1200
)
for
nic
in
result
:
nic_obj
=
Interface
.
objects
.
get
(
pk
=
nic
[
"id"
])
nic_obj
.
public_ip
=
nic
[
"public_ip"
]
nic_obj
.
save
()
@register_operation
class
DestroyOperation
(
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