]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add cinder-manage cmd to update host column
authorJohn Griffith <john.griffith8@gmail.com>
Sun, 29 Jun 2014 15:06:31 +0000 (09:06 -0600)
committerJohn Griffith <john.griffith8@gmail.com>
Sun, 29 Jun 2014 15:06:31 +0000 (09:06 -0600)
If you deploy Cinder as per the default using the docs,
you can't later decide to add backends using the
multi-backend functionality. The reason is that multi-backend
is implemented by appending a backend-name to the host entry.

So if you convert the config to multi-backend the hostname
for any volumes that you have created are no longer
associated with a valid volume-driver (ie you can no
longer perform operations including delete on these
volumes).

In addition, in the case of using a SAN attached backend if
one redeploys their cinder-volume service to another node
they'll have the same issue.

This patch adds a cinder-manage command that will go through
volumes that are located on a specified host and update
the host column on each of them.

Change-Id: I8758fb8ef3fccbba2a598240c42d625b997e2db6
Closes-Bug: 1320688

bin/cinder-manage

index c9eec4ad99fbb6c626cd8bb25175098778a79a53..558d9286caa0856b0307c6b795538931c823dd19 100755 (executable)
@@ -294,6 +294,22 @@ class VolumeCommands(object):
         cctxt.cast(ctxt, "attach_volume", instance_id=instance['id'],
                    volume_id=volume['id'], mountpoint=volume['mountpoint'])
 
+    @args('--currenthost', required=True, help='Existing volume host name')
+    @args('--newhost', required=True, help='New volume host name')
+    def update_host(self, currenthost, newhost):
+        """Modify the host name asscoiated with
+        a volume.  Particularly to recover from
+        cases where one has moved their Cinder Volume
+        node, or modfied their backend_name in a
+        multi-backend config.
+        """
+        ctxt = context.get_admin_context()
+        volumes = db.volume_get_all_by_host(ctxt,
+                                            currenthost)
+        for v in volumes:
+            db.volume_update(ctxt, v['id'],
+                             {'host': newhost})
+
 
 class ConfigCommands(object):
     """Class for exposing the flags defined by flag_file(s)."""