def __setup_virtual_machine_without_deployment_existed(self, sctx): ctx = sctx.job_ctxs[sctx.current_job_index] adapter = VirtualMachineAdapter(ctx.subscription_id, ctx.pem_url, host=ctx.management_host) if not ctx.is_vm_image: network_config = get_network_config( ctx.raw_network_config, adapter.get_assigned_endpoints(ctx.cloud_service_name)) else: network_config = None try: req = adapter.create_virtual_machine_deployment( ctx.cloud_service_name, ctx.deployment_name, ctx.deployment_slot, ctx.virtual_machine_label, ctx.virtual_machine_name, ctx.system_config, ctx.os_virtual_hard_disk, network_config, role_size=ctx.virtual_machine_size, vm_image_name=ctx.image_name if ctx.is_vm_image else None) except Exception as e: self.log.error( "azure virtual environment %d create virtual machine %r failed: %r" % (sctx.current_job_index, ctx.virtual_machine_name, str(e))) self.__on_setup_failed(sctx) return # wait for add virtual machine to finish ctx.request_id = req.request_id ctx.vm_need_config = True if ctx.is_vm_image else False self.__wait_for_create_virtual_machine_deployment(sctx)