Use client to create vms and set ssh key correct
This commit is contained in:
		
					parent
					
						
							
								7a5555fe99
							
						
					
				
			
			
				commit
				
					
						fb8dac7d00
					
				
			
		
					 1 changed files with 13 additions and 4 deletions
				
			
		|  | @ -196,12 +196,15 @@ class OpenNebulaManager(): | ||||||
|                         """.format(size=1024 * int(specs['disk_size']), |                         """.format(size=1024 * int(specs['disk_size']), | ||||||
|                                    image=image, |                                    image=image, | ||||||
|                                    image_uname=image_uname) |                                    image_uname=image_uname) | ||||||
|         vm_id = template.instantiate(name ='', |         vm_id = self.client.call(oca.VmTemplate.METHODS['instantiate'], | ||||||
|                                     pending=False, |                 template.id, | ||||||
|                                     extra_template=vm_specs,                                    ) |                 '', | ||||||
|  |                 True,                 | ||||||
|  |                 vm_specs, | ||||||
|  |                 False) | ||||||
| 
 | 
 | ||||||
|         self.oneadmin_client.call( |         self.oneadmin_client.call( | ||||||
|             'vm.updateconf', |             'vm.update', | ||||||
|             vm_id, |             vm_id, | ||||||
|             """<CONTEXT> |             """<CONTEXT> | ||||||
|                 <SSH_PUBLIC_KEY>{ssh}</SSH_PUBLIC_KEY> |                 <SSH_PUBLIC_KEY>{ssh}</SSH_PUBLIC_KEY> | ||||||
|  | @ -217,6 +220,12 @@ class OpenNebulaManager(): | ||||||
|             ) |             ) | ||||||
|         except AttributeError: |         except AttributeError: | ||||||
|             logger.info('Could not change owner for vm with id: {}.'.format(vm_id)) |             logger.info('Could not change owner for vm with id: {}.'.format(vm_id)) | ||||||
|  |          | ||||||
|  |         self.oneadmin_client.call( | ||||||
|  |                 oca.VirtualMachine.METHODS['action'], | ||||||
|  |                 'release', | ||||||
|  |                 vm_id | ||||||
|  |                 ) | ||||||
|         return vm_id |         return vm_id | ||||||
| 
 | 
 | ||||||
|     def delete_vm(self, vm_id): |     def delete_vm(self, vm_id): | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue