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
13928bea
authored
Oct 10, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement create_azure_interface task.
parent
1562b83b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
2 deletions
+129
-2
netdriver.py
+82
-0
requirements/base.txt
+47
-2
No files found.
netdriver.py
View file @
13928bea
...
...
@@ -8,6 +8,88 @@ from vm import VMNetwork
from
vmcelery
import
native_ovs
driver
=
getenv
(
"HYPERVISOR_TYPE"
,
"test"
)
from
azure.common.credentials
import
ServicePrincipalCredentials
import
azure.mgmt.network
SUBSCRIPTION_ID
=
getenv
(
'SUBSCRIPTION_ID'
)
CLIENT_ID
=
getenv
(
'CLIENT_ID'
)
SECRET
=
getenv
(
'SECRET'
)
TENANT
=
getenv
(
'TENANT'
)
GROUP_NAME
=
getenv
(
'GROUP_NAME'
)
REGION
=
getenv
(
'REGION'
)
credentials
=
ServicePrincipalCredentials
(
client_id
=
CLIENT_ID
,
secret
=
SECRET
,
tenant
=
TENANT
,
)
network_client
=
azure
.
mgmt
.
network
.
NetworkManagementClient
(
credentials
,
SUBSCRIPTION_ID
)
@celery.task
def
create_azure_interface
(
ifacepk
,
vlan_name
):
""" Create azure network interface """
public_ip_name
=
"pip_
%
d"
%
ifacepk
network_interface_name
=
"nic_
%
d"
%
ifacepk
subnet
=
network_client
.
subnets
.
get
(
GROUP_NAME
,
vlan_name
,
"
%
s.subnet"
%
vlan_name
)
# create public ip #TODO: should be optional
pub_ip_poller
=
network_client
.
public_ip_addresses
.
create_or_update
(
GROUP_NAME
,
public_ip_name
,
azure
.
mgmt
.
network
.
models
.
PublicIPAddress
(
location
=
REGION
,
public_ip_allocation_method
=
\
azure
.
mgmt
.
network
.
models
.
IPAllocationMethod
.
dynamic
,
idle_timeout_in_minutes
=
4
,
),
)
try
:
pub_ip_poller
.
wait
()
public_ip_id
=
pub_ip_poller
.
result
()
.
id
logging
.
info
(
"created public ip with id:
%
s"
%
public_ip_id
)
except
Exception
,
e
:
logging
.
error
(
"cloud not create public ip"
)
logging
.
error
(
str
(
e
))
return
None
# create nic
nic_poller
=
network_client
.
network_interfaces
.
create_or_update
(
GROUP_NAME
,
network_interface_name
,
azure
.
mgmt
.
network
.
models
.
NetworkInterface
(
location
=
REGION
,
ip_configurations
=
[
azure
.
mgmt
.
network
.
models
.
NetworkInterfaceIPConfiguration
(
name
=
'default'
,
private_ip_allocation_method
=
\
azure
.
mgmt
.
network
.
models
.
IPAllocationMethod
.
dynamic
,
subnet
=
subnet
,
public_ip_address
=
azure
.
mgmt
.
network
.
models
.
PublicIPAddress
(
id
=
public_ip_id
,
),
),
],
),
)
try
:
nic_poller
.
wait
()
nic_id
=
nic_poller
.
result
()
.
id
logging
.
info
(
"created network interface with id:
%
s"
%
nic_id
)
return
nic_id
except
Exception
,
e
:
logging
.
error
(
"cloud not create network interface"
)
logging
.
error
(
str
(
e
))
#TODO: should delete public ip (rollback)
return
None
@celery.task
def
create
(
network
):
...
...
requirements/base.txt
View file @
13928bea
GitPython==0.3.6
Pillow==2.3.0
amqp==1.4.9
anyjson==0.3.3
azure==2.0.0rc6
azure-batch==1.0.0
azure-common==1.1.4
azure-mgmt==0.30.0rc6
azure-mgmt-batch==1.0.0
azure-mgmt-compute==0.30.0rc6
azure-mgmt-keyvault==0.30.0rc6
azure-mgmt-logic==1.0.0
azure-mgmt-network==0.30.0rc6
azure-mgmt-nspkg==1.0.0
azure-mgmt-redis==1.0.0
azure-mgmt-resource==0.30.0rc6
azure-mgmt-scheduler==1.0.0
azure-mgmt-storage==0.30.0rc6
azure-nspkg==1.0.0
azure-servicebus==0.20.3
azure-servicemanagement-legacy==0.20.4
azure-storage==0.33.0
billiard==3.3.0.23
celery==3.1.17
certifi==2016.9.26
cffi==1.8.3
chardet==2.3.0
cryptography==1.5.2
decorator==3.4.0
enum34==1.1.6
futures==3.0.5
gitdb==0.6.4
idna==2.1
ipaddress==1.0.17
isodate==0.5.4
keyring==9.3.1
kombu==3.0.35
lxml==3.4.2
msrest==0.4.4
msrestazure==0.4.3
oauthlib==2.0.0
psutil==1.1.3
Pillow==2.3.0
GitPython==0.3.6
pyasn1==0.1.9
pycparser==2.14
python-dateutil==2.5.3
pytz==2016.6.1
requests==2.11.1
requests-oauthlib==0.7.0
six==1.10.0
smmap==0.9.0
wsgiref==0.1.2
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