Quantcast
Channel: Azure Virtual Machines forum
Viewing all articles
Browse latest Browse all 12545

How to add a new role to an exist deployment "multiple machines under the same cloud service" using python API of azure?

$
0
0

I tried to add a new role to an existing deployment on the same cloud service of the 1st virtual machine but the add_role() method did not create any new VM to the existing deployment. the following is a sample of my python code to create the new roles.

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
                        print "*"*40+":"+vname
                        print "*"*40+":"+str(result_cert)
                        #def create_deployment(self, service_name, deployment_slot, name, package_url, label, configuration, start_deployment=False, treat_warnings_as_error=False, extended_properties=None):
                        #deployment_name = sms.create_deployment(service_name=Service_name,
                        #                                       deployment_slot = 'production',
                        #                                       name = vname,
                        #                                       package_url=result_cert,
                        #                                       label= vname)
                        #def add_role(self, service_name, deployment_name, role_name, system_config, os_virtual_hard_disk, network_config=None, availability_set_name=None, data_virtual_hard_disks=None, role_size=None, role_type='PersistentVMRole'):
                        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)
                        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")
and no virtual machines have been created !!!



Viewing all articles
Browse latest Browse all 12545

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>