openstack 数据库实例删除脚本

来源:互联网 发布:新手淘宝开店教程视频 编辑:程序博客网 时间:2024/04/25 13:58

遇到错误实例的时候要删除,数据库中有好几张表关联,所以整理了个脚本,以实例ID ,来删除更新关联的几张表中的数据。

直接在mysql中运行

DROP PROCEDURE IF EXISTS test1//        CREATE PROCEDURE test1()         BEGIN         DECLARE instanceID int(11);      set instanceID = 4;update instances set   deleted_at = updated_at,   deleted = 1,   power_state = 0,   vm_state = "deleted",   terminated_at = updated_at,   root_device_name = NULL,   task_state = NULL   where id =instanceID  ;update instance_info_caches set   deleted_at = updated_at,   deleted = 1   where instance_id = (select uuid from instances where id =instanceID );update security_group_instance_association set   deleted_at = updated_at,   deleted = 1   where instance_id =instanceID  ;  update fixed_ips set   instance_id = NULL,   allocated = 0,leased = 0,   virtual_interface_id = NULL   where instance_id = instanceID ;delete from virtual_interfaces where instance_id =instanceID  ;update floating_ips set deleted_at = updated_at,fixed_ip_id = NULL,host = NULLwhere fixed_ip_id = (select id from fixed_ips where instance_id =instanceID );     END//call test1//