from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.compute.models import DiskCreateOption
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.compute.models import DiskCreateOption
-from msrestazure.azure_exceptions import CloudError
+from cryptography.hazmat.backends import default_backend as crypto_default_backend
+from cryptography.hazmat.primitives import serialization as crypto_serialization
+from cryptography.hazmat.primitives.asymmetric import rsa
__author__ = "Isabel Lloret, Sergio Gonzalez, Alfonso Tierno, Gerardo Garcia"
__date__ = "$18-apr-2019 23:59:59$"
__author__ = "Isabel Lloret, Sergio Gonzalez, Alfonso Tierno, Gerardo Garcia"
__date__ = "$18-apr-2019 23:59:59$"
# TODO - not used, do anything about it?
# public ssh key
self.pub_key = config.get("pub_key")
# TODO - not used, do anything about it?
# public ssh key
self.pub_key = config.get("pub_key")
self.logger.debug("create base vnet: %s", self.vnet_name)
self.conn_vnet.virtual_networks.begin_create_or_update(
self.logger.debug("create base vnet: %s", self.vnet_name)
self.conn_vnet.virtual_networks.begin_create_or_update(
self.logger.debug("creating subnet_name: {}".format(subnet_name))
async_creation = self.conn_vnet.subnets.begin_create_or_update(
self.logger.debug("creating subnet_name: {}".format(subnet_name))
async_creation = self.conn_vnet.subnets.begin_create_or_update(
Adds a prefix to the subnet_name with a number in case the indicated name is repeated
Checks subnets with the indicated name (without suffix) and adds a suffix with a number
"""
Adds a prefix to the subnet_name with a number in case the indicated name is repeated
Checks subnets with the indicated name (without suffix) and adds a suffix with a number
"""
# Filter to subnets starting with the indicated name
subnets = list(
filter(lambda subnet: (subnet.name.startswith(subnet_name)), all_subnets)
# Filter to subnets starting with the indicated name
subnets = list(
filter(lambda subnet: (subnet.name.startswith(subnet_name)), all_subnets)
- def _create_nic(self, net, nic_name, static_ip=None, created_items={}):
+ def _create_nic(self, net, nic_name, region=None, static_ip=None, created_items={}):
self.logger.debug("create nic name %s, net_name %s", nic_name, net)
self._reload_connection()
subnet_id = net["net_id"]
self.logger.debug("create nic name %s, net_name %s", nic_name, net)
self._reload_connection()
subnet_id = net["net_id"]
# subnet_id=net["net_id"]
nic_name = vm_name + "-nic-" + str(idx)
vm_nic, nic_items = self._create_nic(
# subnet_id=net["net_id"]
nic_name = vm_name + "-nic-" + str(idx)
vm_nic, nic_items = self._create_nic(
- net, nic_name, net.get("ip_address"), created_items
+ net, nic_name, self.region, net.get("ip_address"), created_items
# Subnet API fails (CloudError: Azure Error: ResourceNotFound)
# Put the initial virtual_network API
async_delete = self.conn_vnet.subnets.begin_delete(
# Subnet API fails (CloudError: Azure Error: ResourceNotFound)
# Put the initial virtual_network API
async_delete = self.conn_vnet.subnets.begin_delete(
netName = self._get_net_name_from_resource_id(net_id)
resName = self._get_resource_name_from_resource_id(net_id)
netName = self._get_net_name_from_resource_id(net_id)
resName = self._get_resource_name_from_resource_id(net_id)
- net = self.conn_vnet.subnets.get(self.resource_group, netName, resName)
+ net = self.conn_vnet.subnets.get(
+ self.vnet_resource_group or self.resource_group, netName, resName
+ )
logger.debug("List networks")
network_list = azure.get_network_list({"name": "internal"})
logger.debug("Network_list: {}".format(network_list))
logger.debug("List networks")
network_list = azure.get_network_list({"name": "internal"})
logger.debug("Network_list: {}".format(network_list))
logger.debug("Show machine isabelvm")
vmachine = azure.get_vminstance( ("/subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}"
"/providers/Microsoft.Compute/virtualMachines/isabelVM"
logger.debug("Show machine isabelvm")
vmachine = azure.get_vminstance( ("/subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}"
"/providers/Microsoft.Compute/virtualMachines/isabelVM"
network_id = ("subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}
"/providers/Microsoft.Network/virtualNetworks/osm_vnet/subnets/internal"
).format(test_params["resource_group"])
network_id = ("subscriptions/5c1a2458-dfde-4adf-a4e3-08fa0e21d171/resourceGroups/{}
"/providers/Microsoft.Network/virtualNetworks/osm_vnet/subnets/internal"
).format(test_params["resource_group"])