retrieve segmentation id from neutron networks
diff --git a/xos/core/admin.py b/xos/core/admin.py
index a0fd3cb..1c48477 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -2076,7 +2076,7 @@
verbose_name = "Controller Network"
suit_classes = 'suit-tab suit-tab-admin-only'
fields = ['backend_status_icon', 'controller',
- 'net_id', 'subnet_id', 'subnet']
+ 'net_id', 'subnet_id', 'subnet', 'segmentation_id']
readonly_fields = ('backend_status_icon', )
diff --git a/xos/core/models/network.py b/xos/core/models/network.py
index 8373814..b51ff27 100644
--- a/xos/core/models/network.py
+++ b/xos/core/models/network.py
@@ -203,6 +203,7 @@
router_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum router id")
subnet_id = models.CharField(null=True, blank=True, max_length=256, help_text="Quantum subnet id")
subnet = models.CharField(max_length=32, blank=True)
+ segmentation_id = models.IntegerField(null=True, blank=True)
class Meta:
unique_together = ('network', 'controller')
diff --git a/xos/synchronizers/openstack/steps/sync_controller_networks.py b/xos/synchronizers/openstack/steps/sync_controller_networks.py
index 5375a8d..d8c8a25 100644
--- a/xos/synchronizers/openstack/steps/sync_controller_networks.py
+++ b/xos/synchronizers/openstack/steps/sync_controller_networks.py
@@ -77,6 +77,22 @@
}
return network_fields
+ def update_neutron_attributes(self, controller_network):
+ # A bunch of stuff to compensate for OpenStackDriver.client_driveR()
+ # not being in working condition.
+ from openstack.client import OpenStackClient
+ from openstack.driver import OpenStackDriver
+ caller = controller_network.network.owner.creator
+ auth = {'username': caller.email,
+ 'password': caller.remote_password,
+ 'tenant': controller_network.network.owner.name}
+ client = OpenStackClient(controller=controller_network.controller, **auth)
+ driver = OpenStackDriver(client=client)
+
+ neutron_network = driver.shell.quantum.list_networks(controller_network.net_id)["networks"][0]
+ if "provider:segmentation_id" in neutron_network:
+ controller_network.segmentation_id = int(neutron_network["provider:segmentation_id"])
+
def map_sync_outputs(self, controller_network,res):
network_id = res[0]['id']
subnet_id = res[1]['id']
@@ -84,9 +100,9 @@
controller_network.subnet = self.cidr
controller_network.subnet_id = subnet_id
controller_network.backend_status = '1 - OK'
+ self.update_neutron_attributes(controller_network)
controller_network.save()
-
def map_sync_inputs(self, controller_network):
# XXX This check should really be made from booleans, rather than using hardcoded network names
#if (controller_network.network.template.name not in ['Private', 'Private-Indirect', 'Private-Direct', 'management_template'):