Revert "Revert "Cleanup down ports""
This reverts commit 7e1b8a7261.
openstacksdk >=0.19.0 fixes the filtering problems leading to all
ports being deleted. However openstacksdk <0.21.0 has problems with
dogpile.cache so use 0.21.0 as a minimum.
Change-Id: Id642d074cbb645ced5342dda4a1c89987c91a8fc
This commit is contained in:
committed by
Tobias Henkel
parent
e459ffa0fd
commit
0cf8144e8c
@@ -32,6 +32,7 @@ class Dummy(object):
|
||||
INSTANCE = 'Instance'
|
||||
FLAVOR = 'Flavor'
|
||||
LOCATION = 'Server.Location'
|
||||
PORT = 'Port'
|
||||
|
||||
def __init__(self, kind, **kw):
|
||||
self.__kind = kind
|
||||
@@ -105,6 +106,12 @@ class FakeOpenStackCloud(object):
|
||||
self._server_list = []
|
||||
self.max_cores, self.max_instances, self.max_ram = FakeOpenStackCloud.\
|
||||
_get_quota()
|
||||
self._down_ports = [
|
||||
Dummy(Dummy.PORT, id='1a', status='DOWN',
|
||||
device_owner="compute:nova"),
|
||||
Dummy(Dummy.PORT, id='2b', status='DOWN',
|
||||
device_owner=None),
|
||||
]
|
||||
|
||||
def _get(self, name_or_id, instance_list):
|
||||
self.log.debug("Get %s in %s" % (name_or_id, repr(instance_list)))
|
||||
@@ -286,6 +293,20 @@ class FakeOpenStackCloud(object):
|
||||
total_ram_used=8192 * len(self._server_list)
|
||||
)
|
||||
|
||||
def list_ports(self, filters=None):
|
||||
if filters and filters.get('status') == 'DOWN':
|
||||
return self._down_ports
|
||||
return []
|
||||
|
||||
def delete_port(self, port_id):
|
||||
tmp_ports = []
|
||||
for port in self._down_ports:
|
||||
if port.id != port_id:
|
||||
tmp_ports.append(port)
|
||||
else:
|
||||
self.log.debug("Deleted port ID: %s", port_id)
|
||||
self._down_ports = tmp_ports
|
||||
|
||||
|
||||
class FakeUploadFailCloud(FakeOpenStackCloud):
|
||||
log = logging.getLogger("nodepool.FakeUploadFailCloud")
|
||||
|
||||
Reference in New Issue
Block a user