1 # Copyright 2011 Justin Santa Barbara |
1 # Copyright 2011 Justin Santa Barbara |
2 # All Rights Reserved. |
2 # All Rights Reserved. |
3 # |
3 # |
4 # Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. |
4 # Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
5 # |
5 # |
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may |
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may |
7 # not use this file except in compliance with the License. You may obtain |
7 # not use this file except in compliance with the License. You may obtain |
8 # a copy of the License at |
8 # a copy of the License at |
9 # |
9 # |
1776 old_rvid = instance.system_metadata.get('old_instance_volid') |
1776 old_rvid = instance.system_metadata.get('old_instance_volid') |
1777 if old_rvid: |
1777 if old_rvid: |
1778 new_rvid = instance.system_metadata.get('new_instance_volid') |
1778 new_rvid = instance.system_metadata.get('new_instance_volid') |
1779 newvname = instance['display_name'] + "-" + self._rootzpool_suffix |
1779 newvname = instance['display_name'] + "-" + self._rootzpool_suffix |
1780 mount_dev = instance['root_device_name'] |
1780 mount_dev = instance['root_device_name'] |
1781 del instance.system_metadata['new_instance_volid'] |
|
1782 del instance.system_metadata['old_instance_volid'] |
1781 del instance.system_metadata['old_instance_volid'] |
1783 |
1782 |
1784 self._resize_disk_migration(context, instance, new_rvid, old_rvid, |
1783 self._resize_disk_migration(context, instance, new_rvid, old_rvid, |
1785 rgb, mount_dev) |
1784 rgb, mount_dev) |
1786 |
|
1787 self._volume_api.delete(context, new_rvid) |
|
1788 |
1785 |
1789 def destroy(self, context, instance, network_info, block_device_info=None, |
1786 def destroy(self, context, instance, network_info, block_device_info=None, |
1790 destroy_disks=True, migrate_data=None): |
1787 destroy_disks=True, migrate_data=None): |
1791 """Destroy the specified instance from the Hypervisor. |
1788 """Destroy the specified instance from the Hypervisor. |
1792 |
1789 |
1839 LOG.warning(_("Unable to destroy instance '%s' via zonemgr(3RAD): " |
1836 LOG.warning(_("Unable to destroy instance '%s' via zonemgr(3RAD): " |
1840 "%s") % (name, reason)) |
1837 "%s") % (name, reason)) |
1841 |
1838 |
1842 # One last point of house keeping. If we are deleting the instance |
1839 # One last point of house keeping. If we are deleting the instance |
1843 # during a resize operation we want to make sure the cinder volumes are |
1840 # during a resize operation we want to make sure the cinder volumes are |
1844 # property cleaned up. We need to do this here, because the periodic |
1841 # properly cleaned up. We need to do this here, because the periodic |
1845 # task that comes along and cleans these things up isn't nice enough to |
1842 # task that comes along and cleans these things up isn't nice enough to |
1846 # pass a context in so that we could simply do the work there. But |
1843 # pass a context in so that we could simply do the work there. But |
1847 # because we have access to a context, we can handle the work here and |
1844 # because we have access to a context, we can handle the work here and |
1848 # let the periodic task simply clean up the left over zone |
1845 # let the periodic task simply clean up the left over zone |
1849 # configuration that might be left around. Note that the left over |
1846 # configuration that might be left around. Note that the left over |
2683 bdm['volume_id'] = old_rvid |
2680 bdm['volume_id'] = old_rvid |
2684 bdm.save() |
2681 bdm.save() |
2685 |
2682 |
2686 del instance.system_metadata['new_instance_volid'] |
2683 del instance.system_metadata['new_instance_volid'] |
2687 del instance.system_metadata['old_instance_volid'] |
2684 del instance.system_metadata['old_instance_volid'] |
2688 |
2685 else: |
2689 rootmp = instance.root_device_name |
2686 new_rvid = instance.system_metadata['new_instance_volid'] |
2690 bmap = block_device_info.get('block_device_mapping') |
2687 if new_rvid: |
2691 for entry in bmap: |
2688 del instance.system_metadata['new_instance_volid'] |
2692 if entry['mount_device'] != rootmp: |
2689 self._volume_api.delete(context, new_rvid) |
2693 self.attach_volume(context, |
|
2694 entry['connection_info'], instance, |
|
2695 entry['mount_device']) |
|
2696 |
2690 |
2697 self._power_on(instance) |
2691 self._power_on(instance) |
2698 |
2692 |
2699 def pause(self, instance): |
2693 def pause(self, instance): |
2700 """Pause the specified instance. |
2694 """Pause the specified instance. |