|
|
@@ -3,8 +3,6 @@ DataTypes used by this provider
|
|
|
"""
|
|
|
import inspect
|
|
|
import json
|
|
|
-import logging
|
|
|
-
|
|
|
|
|
|
from azure.common import AzureException
|
|
|
|
|
|
@@ -23,8 +21,6 @@ from cloudbridge.cloud.providers.azure import helpers as azure_helpers
|
|
|
|
|
|
from msrestazure.azure_exceptions import CloudError
|
|
|
|
|
|
-log = logging.getLogger(__name__)
|
|
|
-
|
|
|
NETWORK_RESOURCE_ID = '/subscriptions/{subscriptionId}/resourceGroups/' \
|
|
|
'{resourceGroupName}/providers/Microsoft.Network/' \
|
|
|
'virtualNetworks/{virtualNetworkName}'
|
|
|
@@ -125,9 +121,6 @@ class AzureSecurityGroup(BaseSecurityGroup):
|
|
|
|
|
|
@property
|
|
|
def rules(self):
|
|
|
- """
|
|
|
- The default rules are not returned, only custom rules.
|
|
|
- """
|
|
|
security_group_rules = []
|
|
|
for custom_rule in self._security_group.security_rules:
|
|
|
sg_custom_rule = AzureSecurityGroupRule(self._provider,
|
|
|
@@ -140,8 +133,7 @@ class AzureSecurityGroup(BaseSecurityGroup):
|
|
|
self._provider.azure_client.\
|
|
|
delete_security_group(self.resource_name)
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
def add_rule(self, ip_protocol=None, from_port=None, to_port=None,
|
|
|
@@ -173,12 +165,9 @@ class AzureSecurityGroup(BaseSecurityGroup):
|
|
|
:return: Rule object if successful or ``None``.
|
|
|
"""
|
|
|
|
|
|
- # If cidr_ip is None, default values is set as 0.0.0.0/0
|
|
|
if not cidr_ip:
|
|
|
cidr_ip = '0.0.0.0/0'
|
|
|
|
|
|
- # If the SG with same parameters exist already,
|
|
|
- # then, it is returned instead of creating a new one.
|
|
|
rule = self.get_rule(ip_protocol, from_port,
|
|
|
to_port, cidr_ip, src_group)
|
|
|
if not rule:
|
|
|
@@ -337,8 +326,7 @@ class AzureBucketObject(BaseBucketObject):
|
|
|
self._provider.azure_client.create_blob_from_text(
|
|
|
self._container.name, self.name, data)
|
|
|
return True
|
|
|
- except AzureException as azureEx:
|
|
|
- log.exception(azureEx)
|
|
|
+ except AzureException:
|
|
|
return False
|
|
|
|
|
|
def upload_from_file(self, path):
|
|
|
@@ -349,8 +337,7 @@ class AzureBucketObject(BaseBucketObject):
|
|
|
self._provider.azure_client.create_blob_from_file(
|
|
|
self._container.name, self.name, path)
|
|
|
return True
|
|
|
- except AzureException as azureEx:
|
|
|
- log.exception(azureEx)
|
|
|
+ except AzureException:
|
|
|
return False
|
|
|
|
|
|
def delete(self):
|
|
|
@@ -364,8 +351,7 @@ class AzureBucketObject(BaseBucketObject):
|
|
|
self._provider.azure_client.delete_blob(
|
|
|
self._container.name, self.name)
|
|
|
return True
|
|
|
- except AzureException as azureEx:
|
|
|
- log.exception(azureEx)
|
|
|
+ except AzureException:
|
|
|
return False
|
|
|
|
|
|
def generate_url(self, expires_in=0):
|
|
|
@@ -399,8 +385,7 @@ class AzureBucket(BaseBucket):
|
|
|
try:
|
|
|
obj = self._provider.azure_client.get_blob(self.name, key)
|
|
|
return AzureBucketObject(self._provider, self, obj)
|
|
|
- except AzureException as azureEx:
|
|
|
- log.exception(azureEx)
|
|
|
+ except AzureException:
|
|
|
return None
|
|
|
|
|
|
def list(self, limit=None, marker=None, prefix=None):
|
|
|
@@ -424,8 +409,7 @@ class AzureBucket(BaseBucket):
|
|
|
try:
|
|
|
self._provider.azure_client.delete_container(self.name)
|
|
|
return True
|
|
|
- except AzureException as azureEx:
|
|
|
- log.exception(azureEx)
|
|
|
+ except AzureException:
|
|
|
return False
|
|
|
|
|
|
def create_object(self, name):
|
|
|
@@ -564,8 +548,7 @@ class AzureVolume(BaseVolume):
|
|
|
self._provider.azure_client \
|
|
|
.create_or_update_vm(params.get(VM_NAME), vm)
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
def detach(self, force=False):
|
|
|
@@ -605,8 +588,7 @@ class AzureVolume(BaseVolume):
|
|
|
self._provider.azure_client. \
|
|
|
delete_disk(self.resource_name)
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
@property
|
|
|
@@ -623,8 +605,7 @@ class AzureVolume(BaseVolume):
|
|
|
self._volume = self._provider.azure_client. \
|
|
|
get_disk(self.resource_name)
|
|
|
self.update_status()
|
|
|
- except (CloudError, ValueError) as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except (CloudError, ValueError):
|
|
|
# The volume no longer exists and cannot be refreshed.
|
|
|
# set the status to unknown
|
|
|
self._status = 'unknown'
|
|
|
@@ -717,8 +698,7 @@ class AzureSnapshot(BaseSnapshot):
|
|
|
self._snapshot = self._provider.azure_client. \
|
|
|
get_snapshot(self.resource_name)
|
|
|
self._status = self._snapshot.provisioning_state
|
|
|
- except (CloudError, ValueError) as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except (CloudError, ValueError):
|
|
|
# The snapshot no longer exists and cannot be refreshed.
|
|
|
# set the status to unknown
|
|
|
self._status = 'unknown'
|
|
|
@@ -730,8 +710,7 @@ class AzureSnapshot(BaseSnapshot):
|
|
|
try:
|
|
|
self._provider.azure_client.delete_snapshot(self.resource_name)
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
def create_volume(self, placement=None,
|
|
|
@@ -844,8 +823,7 @@ class AzureMachineImage(BaseMachineImage):
|
|
|
self._image = self._provider.azure_client\
|
|
|
.get_image(self.resource_name)
|
|
|
self._state = self._image.provisioning_state
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
# image no longer exists
|
|
|
self._state = "unknown"
|
|
|
|
|
|
@@ -912,8 +890,7 @@ class AzureNetwork(BaseNetwork):
|
|
|
self._network = self._provider.azure_client.\
|
|
|
get_network(self.resource_name)
|
|
|
self._state = self._network.provisioning_state
|
|
|
- except (CloudError, ValueError) as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except (CloudError, ValueError):
|
|
|
# The network no longer exists and cannot be refreshed.
|
|
|
# set the status to unknown
|
|
|
self._state = 'unknown'
|
|
|
@@ -930,8 +907,7 @@ class AzureNetwork(BaseNetwork):
|
|
|
self._provider.azure_client.\
|
|
|
delete_network(self.resource_name)
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
def subnets(self):
|
|
|
@@ -1047,8 +1023,7 @@ class AzureSubnet(BaseSubnet):
|
|
|
delete_subnet(self._url_params.get(NETWORK_NAME),
|
|
|
self._url_params.get(SUBNET_NAME))
|
|
|
return True
|
|
|
- except CloudError as cloudError:
|
|
|
- log.exception(cloudError.message)
|
|
|
+ except CloudError:
|
|
|
return False
|
|
|
|
|
|
|
|
|
@@ -1229,10 +1204,6 @@ class AzureInstanceType(BaseInstanceType):
|
|
|
|
|
|
@property
|
|
|
def family(self):
|
|
|
- """
|
|
|
- Python sdk does not return family details.
|
|
|
- So, we are populating it as Unknown
|
|
|
- """
|
|
|
return "Unknown"
|
|
|
|
|
|
@property
|
|
|
@@ -1253,11 +1224,6 @@ class AzureInstanceType(BaseInstanceType):
|
|
|
|
|
|
@property
|
|
|
def num_ephemeral_disks(self):
|
|
|
- """
|
|
|
- Python sdk does not return num_ephemeral_disks details.
|
|
|
- In Azure, we cannot explicitly add ephemeral disks.
|
|
|
- So, we are taking assumption and populating it as Zero.
|
|
|
- """
|
|
|
return 0
|
|
|
|
|
|
@property
|