Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a8e2421f
authored
Oct 11, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get public IP's of interfaces on VM resume.
parent
b24c1117
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
6 deletions
+26
-6
netdriver.py
+2
-2
vmdriver.py
+24
-4
No files found.
netdriver.py
View file @
a8e2421f
...
@@ -83,12 +83,12 @@ def create_azure_interface(ifacepk, vlan_name):
...
@@ -83,12 +83,12 @@ def create_azure_interface(ifacepk, vlan_name):
nic_poller
.
wait
()
nic_poller
.
wait
()
nic_id
=
nic_poller
.
result
()
.
id
nic_id
=
nic_poller
.
result
()
.
id
logging
.
info
(
"created network interface with id:
%
s"
%
nic_id
)
logging
.
info
(
"created network interface with id:
%
s"
%
nic_id
)
return
nic_id
return
{
"azure_id"
:
nic_id
,
"public_ip_name"
:
public_ip_name
}
except
Exception
,
e
:
except
Exception
,
e
:
logging
.
error
(
"cloud not create network interface"
)
logging
.
error
(
"cloud not create network interface"
)
logging
.
error
(
str
(
e
))
logging
.
error
(
str
(
e
))
#TODO: should delete public ip (rollback)
#TODO: should delete public ip (rollback)
return
None
return
{
"azure_id"
:
None
,
"public_ip_name"
:
None
}
@celery.task
@celery.task
...
...
vmdriver.py
View file @
a8e2421f
...
@@ -18,6 +18,7 @@ from vmcelery import celery, lib_connection, to_bool
...
@@ -18,6 +18,7 @@ from vmcelery import celery, lib_connection, to_bool
from
azure.common.credentials
import
ServicePrincipalCredentials
from
azure.common.credentials
import
ServicePrincipalCredentials
import
azure.mgmt.compute
import
azure.mgmt.compute
import
azure.mgmt.network
SUBSCRIPTION_ID
=
os
.
getenv
(
'SUBSCRIPTION_ID'
)
SUBSCRIPTION_ID
=
os
.
getenv
(
'SUBSCRIPTION_ID'
)
CLIENT_ID
=
os
.
getenv
(
'CLIENT_ID'
)
CLIENT_ID
=
os
.
getenv
(
'CLIENT_ID'
)
...
@@ -37,6 +38,11 @@ compute_client = azure.mgmt.compute.ComputeManagementClient(
...
@@ -37,6 +38,11 @@ compute_client = azure.mgmt.compute.ComputeManagementClient(
SUBSCRIPTION_ID
SUBSCRIPTION_ID
)
)
network_client
=
azure
.
mgmt
.
network
.
NetworkManagementClient
(
credentials
,
SUBSCRIPTION_ID
)
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
basename
(
__file__
)))
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
basename
(
__file__
)))
vm_xml_dump
=
None
vm_xml_dump
=
None
...
@@ -385,11 +391,25 @@ def restore(name, path):
...
@@ -385,11 +391,25 @@ def restore(name, path):
@celery.task
@celery.task
def
resume
(
name
):
def
resume
(
nics
):
""" Resume stopped virtual machines.
"""
"""
#TODO: implement
Resume stopped virtual machines
return
return public ip of interfaces
"""
nics_with_public_ip
=
[]
for
nic
in
nics
:
try
:
public_ip_address
=
network_client
.
public_ip_addresses
.
get
(
GROUP_NAME
,
nic
[
"public_ip_name"
])
nics_with_public_ip
.
append
({
"id"
:
nic
[
"id"
],
"public_ip"
:
public_ip_address
.
ip_address
,
})
except
:
pass
return
nics_with_public_ip
@celery.task
@celery.task
...
...
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