def remove_instance(self, id): from novaclient.v1_1 import client # nova client v3 raises exception for this nova = client.Client(self.__os_username,self.__os_password,"admin",self.__os_auth_url) sm = ServerManager(nova) instancia = sm.get(id) sm.delete(instancia) return True
def create_snapshot(self, instance_id): from novaclient.v1_1 import client # nova client v3 raises exception for this nova = client.Client(self.__os_username,self.__os_password,self.__os_tenant_admin, self.__os_auth_url) server_manager = ServerManager(nova) instance_obj = server_manager.get(instance_id) snapshot_name = 'snapshot--%s--%s' % (instance_obj.name, datetime.datetime.now()) print snapshot_name nova.servers.create_image(instance_id, snapshot_name)
def vm_hostname(self,project_name,instance_id): nova = client.Client(env.OS_USERNAME, env.OS_PASSWORD, project_name, env.OS_AUTH_URL) server = ServerManager(nova) return server.get(instance_id)
def remove_instance(self, id): nova = client.Client(env.OS_USERNAME,env.OS_PASSWORD,"admin",env.OS_AUTH_URL) sm = ServerManager(nova) instancia = sm.get(id) sm.delete(instancia) return True