how to check whether is orphan instance and delete orphan instance with python

asked 2016-07-07 04:00:19 -0600

genie gravatar image

updated 2016-07-08 04:15:44 -0600

orphan instance definition is that after deleted project first before deleted instance, the instance exist but not owned by any project, such as orphan floating ip,

we know that it can be deleted in web horizon, but we would like to list all instance including orphan instance with python script or command. if can use python script to delete orphan script will be a bonus

nova_client.servers.list has name only for each project and can only show non-orphan instance,

how to get a whole list of instance including orphan instance and check whether it is orphan instance and then delete this orphan instance with python script

edit retag flag offensive close merge delete

Comments

what do you exactly mean by orphan instances. it is unclear from your question what exactly are you trying to acheive.

Syed Awais Ali gravatar imageSyed Awais Ali ( 2016-07-07 04:52:29 -0600 )edit

orphan instance means after deleted project first before deleted instance, the instance exist but not owned by any project, such as orphan floating ip

genie gravatar imagegenie ( 2016-07-08 04:13:27 -0600 )edit

nova hypervisor-servers <compute-hostname> will show the orphaned instances, but only by using nova show <server-id> on each server and comparing tenant_id with known project_ids from openstack project list. If no match, then use nova delete <server-id> to remove the orphaned instance(s).

barry.davis gravatar imagebarry.davis ( 2016-07-10 14:34:49 -0600 )edit