created_items = {}
expected_block_device_mapping = {}
self.vimconn.cinder.volumes.list.return_value = [
- Volume("avaible", "multiattach", "shared-volume", volume_id4)
+ Volume("available", "multiattach", "shared-volume", volume_id4)
]
self.vimconn.cinder.volumes.get.return_value.id = volume_id4
+ self.vimconn.cinder.volumes.get.return_value.status = "available"
self.vimconn._prepare_shared_volumes(
name,
disk,
def test_delete_ports_by_id_by_neutron(self):
"""neutron delete ports."""
k_id = port_id
- self.vimconn.neutron.list_ports.return_value = {
- "ports": [{"id": port_id}, {"id": port2_id}]
- }
-
self.vimconn._delete_ports_by_id_wth_neutron(k_id)
- self.vimconn.neutron.list_ports.assert_called_once()
self.vimconn.neutron.delete_port.assert_called_once_with(k_id)
self.vimconn.logger.error.assert_not_called()
- def test_delete_ports_by_id_by_neutron_id_not_in_port_list(self):
- """port id not in the port list."""
- k_id = volume_id
- self.vimconn.neutron.list_ports.return_value = {
- "ports": [{"id": port_id}, {"id": port2_id}]
- }
-
- self.vimconn._delete_ports_by_id_wth_neutron(k_id)
- self.vimconn.neutron.list_ports.assert_called_once()
- self.vimconn.neutron.delete_port.assert_not_called()
- self.vimconn.logger.error.assert_not_called()
-
- def test_delete_ports_by_id_by_neutron_list_port_raise_exception(self):
- """neutron list port raises exception."""
- k_id = port_id
- self.vimconn.neutron.list_ports.side_effect = nvExceptions.ClientException(
- "Connection aborted."
- )
- self.vimconn._delete_ports_by_id_wth_neutron(k_id)
- self.vimconn.neutron.list_ports.assert_called_once()
- self.vimconn.neutron.delete_port.assert_not_called()
- self.vimconn.logger.error.assert_called_once_with(
- "Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)"
- )
-
def test_delete_ports_by_id_by_neutron_delete_port_raise_exception(self):
"""neutron delete port raises exception."""
k_id = port_id
- self.vimconn.neutron.list_ports.return_value = {
- "ports": [{"id": port_id}, {"id": port2_id}]
- }
self.vimconn.neutron.delete_port.side_effect = nvExceptions.ClientException(
"Connection aborted."
)
self.vimconn._delete_ports_by_id_wth_neutron(k_id)
- self.vimconn.neutron.list_ports.assert_called_once()
self.vimconn.neutron.delete_port.assert_called_once_with(k_id)
self.vimconn.logger.error.assert_called_once_with(
"Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)"