Re: [Users] How to import existing libvirt management KVM virtual machine to the ovirt
On 03/12/2013 10:19 AM, xianghuadu wrote: hi all How to import existing libvirt management KVM virtual machine to the ovirt virt-v2v should be a tool what you want, please refer to this link http://linux.web.cern.ch/linux/scientific6/docs/rhel/V2V_Guide/#chap-V2V-VMS_To_Run_on_RHEV, note that it's a little different between RHEV and ovirt, for details, please also refer to http://www.ovirt.org/Quick_Start_Guide, in addition, if you are also familiar with REST-API then you may use virt-v2v tool and REST-API to do the same thing, for details, please see https://github.com/autotest/autotest/pull/432. Good Luck! Alex xianghuadu ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] How to approve the host to custom cluster instead the default cluster
Hi Mohua, The following link should be helpful for you(see add() of the class HostManager): https://github.com/chuanchang/autotest/commit/1a59defaf1987d197d90b3e21bc518c78bfb4823 -- Regards, Alex - Original Message - From: Mohua Li m...@redhat.com To: users@ovirt.org Sent: Tuesday, December 11, 2012 3:22:43 PM Subject: [Users] How to approve the host to custom cluster instead the default cluster Hi all, In admin portal, when try to approve a host, need to select the cluster first, but with rest api, /*code*/ try: api = API(url=HOST, username=USER, password=PASS, ca_file=ca.crt) h = api.hosts.get(name=Atlantic) if(h.approve()): print Host '%s' approved (Status: %s). % (h.get_name(), h.get_status().get_state()) else: print Approval of '%s' failed. % h.get_name() api.disconnect() except Exception as ex: print Unexpected error: %s % ex above code will register to the default cluster, could you give me an example how to register to the custom cluster instead the default? or i misunderstand some workflow, light me pls, thanks Regards, Mohua Li ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] [V2V] import errors
- Original Message - From: Andres Gonzalez tuc...@gmail.com To: Alex Jia a...@redhat.com Cc: users@ovirt.org Sent: Saturday, August 25, 2012 1:37:10 AM Subject: Re: [Users] [V2V] import errors On Fri, Aug 24, 2012 at 4:52 AM, Alex Jia a...@redhat.com wrote: Hi Andres, If you ran virt-v2v as root: # ll ~/.netrc -rw---. 1 root root 293 Aug 16 21:20 /root/.netrc Notes, the file access permission is 600. # cat ~/.netrc machine add your ESX host IP login root password add your ESX host password And then run the following cmdline: # virt-v2v -ic esx:// 192.168.250.31/?no_verify=1 -o rhev -os 192.168.250.30:/oVirt/export -b ovirtmgmt VM_NAME I hope it's helpful for you. Hi Alex, Seems that works because the process finnish now, but at the end gives the following error: virt-v2v: Installation failed because the following files referenced in the configuration file are required, but missing: /usr/share/virtio-win/drivers/i386/Win2008 I found that on RHEL there's a package (yum install virtio-win) that install those files, but I could find it for CentOS 6.3. Any idea where if there is any repo for that ? Yeah, you need to install a virtio-win rpm, the following link should be available: http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers Regards, Alex Regards.- -- AGD ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] [V2V] import errors
-- Regards, Alex - Original Message - From: Andres Gonzalez tuc...@gmail.com To: Alex Jia a...@redhat.com Cc: users@ovirt.org Sent: Monday, August 27, 2012 11:32:57 AM Subject: Re: [Users] [V2V] import errors On Mon, Aug 27, 2012 at 12:19 AM, Alex Jia a...@redhat.com wrote: - Original Message - From: Andres Gonzalez tuc...@gmail.com To: Alex Jia a...@redhat.com Cc: users@ovirt.org Sent: Saturday, August 25, 2012 1:37:10 AM Subject: Re: [Users] [V2V] import errors On Fri, Aug 24, 2012 at 4:52 AM, Alex Jia a...@redhat.com wrote: Hi Andres, If you ran virt-v2v as root: # ll ~/.netrc -rw---. 1 root root 293 Aug 16 21:20 /root/.netrc Notes, the file access permission is 600. # cat ~/.netrc machine add your ESX host IP login root password add your ESX host password And then run the following cmdline: # virt-v2v -ic esx:// 192.168.250.31/?no_verify=1 -o rhev -os 192.168.250.30:/oVirt/export -b ovirtmgmt VM_NAME I hope it's helpful for you. Hi Alex, Seems that works because the process finnish now, but at the end gives the following error: virt-v2v: Installation failed because the following files referenced in the configuration file are required, but missing: /usr/share/virtio-win/drivers/i386/Win2008 I found that on RHEL there's a package (yum install virtio-win) that install those files, but I could find it for CentOS 6.3. Any idea where if there is any repo for that ? Yeah, you need to install a virtio-win rpm, the following link should be available: http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers Regards, Alex Regards.- May be I looking bad but on that URL there's only an iso file ( virtio-win-0.1-30.iso ), and for example doesn't have a Win2008 directory inside. Please see this discussion http://lists.centos.org/pipermail/centos-virt/2011-July/002493.html;. Alex Regards.- -- AGD ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Unable to get latest resource status
Hi Michael, Thanks for your reply, yeah, it's not a bug, I mean whether we may support wait_for_status function in ovirt-engine-sdk like python-rhev, as I said, it will be more convenient for users. so it should be RFE. In addition, I know this user guide, however, I think I need to see it carefully again. Thanks, Alex - Original Message - From: Michael Pasternak mpast...@redhat.com To: Alex Jia a...@redhat.com Cc: Juan Hernandez juan.hernan...@redhat.com, users@ovirt.org, Rita Wu r...@redhat.com, Itamar Heim ih...@redhat.com Sent: Saturday, April 28, 2012 7:21:59 PM Subject: Re: [Users] Unable to get latest resource status Hi Alex, On 04/28/2012 06:19 AM, Alex Jia wrote: On 04/27/2012 11:30 PM, Juan Hernandez wrote: On 04/27/2012 05:27 PM, Alex Jia wrote: Although I haven't try it, I think you're right, I should refresh VM in loop body. Let me know what is the result in your environment. I have tried it and indeed works well for me. In addition, as I said, it will be convenient if we have wait_for_status function like before. I will look into it. I would greatly appreciate if you can open a bug to request and track it. It's okay for me, I want to know I need to file a fedora bug? which component? because I'm doing these on RHEL6.2. it's not a bug, since we using RESTful api, you get resource representation which is holding vm metadata relevant only for the given moment, if you want to poll this vm for the status change, you'll have to retrieve it on each iteration. not relevant to vm execution, but we also have /sync execution mode/ (mostly on storage related actions, see our user guide [1]), so you can block action till it get accomplished on server side. [1] http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html/REST_API_Guide/ -- Michael Pasternak RedHat, ENG-Virtualization RD ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Unable to get latest resource status
On 04/27/2012 04:06 PM, Juan Hernandez wrote: On 04/26/2012 05:49 PM, Alex Jia wrote: I built ovirt-engine-sdk rpm based on git repo 'http://gerrit.ovirt.org/p/ovirt-engine-sdk.git', then the ovirt-engine-sdk works well for me, I can get resource information from Ovirt/RHEVM(3.0) on the rhel6.2. The only question is I can't get latest resource status when I changed VM from 'suspended' to 'up' status, the api.vms.get(vm_name).status.state is always 'suspended' status, I can get a correct VM status unless I reconnect Ovirt/RHEVM, it's not convenient for users, I remember there are reload and wait_for_status method in old python binding API of RHEV(python-rhev), the wait_for_status method will reload resource then get current resource status, however, I haven't found similar method in ovirt-engine-sdk. Are you sure you are calling api.vms.get(vm_name) each time? Or are you doing something like this: vm = api.vms.get(vm_name) while vm.status.state == suspended: sleep(10) Yeah, I put 'api.vms.get(vm_name)' in a loop body like above codes. If you are doing that the vm information is retrieved only once, not each time. If this is the case try something like this: while api.vms.get(VM_NAME).status.state == suspended: sleep(1) Can you share that snippet of code so that I can try to reproduce it? Okay, I will list my snippet of code in here, you may replace 'logging' with 'print' then remove useless '()' if need. thanks. snip import time, logging from ovirtsdk.api import API from ovirtsdk.xml import params class RHEV(object): RHEV class def __init__(self, url, username, password): try: self.api = API(url, username, password) except Exception as e: logging.error('could not connect: %s\n' % str(e)) else: logging.info('success: RHEV manager could be reached OK\n') def vm_start(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Starting VM') vm.start() logging.info('Waiting for VM to reach Up status') while vm.status.state != 'up': time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to start VM:\n%s' % str(e)) def vm_suspend(self, vm_name): vm = self.api.vms.get(vm_name) while vm.status.state != 'suspended': try: logging.info('Suspend VM') vm.suspend() logging.info('Waiting for VM to reach suspended status') while vm.status.state != 'suspended': time.sleep(1) except Exception as e: if e.reason == 'Bad Request' \ and 'asynchronous running tasks' in e.detail: logging.warning('VM has asynchronous running tasks, trying again') time.sleep(1) else: logging.error('Failed to suspend VM:\n%s' % str(e)) break def vm_resume(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Resume VM') vm.start() logging.info('Waiting for VM to resume') while vm.status.state != 'up': time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to resume VM:\n%s' % str(e)) /snip ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Unable to get latest resource status
Hi Juan, Although I haven't try it, I think you're right, I should refresh VM in loop body. In addition, as I said, it will be convenient if we have wait_for_status function like before. Thanks, Alex - Original Message - From: Juan Hernandez juan.hernan...@redhat.com To: Alex Jia a...@redhat.com Cc: users@ovirt.org, Rita Wu r...@redhat.com Sent: Friday, April 27, 2012 8:17:05 PM Subject: Re: [Users] Unable to get latest resource status On 04/27/2012 12:06 PM, Alex Jia wrote: On 04/27/2012 04:06 PM, Juan Hernandez wrote: On 04/26/2012 05:49 PM, Alex Jia wrote: I built ovirt-engine-sdk rpm based on git repo 'http://gerrit.ovirt.org/p/ovirt-engine-sdk.git', then the ovirt-engine-sdk works well for me, I can get resource information from Ovirt/RHEVM(3.0) on the rhel6.2. The only question is I can't get latest resource status when I changed VM from 'suspended' to 'up' status, the api.vms.get(vm_name).status.state is always 'suspended' status, I can get a correct VM status unless I reconnect Ovirt/RHEVM, it's not convenient for users, I remember there are reload and wait_for_status method in old python binding API of RHEV(python-rhev), the wait_for_status method will reload resource then get current resource status, however, I haven't found similar method in ovirt-engine-sdk. Are you sure you are calling api.vms.get(vm_name) each time? Or are you doing something like this: vm = api.vms.get(vm_name) while vm.status.state == suspended: sleep(10) Yeah, I put 'api.vms.get(vm_name)' in a loop body like above codes. If you are doing that the vm information is retrieved only once, not each time. If this is the case try something like this: while api.vms.get(VM_NAME).status.state == suspended: sleep(1) Can you share that snippet of code so that I can try to reproduce it? Okay, I will list my snippet of code in here, you may replace 'logging' with 'print' then remove useless '()' if need. thanks. snip import time, logging from ovirtsdk.api import API from ovirtsdk.xml import params class RHEV(object): RHEV class def __init__(self, url, username, password): try: self.api = API(url, username, password) except Exception as e: logging.error('could not connect: %s\n' % str(e)) else: logging.info('success: RHEV manager could be reached OK\n') def vm_start(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Starting VM') vm.start() logging.info('Waiting for VM to reach Up status') while vm.status.state != 'up': I think that the problem is with the line above. The VM object that you get with self.api.vms.get(vm_name) is not automatically refreshed, you have to refresh it before each iteration calling the api.vms.get(...) method again: while api.vms.get(vm_name).status.state != 'up': Can you try that? time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to start VM:\n%s' % str(e)) def vm_suspend(self, vm_name): vm = self.api.vms.get(vm_name) while vm.status.state != 'suspended': try: logging.info('Suspend VM') vm.suspend() logging.info('Waiting for VM to reach suspended status') while vm.status.state != 'suspended': Same here ^. time.sleep(1) except Exception as e: if e.reason == 'Bad Request' \ and 'asynchronous running tasks' in e.detail: logging.warning('VM has asynchronous running tasks, trying again') time.sleep(1) else: logging.error('Failed to suspend VM:\n%s' % str(e)) break def vm_resume(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Resume VM') vm.start() logging.info('Waiting for VM to resume') while vm.status.state != 'up': Same here ^. time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to resume VM:\n%s' % str(e)) /snip ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Unable to get latest resource status
On 04/27/2012 11:30 PM, Juan Hernandez wrote: On 04/27/2012 05:27 PM, Alex Jia wrote: Although I haven't try it, I think you're right, I should refresh VM in loop body. Let me know what is the result in your environment. I have tried it and indeed works well for me. In addition, as I said, it will be convenient if we have wait_for_status function like before. I will look into it. I would greatly appreciate if you can open a bug to request and track it. It's okay for me, I want to know I need to file a fedora bug? which component? because I'm doing these on RHEL6.2. - Original Message - From: Juan Hernandezjuan.hernan...@redhat.com To: Alex Jiaa...@redhat.com Cc: users@ovirt.org, Rita Wur...@redhat.com Sent: Friday, April 27, 2012 8:17:05 PM Subject: Re: [Users] Unable to get latest resource status On 04/27/2012 12:06 PM, Alex Jia wrote: On 04/27/2012 04:06 PM, Juan Hernandez wrote: On 04/26/2012 05:49 PM, Alex Jia wrote: I built ovirt-engine-sdk rpm based on git repo 'http://gerrit.ovirt.org/p/ovirt-engine-sdk.git', then the ovirt-engine-sdk works well for me, I can get resource information from Ovirt/RHEVM(3.0) on the rhel6.2. The only question is I can't get latest resource status when I changed VM from 'suspended' to 'up' status, the api.vms.get(vm_name).status.state is always 'suspended' status, I can get a correct VM status unless I reconnect Ovirt/RHEVM, it's not convenient for users, I remember there are reload and wait_for_status method in old python binding API of RHEV(python-rhev), the wait_for_status method will reload resource then get current resource status, however, I haven't found similar method in ovirt-engine-sdk. Are you sure you are calling api.vms.get(vm_name) each time? Or are you doing something like this: vm = api.vms.get(vm_name) while vm.status.state == suspended: sleep(10) Yeah, I put 'api.vms.get(vm_name)' in a loop body like above codes. If you are doing that the vm information is retrieved only once, not each time. If this is the case try something like this: while api.vms.get(VM_NAME).status.state == suspended: sleep(1) Can you share that snippet of code so that I can try to reproduce it? Okay, I will list my snippet of code in here, you may replace 'logging' with 'print' then remove useless '()' if need. thanks. snip import time, logging from ovirtsdk.api import API from ovirtsdk.xml import params class RHEV(object): RHEV class def __init__(self, url, username, password): try: self.api = API(url, username, password) except Exception as e: logging.error('could not connect: %s\n' % str(e)) else: logging.info('success: RHEV manager could be reached OK\n') def vm_start(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Starting VM') vm.start() logging.info('Waiting for VM to reach Up status') while vm.status.state != 'up': I think that the problem is with the line above. The VM object that you get with self.api.vms.get(vm_name) is not automatically refreshed, you have to refresh it before each iteration calling the api.vms.get(...) method again: while api.vms.get(vm_name).status.state != 'up': Can you try that? time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to start VM:\n%s' % str(e)) def vm_suspend(self, vm_name): vm = self.api.vms.get(vm_name) while vm.status.state != 'suspended': try: logging.info('Suspend VM') vm.suspend() logging.info('Waiting for VM to reach suspended status') while vm.status.state != 'suspended': Same here ^. time.sleep(1) except Exception as e: if e.reason == 'Bad Request' \ and 'asynchronous running tasks' in e.detail: logging.warning('VM has asynchronous running tasks, trying again') time.sleep(1) else: logging.error('Failed to suspend VM:\n%s' % str(e)) break def vm_resume(self, vm_name): try: vm = self.api.vms.get(vm_name) if vm.status.state != 'up': logging.info('Resume VM') vm.start() logging.info('Waiting for VM to resume') while vm.status.state != 'up': Same here ^. time.sleep(1) else: logging.debug('VM already up') except Exception as e: logging.error('Failed to resume VM:\n%s' % str(e)) /snip