gpt4 book ai didi

python - 如何在azure上的同一云服务中部署多台机器

转载 作者:太空宇宙 更新时间:2023-11-04 09:40:49 27 4
gpt4 key购买 nike

我尝试使用 Python API 在 Windows Azure 上部署多个 Linux 虚拟机,但部署它们时出现错误。当我为单个虚拟机创建单个云服务但不适用于多个节点时,以下代码:

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 "+"ehpcuser@"+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)

WindowsAzure冲突错误

谁能帮我解决这个问题

谢谢!!

最佳答案

使用 add_role 而不是 create_virtual_machine_deployment() 将新虚拟机添加到现有部署,其中服务名称是已创建的第一个虚拟机的托管服务名称和部署名称:

       .........
..........
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)

.............

关于python - 如何在azure上的同一云服务中部署多台机器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21731133/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com