Delete Cluster Bug

closes-bug: 1469823

Change-Id: If3a6b861dcecd6cf0169dea4264226b076139dd8
This commit is contained in:
dagnello 2015-06-26 20:05:30 -07:00 committed by Min Pae
parent d23a9cc918
commit 04761d3444
3 changed files with 44 additions and 11 deletions

View File

@ -63,6 +63,7 @@ def delete_cluster_node(cluster_id, node_number, node_id):
os_client=client.nova_client(),
name="list vm interfaces %s" % node_name,
rebind={'server': "vm_id_%d" % node_number},
inject={'ignore_nova_not_found_exception': True},
provides="vm_interfaces_%d" % node_number),
os_common.Lambda(
extract_port_ids,

View File

@ -21,6 +21,7 @@ from cue.tests.functional.fixtures import neutron
from cue.tests.functional.fixtures import nova
import os_tasklib.nova.list_vm_interfaces as list_vm_interfaces
import novaclient.exceptions as nova_exc
from taskflow import engines
from taskflow.patterns import linear_flow
@ -80,6 +81,24 @@ class GetVmInterfacesTests(base.FunctionalTestCase):
interface_list = result['interface_list']
self.assertEqual(self.valid_net_id, interface_list[0]['net_id'])
def test_get_vm_interfaces_invalid_vm(self):
flow_store = {
'server': str(uuid.uuid4())
}
self.assertRaises(nova_exc.NotFound, engines.run, self.flow,
store=flow_store)
def test_get_vm_interfaces_invalid_vm_ignore_not_found_exception(self):
flow_store = {
'server': str(uuid.uuid4()),
'ignore_nova_not_found_exception': True
}
result = engines.run(self.flow, store=flow_store)
interface_list = result['interface_list']
self.assertEqual([], interface_list)
def tearDown(self):
if self.valid_vm_id is not None:
self.nova_client.servers.delete(self.valid_vm_id)

View File

@ -15,6 +15,9 @@
import os_tasklib
from cue.common.i18n import _LW # noqa
import novaclient.exceptions as nova_exc
from oslo_log import log as logging
@ -37,24 +40,34 @@ class ListVmInterfaces(os_tasklib.BaseTask):
attached to the indicated VM.
"""
def execute(self, server, **kwargs):
def execute(self, server, ignore_nova_not_found_exception=False, **kwargs):
"""Main execute method
:param server: vm id to get list of attached interfaces to
:type server: string
:param ignore_nova_not_found_exception: ignore nova not found exception
:type ignore_nova_not_found_exception: bool
:return: list of interfaces
"""
raw_list = self.os_client.servers.interface_list(server=server)
# The interface returned by Nova API has circular references which
# break serialization of the list to storage, so a subset of the data
# is being extracted and returned.
interface_list = list()
for interface in raw_list:
interface_entry = {k: getattr(interface, k)
for k in _INTERFACE_ATTRIBUTES
if hasattr(interface, k)}
interface_list.append(interface_entry)
try:
raw_list = self.os_client.servers.interface_list(server=server)
except nova_exc.NotFound:
if ignore_nova_not_found_exception:
LOG.warning(_LW("VM was not found %s") % server)
else:
raise
else:
# The interface returned by Nova API has circular references which
# break serialization of the list to storage, so a subset of the
# data is being extracted and returned.
for interface in raw_list:
interface_entry = {k: getattr(interface, k)
for k in _INTERFACE_ATTRIBUTES
if hasattr(interface, k)}
interface_list.append(interface_entry)
return interface_list