2014-02-12 74 views
0

我想在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) 

     ............. 
+0

從代碼看,您似乎試圖在單個雲服務中一個接一個地部署多個VM。我對麼? –

+0

是的,當然,但我得到了較高的錯誤,所以我沒有創建它們。那麼是否有任何想法在同一個雲服務中部署多個節點 – aabdulwahed

+0

雲服務中是否已經部署了一個VM? –

回答

2

使用add_role代替create_virtual_machine_deployment(),其中服務名稱是託管服務的名稱和已創建的第一個虛擬機的部署名稱添加新的虛擬機到現有部署在部署臨時插槽角色之後添加2個角色的第一個角色作爲臨時插槽部署角色將新角色添加爲具有臨時部署名稱(第一個角色)的相同名稱的生產部署角色。有關更多信息,請查看test_add_role_linux():https://github.com/WindowsAzure/azure-sdk-for-python/blob/master/tests/test_servicebusmanagementservice.py

+0

我剛剛測試了add_role()以將虛擬機添加到現有的雲服務/部署,並且它可以工作。 – ab77

+0

是的,那是我在說的,如果你想添加一個新的虛擬機到相同的雲服務,你必須使用add_role()而不是create_virtual_machine_deployment(),它的工作原理,但我忘了修改帖子 – aabdulwahed

相關問題