我想在Windows Azure上使用Python API部署多臺Linux虛擬機,但我有一個錯誤來部署它們。當我創建以下代碼爲單個虛擬機的單一的雲服務,但多個節點沒有工作:如何在Azure上的相同雲服務中部署多臺機器
def createMachine(self,vmname,num,sms,region,affGrp,medialink,imageID,cert_data,cert_format,cert_password,linux_config,os_hd,endpoint_config,instanceSize,Service_name):
exitF = 0
if exitF:
thread.exit()
else:
endpoint3 = ConfigurationSetInputEndpoint(name='SSH'+str(num), protocol='tcp', port='220'+str(num), local_port='22', load_balanced_endpoint_set_name=None, enable_direct_server_return=False)
endpoint_config.input_endpoints.input_endpoints.append(endpoint3)
media_link = ""
name = vmname+str(num+1)
vname = vmname+str(num+1)
#Service_url = self.newCloudService(sms,vname,name,name,region,affGrp)
#Service_name = vname
media_link = medialink+name+".vhd"
self.logger.info("Configuring Media Link "+media_link+".......... Ok")
# Configuring Image ID:
#----------------------
os_hd = OSVirtualHardDisk(imageID, media_link)
self.logger.info("Configuring The Virtual Hard Disk using Image ID:"+imageID+".......... Ok")
self.logger.info("Deploying Node number:"+str(num)+".......... Ok")
result_cert = sms.add_service_certificate(service_name=Service_name,
data=cert_data,
certificate_format=cert_format,
password=cert_password)
self.logger.info("Start Deploying VM with Name: "+vname)
try:
self.logger.info(vars(result_cert))
except:
self.logger.info("Error: Can not configure the certifications")
time.sleep(5)
print "*"*40+":"+Service_name
result = sms.create_virtual_machine_deployment(service_name=Service_name,
deployment_name=vname,
deployment_slot='production',
label=vname,
role_name=vname,
system_config=linux_config,
os_virtual_hard_disk=os_hd,
network_config=endpoint_config,
role_size=instanceSize)
operation_result = sms.get_operation_status(result.request_id)
self.logger.info("Start Deployment.......... Ok")
self.logger.info("ssh -i keys/mycert.pem "+"[email protected]"+Service_name+".cloudapp.net")
#self.instances.append(Service_name+".cloudapp.net")
exitF = 1
return (Service_name+".cloudapp.net")
和錯誤是:
self.instance = self.azureclient.createMachine(self.vmname,self.num,self.sms,self.region,self.affGrp,self.medialink,self.imageID,self.cert_data,self.cert_format,self.cert_password,self.linux_config,self.os_hd,self.endpoint_config,self.instanceSize,self.Service_name)
File "/home/ehpcuser/ehpcazure/azurehpc.py", line 283, in createMachine
role_size=instanceSize)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementservice.py", line 913, in create_virtual_machine_deployment
async=True)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementclient.py", line 119, in _perform_post
response = self._perform_request(request)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/servicemanagementclient.py", line 78, in _perform_request
return _management_error_handler(e)
File "/home/ehpcuser/ehpcazure/azure/servicemanagement/__init__.py", line 697, in _management_error_handler
return _general_error_handler(http_error)
File "/home/ehpcuser/ehpcazure/azure/__init__.py", line 644, in _general_error_handler
raise WindowsAzureConflictError(_ERROR_CONFLICT)
WindowsAzureConflictError
誰能幫助我解決這個問題
謝謝!!
.........
..........
result = sms.add_role(service_name=Service_name,
deployment_name=Service_name,
role_name=vname,
system_config=linux_config,
os_virtual_hard_disk=os_hd,
network_config=endpoint_config,
role_size=instanceSize)
.............
從代碼看,您似乎試圖在單個雲服務中一個接一個地部署多個VM。我對麼? –
是的,當然,但我得到了較高的錯誤,所以我沒有創建它們。那麼是否有任何想法在同一個雲服務中部署多個節點 – aabdulwahed
雲服務中是否已經部署了一個VM? –