Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,9 @@ def _do_remove_vlan_actions(self, openstack_session, cp_resource_model, vlan_act
remove_results.append(action_result)

results += remove_results

# We should just remove subnet(s) and net from Openstack now (If any exception that gets logged)
# FIXME: Add synchronization here, when moved to a domain service.
self.network_service.remove_subnet_and_net(openstack_session=openstack_session,
network=net, logger=logger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ def remove_subnet_and_net(self, openstack_session, network, logger):
:return:
"""

# FIXME: What happens if multiple threads call this?
client = neutron_client.Client(session=openstack_session)

try:
# FIXME: This whole block should be synchronized.

for subnet in network['subnets']:
client.delete_subnet(subnet)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def get_instance_from_instance_id(self, openstack_session, instance_id, logger,
except Exception:
raise

# FIXME: Both the methods should return some kind of an object
# result: Success/Failure
# Error Message: To be displayed.
def attach_nic_to_net(self, openstack_session, instance_id, net_id, logger):
"""

Expand All @@ -205,6 +208,7 @@ def attach_nic_to_net(self, openstack_session, instance_id, net_id, logger):
iface_mac = res.to_dict().get('mac_addr')
iface_portid = res.to_dict().get('port_id')
iface_ip = res.to_dict().get('fixed_ips')[0]['ip_address']
# FIXME: return a json string (easier to access subsequently)
result = "/".join([iface_ip, iface_portid, iface_mac])
return result
except Exception as e:
Expand All @@ -221,10 +225,9 @@ def detach_nic_from_instance(self, openstack_session, instance_id, port_id, logg
:param LoggingSesssionContext logger:
:return bool: Success or Failure
"""


logger.info("Detaching port {0} from Instance {1}".format(port_id, instance_id))

instance = self.get_instance_from_instance_id(openstack_session=openstack_session,
instance_id=instance_id,
logger=logger)
Expand Down