def delete_network_all_subnets(self, net_id):
        """Delete the openstack network including all its subnets. """
        try:
            body = {'network_id': net_id}
            subnet_list = self.neutronclient.list_subnets(body=body)
            subnet_list = subnet_list.get('subnets')
            for subnet in subnet_list:
                if subnet.get('network_id') == net_id:
                    subnet_id = subnet.get('id')
                    self.neutronclient.delete_subnet(subnet_id)
        except Exception as exc:
            LOG.error("Failed to delete subnet for net %(net)s "
                      "Exc %(exc)s", {'net': net_id, 'exc': str(exc)})
            return False
        try:
            self.neutronclient.delete_network(net_id)
        except Exception as exc:
            LOG.error("Failed to delete network %(net)s Exc %(exc)s",
                      {'net': net_id, 'exc': str(exc)})
            return False
        return True
def delete_network_all_subnets ( self , net_id ) : try : body = { 'network_id' : net_id } subnet_list = self . neutronclient . list_subnets ( body = body ) subnet_list = subnet_list . get ( 'subnets' ) for subnet in subnet_list : if subnet . get ( 'network_id' ) == net_id : subnet_id = subnet . get ( 'id' ) self . neutronclient . delete_subnet ( subnet_id ) except Exception as exc : LOG . error ( "Failed to delete subnet for net %(net)s " "Exc %(exc)s" , { 'net' : net_id , 'exc' : str ( exc ) } ) return False try : self . neutronclient . delete_network ( net_id ) except Exception as exc : LOG . error ( "Failed to delete network %(net)s Exc %(exc)s" , { 'net' : net_id , 'exc' : str ( exc ) } ) return False return True
Delete the openstack network including all its subnets.