Merge lp:~nttdata/nova/kvm-pause-suspend into lp:~hudson-openstack/nova/trunk
Proposed by
Kei Masumoto
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Dan Prince | ||||
Approved revision: | 987 | ||||
Merged at revision: | 1126 | ||||
Proposed branch: | lp:~nttdata/nova/kvm-pause-suspend | ||||
Merge into: | lp:~hudson-openstack/nova/trunk | ||||
Diff against target: |
35 lines (+12/-4) 1 file modified
nova/virt/libvirt/connection.py (+12/-4) |
||||
To merge this branch: | bzr merge lp:~nttdata/nova/kvm-pause-suspend | ||||
Related bugs: |
|
||||
Related blueprints: |
kvm-pause-suspend
(Low)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Dan Prince (community) | Approve | ||
Vish Ishaya (community) | Approve | ||
Devin Carlen (community) | Approve | ||
Brian Lamar (community) | Approve | ||
Jay Pipes (community) | Approve | ||
justinsb (community) | Needs Information | ||
Review via email: mp+62255@code.launchpad.net |
Description of the change
added pause/suspend implementation to nova.virt.
To post a comment you must log in.
Hi. Repeating same logic seems ugly. How about something like the following?
def _do_dom(self, action, instance_name)
if self.readonly:
tmpconn ...
action(dom) close()
tmpconn.
else:
dom = ...
action(dom)
def pause(...) _do_dom( virtDoain. suspend)
...
self.
...
thanks,
On Wed, May 25, 2011 at 08:23:29AM -0000, Kei Masumoto wrote: /code.launchpad .net/~nttdata/ nova/kvm- pause-suspend/ +merge/ 62255 libvirt_ conn /code.launchpad .net/~nttdata/ nova/kvm- pause-suspend/ +merge/ 62255
> Kei Masumoto has proposed merging lp:~nttdata/nova/kvm-pause-suspend into lp:nova.
>
> Requested reviews:
> Nova Core (nova-core)
>
> For more details, see:
> https:/
>
> added pause/suspend implementation to nova.virt.
> --
> https:/
> You are subscribed to branch lp:nova.
> === modified file 'nova/virt/ libvirt_ conn.py' libvirt_ conn.py 2011-05-17 16:28:44 +0000 libvirt_ conn.py 2011-05-25 08:17:27 +0000 wrap_exception ApiError( "pause not supported for libvirt.") self.libvirt_ uri, False) lookupByName( instance. name) lookupByName( instance. name) wrap_exception ApiError( "unpause not supported for libvirt.") self.libvirt_ uri, False) lookupByName( instance. name) lookupByName( instance. name) wrap_exception ApiError( "suspend not supported for libvirt") self.libvirt_ uri, False) lookupByName( instance. name) lookupByName( instance. name) wrap_exception ApiError( "resume not supported for libvirt") self.libvirt_ uri, False) lookupByName( instance. name) lookupByName( instance. name) LibvirtError: xml(instance, None) new_domain( xml)
> --- nova/virt/
> +++ nova/virt/
> @@ -550,19 +550,54 @@
>
> @exception.
> def pause(self, instance, callback):
> - raise exception.
> + """Pause VM instance"""
> + if self.read_only:
> + tmpconn = self._connect(
> + dom = tmpconn.
> + dom.suspend()
> + tmpconn.close()
> + else:
> + dom = self._conn.
> + dom.suspend()
>
> @exception.
> def unpause(self, instance, callback):
> - raise exception.
> + """Unpause paused VM instance"""
> + if self.read_only:
> + tmpconn = self._connect(
> + dom = tmpconn.
> + dom.resume()
> + tmpconn.close()
> + else:
> + dom = self._conn.
> + dom.resume()
>
> @exception.
> def suspend(self, instance, callback):
> - raise exception.
> + """Suspend the specified instance"""
> + if self.read_only:
> + tmpconn = self._connect(
> + dom = tmpconn.
> + dom.managedSave(0)
> + tmpconn.close()
> + else:
> + dom = self._conn.
> + dom.managedSave(0)
>
> @exception.
> def resume(self, instance, callback):
> - raise exception.
> + """resume the specified instance"""
> + try:
> + if self.read_only:
> + tmpconn = self._connect(
> + dom = tmpconn.
> + tmpconn.close()
> + else:
> + dom = self._conn.
> + dom.create()
> + except libvirt.
> + xml = self.to_
> + self._create_
>...