@ -23,7 +23,7 @@ from tempest.common.utils import net_info
from tempest import config
from tempest . lib import exceptions
LOG = logging . getLogger ( __name__ )
LOG = logging . getLogger ( ' tempest.cmd.cleanup ' )
CONF = config . CONF
CONF_FLAVORS = None
@ -167,6 +167,7 @@ class SnapshotService(BaseService):
client = self . client
for snap in snaps :
try :
LOG . debug ( " Deleting Snapshot with id %s " , snap [ ' id ' ] )
client . delete_snapshot ( snap [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Snapshot %s exception. " , snap [ ' id ' ] )
@ -204,6 +205,7 @@ class ServerService(BaseService):
servers = self . list ( )
for server in servers :
try :
LOG . debug ( " Deleting Server with id %s " , server [ ' id ' ] )
client . delete_server ( server [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Server %s exception. " , server [ ' id ' ] )
@ -236,6 +238,7 @@ class ServerGroupService(ServerService):
sgs = self . list ( )
for sg in sgs :
try :
LOG . debug ( " Deleting Server Group with id %s " , sg [ ' id ' ] )
client . delete_server_group ( sg [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Server Group %s exception. " , sg [ ' id ' ] )
@ -273,6 +276,7 @@ class KeyPairService(BaseService):
for k in keypairs :
name = k [ ' keypair ' ] [ ' name ' ]
try :
LOG . debug ( " Deleting keypair %s " , name )
client . delete_keypair ( name )
except Exception :
LOG . exception ( " Delete Keypair %s exception. " , name )
@ -309,6 +313,7 @@ class VolumeService(BaseService):
vols = self . list ( )
for v in vols :
try :
LOG . debug ( " Deleting volume with id %s " , v [ ' id ' ] )
client . delete_volume ( v [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Volume %s exception. " , v [ ' id ' ] )
@ -332,6 +337,8 @@ class VolumeQuotaService(BaseService):
def delete ( self ) :
client = self . client
try :
LOG . debug ( " Deleting Volume Quotas for project with id %s " ,
self . project_id )
client . delete_quota_set ( self . project_id )
except Exception :
LOG . exception ( " Delete Volume Quotas exception for ' project %s ' . " ,
@ -352,9 +359,11 @@ class NovaQuotaService(BaseService):
def delete ( self ) :
client = self . client
try :
LOG . debug ( " Deleting Nova Quotas for project with id %s " ,
self . project_id )
client . delete_quota_set ( self . project_id )
except Exception :
LOG . exception ( " Delete Quotas exception for ' project %s ' . " ,
LOG . exception ( " Delete Nova Quotas exception for ' project %s ' . " ,
self . project_id )
def dry_run ( self ) :
@ -371,6 +380,8 @@ class NetworkQuotaService(BaseService):
def delete ( self ) :
client = self . client
try :
LOG . debug ( " Deleting Network Quotas for project with id %s " ,
self . project_id )
client . reset_quotas ( self . project_id )
except Exception :
LOG . exception ( " Delete Network Quotas exception for ' project %s ' . " ,
@ -419,7 +430,7 @@ class NetworkService(BaseNetworkService):
if self . is_preserve :
networks = [ network for network in networks
if network [ ' id ' ] not in CONF_NETWORKS ]
LOG . debug ( " List count, %s Networks " , networks )
LOG . debug ( " List count, %s Networks " , len ( networks ) )
return networks
def delete ( self ) :
@ -427,6 +438,7 @@ class NetworkService(BaseNetworkService):
networks = self . list ( )
for n in networks :
try :
LOG . debug ( " Deleting Network with id %s " , n [ ' id ' ] )
client . delete_network ( n [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Network %s exception. " , n [ ' id ' ] )
@ -461,6 +473,8 @@ class NetworkFloatingIpService(BaseNetworkService):
flips = self . list ( )
for flip in flips :
try :
LOG . debug ( " Deleting Network Floating IP with id %s " ,
flip [ ' id ' ] )
client . delete_floatingip ( flip [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Network Floating IP %s exception. " ,
@ -506,11 +520,14 @@ class NetworkRouterService(BaseNetworkService):
if net_info . is_router_interface_port ( port ) ]
for port in ports :
try :
LOG . debug ( " Deleting port with id %s of router with id %s " ,
port [ ' id ' ] , rid )
client . remove_router_interface ( rid , port_id = port [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Router Interface exception for "
" ' port %s ' of ' router %s ' . " , port [ ' id ' ] , rid )
try :
LOG . debug ( " Deleting Router with id %s " , rid )
client . delete_router ( rid )
except Exception :
LOG . exception ( " Delete Router %s exception. " , rid )
@ -546,6 +563,8 @@ class NetworkMeteringLabelRuleService(NetworkService):
rules = self . list ( )
for rule in rules :
try :
LOG . debug ( " Deleting Metering Label Rule with id %s " ,
rule [ ' id ' ] )
client . delete_metering_label_rule ( rule [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Metering Label Rule %s exception. " ,
@ -582,6 +601,7 @@ class NetworkMeteringLabelService(BaseNetworkService):
labels = self . list ( )
for label in labels :
try :
LOG . debug ( " Deleting Metering Label with id %s " , label [ ' id ' ] )
client . delete_metering_label ( label [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Metering Label %s exception. " ,
@ -622,6 +642,7 @@ class NetworkPortService(BaseNetworkService):
ports = self . list ( )
for port in ports :
try :
LOG . debug ( " Deleting port with id %s " , port [ ' id ' ] )
client . delete_port ( port [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Port %s exception. " , port [ ' id ' ] )
@ -663,6 +684,7 @@ class NetworkSecGroupService(BaseNetworkService):
secgroups = self . list ( )
for secgroup in secgroups :
try :
LOG . debug ( " Deleting security_group with id %s " , secgroup [ ' id ' ] )
client . delete_security_group ( secgroup [ ' id ' ] )
except Exception :
LOG . exception ( " Delete security_group %s exception. " ,
@ -699,6 +721,7 @@ class NetworkSubnetService(BaseNetworkService):
subnets = self . list ( )
for subnet in subnets :
try :
LOG . debug ( " Deleting subnet with id %s " , subnet [ ' id ' ] )
client . delete_subnet ( subnet [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Subnet %s exception. " , subnet [ ' id ' ] )
@ -734,6 +757,7 @@ class NetworkSubnetPoolsService(BaseNetworkService):
pools = self . list ( )
for pool in pools :
try :
LOG . debug ( " Deleting Subnet Pool with id %s " , pool [ ' id ' ] )
client . delete_subnetpool ( pool [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Subnet Pool %s exception. " , pool [ ' id ' ] )
@ -762,8 +786,10 @@ class RegionService(BaseService):
if not self . is_save_state :
regions = [ region for region in regions [ ' regions ' ] if region [ ' id ' ]
not in self . saved_state_json [ ' regions ' ] . keys ( ) ]
LOG . debug ( " List count, %s Regions " , len ( regions ) )
return regions
else :
LOG . debug ( " List count, %s Regions " , len ( regions [ ' regions ' ] ) )
return regions [ ' regions ' ]
def delete ( self ) :
@ -771,6 +797,7 @@ class RegionService(BaseService):
regions = self . list ( )
for region in regions :
try :
LOG . debug ( " Deleting region with id %s " , region [ ' id ' ] )
client . delete_region ( region [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Region %s exception. " , region [ ' id ' ] )
@ -812,6 +839,7 @@ class FlavorService(BaseService):
flavors = self . list ( )
for flavor in flavors :
try :
LOG . debug ( " Deleting flavor with id %s " , flavor [ ' id ' ] )
client . delete_flavor ( flavor [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Flavor %s exception. " , flavor [ ' id ' ] )
@ -857,6 +885,7 @@ class ImageService(BaseService):
images = self . list ( )
for image in images :
try :
LOG . debug ( " Deleting image with id %s " , image [ ' id ' ] )
client . delete_image ( image [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Image %s exception. " , image [ ' id ' ] )
@ -900,6 +929,7 @@ class UserService(BaseService):
users = self . list ( )
for user in users :
try :
LOG . debug ( " Deleting user with id %s " , user [ ' id ' ] )
self . client . delete_user ( user [ ' id ' ] )
except Exception :
LOG . exception ( " Delete User %s exception. " , user [ ' id ' ] )
@ -940,6 +970,7 @@ class RoleService(BaseService):
roles = self . list ( )
for role in roles :
try :
LOG . debug ( " Deleting role with id %s " , role [ ' id ' ] )
self . client . delete_role ( role [ ' id ' ] )
except Exception :
LOG . exception ( " Delete Role %s exception. " , role [ ' id ' ] )
@ -982,6 +1013,7 @@ class ProjectService(BaseService):
projects = self . list ( )
for project in projects :
try :
LOG . debug ( " Deleting project with id %s " , project [ ' id ' ] )
self . client . delete_project ( project [ ' id ' ] )
except Exception :
LOG . exception ( " Delete project %s exception. " , project [ ' id ' ] )
@ -1018,6 +1050,7 @@ class DomainService(BaseService):
domains = self . list ( )
for domain in domains :
try :
LOG . debug ( " Deleting domain with id %s " , domain [ ' id ' ] )
client . update_domain ( domain [ ' id ' ] , enabled = False )
client . delete_domain ( domain [ ' id ' ] )
except Exception :