Added base Azure backend#105
Conversation
546f981 to
5db80a5
Compare
stefan-caraiman
left a comment
There was a problem hiding this comment.
Besides pep8 issues and a few suggestions, the patch looks alright.
| help="The subscription id for the Azure account" | ||
| "used for tests."), | ||
| cfg.StrOpt( | ||
| "username", default=None, |
There was a problem hiding this comment.
This line can fit on the one above.
| }] | ||
| },} | ||
|
|
||
| @util.retry_on_error(max_attempts=20, sleep_seconds=5) |
There was a problem hiding this comment.
Shouldn't we use CONF values regarding the retry count
|
|
||
| @util.retry_on_error(max_attempts=20, sleep_seconds=5) | ||
| def get_floating_ip(self): | ||
| floating_ip = self._network_client.public_ip_addresses.get(self._resource_group_name, self._vip_name).ip_address |
| self._resource_group_name, self._sec_group_name, {'location':self._availability_zone}) | ||
| secgroup_info = async_secgroup_creation.result() | ||
|
|
||
| self._network_client.security_rules.create_or_update(self._resource_group_name, self._sec_group_name, 'secgr1', {'access':'allow', 'protocol':'Tcp', 'direction':'inbound', 'source_address_prefix':'*','destination_address_prefix':'*', 'source_port_range':'*', 'destination_port_range':'3389', 'priority':100}).wait() |
There was a problem hiding this comment.
We can use a for loop and only change the required values from the dict instead of repeating these code blocks, also not pep8 compliant
|
|
||
| def create_nic(self): | ||
| """Create a Network Interface for a VM. | ||
| """ |
| from azure.mgmt.compute import ComputeManagementClient | ||
| from azure.storage import CloudStorageAccount | ||
|
|
||
| VM_REFERENCE = { |
| return { 'image': {'OS-EXT-IMG-SIZE:size': 50000}} | ||
|
|
||
| def get_mtu(self): | ||
| return 1450 |
There was a problem hiding this comment.
Isn't there already a function used for getting the mtu size?
|
|
||
| def get_image_by_ref(self): | ||
| """Get the image object by its reference id.""" | ||
| return { 'image': {'OS-EXT-IMG-SIZE:size': 50000}} |
There was a problem hiding this comment.
Will all images be 50000 in size? or is there another reason for this
| status = execute_function( | ||
| 'Test-Path "{}\\Cloudbase` Solutions"'.format( | ||
| _location), command_type=util.POWERSHELL).strip().lower() | ||
|
|
There was a problem hiding this comment.
No need to remove this line, since there are separated logic code blocks.
|
|
||
| def _create_vm_parameters(self, vm_name, vm_username, vm_password, os_disk_name, nic_id, vm_reference): | ||
| """Create the VM parameters structure. | ||
| """ |
1e57378 to
0da0377
Compare
Adds support for Argus testing on Azure cloud. This commit adds an Azure backend, an Azure recipe and a scenario (ScenarioAzure) that verifies that no errors are found in the cloudbase-init logs.
0da0377 to
d7e5153
Compare
|
|
||
| CONFIG = argus_config.CONFIG | ||
|
|
||
| RETRY_COUNT = 50 |
There was a problem hiding this comment.
Wouldn't it be better to have these as configurable options in default? Also I don't find these variables being used anywhere
| self._creds, subscription_id) | ||
| self._vm_client = ComputeManagementClient( | ||
| self._creds, subscription_id) | ||
| self.net_client = NetworkManagementClient( |
| self.vm_password = vm_password | ||
| self._creds = UserPassCredentials(username, password) | ||
| self.res_client = ResourceManagementClient( | ||
| self._creds, subscription_id) |
There was a problem hiding this comment.
Just a suggestion, couldn't we save this to a variable since we are using it to initialize other objects too?
|
|
||
| @staticmethod | ||
| def _get_random_id(): | ||
| return str(random.randint(0, 10000)) |
There was a problem hiding this comment.
We already have a method for generating random names in util, util.rand_name.
| storage_account_name, availability_zone, image_vhd_path, | ||
| vm_username, vm_password) | ||
|
|
||
| self.vm_name = "argusvm-" + AzureClient._get_random_id() |
There was a problem hiding this comment.
We could use util.rand_name, also we could save this to a variable instead of calling _get_random_id each time.
| self._vm_client.virtual_machines.start( | ||
| self._resource_group_name, self.vm_name) | ||
|
|
||
| def destroy_vm(self): |
| def _get_random_id(): | ||
| return str(random.randint(0, 10000)) | ||
|
|
||
| def create_vm(self): |
No description provided.