def _action_ha_to_sg(self, instance, body): LOG.debug("_action_ha_to_sg start instance: %s", instance.id) ha_to_sg_body = body.get('ha_to_sg', None) if ha_to_sg_body is None: msg = (_("request body not contains 'ha_to_sg' attribute. '%s'" % body)) LOG.error(msg) raise exception.BadRequest(msg) master_id = instance.id fake_delete_standby = ha_to_sg_body.get('fake_delete_standby') if fake_delete_standby is not None: fake_delete_standby = str(fake_delete_standby).lower().strip() if fake_delete_standby == 'false': fake_delete_standby = False else: fake_delete_standby = True else: fake_delete_standby = True LOG.debug("_action_ha_to_sg fake_delete_standby: %s", fake_delete_standby) master = FreshInstance.load(instance.context, master_id) seccess, msg = KSC_FreshInstanceTasks_Ext.check_ha_to_sg(instance.context, master) if not seccess: LOG.error(msg) raise exception.BadRequest(msg) instance.ha_to_sg(instance.context, master_id, fake_delete_standby=fake_delete_standby) LOG.debug("_action_ha_to_sg finished instance: %s", instance.id) return wsgi.Result(None, 202)
def _action_switch_master(self, instance, body): switch_master_body = body.get('switch_master', None) if switch_master_body is None: msg = (_("request body not contains 'switch_master' attribute. '%s'" % body)) LOG.error(msg) raise exception.BadRequest(msg) old_master_id = instance.id new_master_id = switch_master_body.get('new_master_id', None) seccess, msg = KSC_FreshInstanceTasks_Ext.check_switch_master(instance.context, instance.group_id, old_master_id, new_master_id) if not seccess: LOG.error(msg) raise exception.BadRequest(msg) instance.switch_master(instance.context, instance.group_id, old_master_id, new_master_id) return wsgi.Result(None, 202)