From 2068164d0f155578d2f7a106afe464ef578032cb Mon Sep 17 00:00:00 2001 From: John Griffith Date: Sun, 29 Jun 2014 09:06:31 -0600 Subject: [PATCH] Add cinder-manage cmd to update host column 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/bin/cinder-manage b/bin/cinder-manage index c9eec4ad99f..558d9286caa 100755 --- a/bin/cinder-manage +++ b/bin/cinder-manage @@ -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)."""