OpenStack Essex中Nova Resize功能更改

更改nova.conf配置(nova api host)

#允许冷迁移到相同主机
#因在nova resize时,将合并虚拟机的快照磁盘与初始镜像,
#迁移至其他主机会受到网络带宽的限制  
allow_resize_to_same_host = True

更改nova代码

Nova 代码已更新至GitHub: https://github.com/Powerleader/nova-plcloud

#/usr/lib/python2.6/site-packages/nova/compute/api.py
#取消升级时对内存配置的限制
    def resize(self, context, instance, flavor_id=None, **kwargs): 
…… 
        #if (current_memory_mb == new_memory_mb) and flavor_id: 
        #    raise exception.CannotResizeToSameSize() 
…… 

#先复制inst_base目录至inst_base_resize,再执行destroy
#/usr/lib/python2.6/site-packages/nova/virt/libvirt/connection.py
    def migrate_disk_and_power_off(self, context, instance, dest, 
                                   instance_type, network_info): 
        #self._destroy(instance, network_info, cleanup=False) 
…… 
        try: 
            utils.execute('cp', '-r', inst_base, inst_base_resize) 
            self._destroy(instance, network_info, cleanup=False) 
…… 


#注:因为awcloud在_destroy中,在判断cleanup参数前,直接删除了root disk文件:
    def _destroy(self, instance, network_info, block_device_info=None, 
                 cleanup=True): 
        # APPEND BY ZHANGJIALONG<zhangjl@awcloud.com> BEGIN 
        # Delete the root disk of vm instance 
        target = os.path.join(FLAGS.instances_path, instance['name'],"disk") 
        if os.path.exists(target): 
            os.remove(target) 
        # APPEND BY ZHANGJIALONG<zhangjl@awcloud.com> END 
        if cleanup: 
            self._cleanup(instance)

nova resize操作步骤

#升级配置
 nova resize [--poll] <server> <flavor>
#升级完成后,虚拟机会进入resize_verify状态,等待确认

#确认升级
#可在nova.conf添加resize_confirm_window配置,以自动确认
nova resize-confirm <server>

#撤销升级
nova resize-revert <server>

升级后迁移网络信息

#在原主机上清除Floating IP的绑定
ip addr del 192.168.11.180/32 dev eth0

#在现主机上添加Floating IP的绑定
ip addr add 192.168.11.180/32 dev eth0

#重启现主机中的nova-network服务
service openstack-nova-network stop
service openstack-nova-network start

#重启虚拟机中的network,重新获取内网IP
service network restart




One thought on “OpenStack Essex中Nova Resize功能更改

  1. Pingback: qemu-img resize磁盘扩容 | rf.w's BlueSky

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>