From 58bc7531608feb2792487400ebc4d894c1a95c2e Mon Sep 17 00:00:00 2001 From: Amey Bhide Date: Fri, 29 Jan 2016 16:16:42 -0800 Subject: [PATCH] [NSXv]: Push description to NSXv edge during creation For now, the description will be the neutron version Change-Id: Ia22ac1c33643d77c2bace92d2bc54e38cd41329d --- .../plugins/nsx_v/vshield/edge_appliance_driver.py | 12 +++++++++--- vmware_nsx/plugins/nsx_v/vshield/edge_utils.py | 10 +++++++--- .../tests/unit/nsx_v/vshield/test_edge_utils.py | 4 +++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py b/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py index efc13a407f..d6e17b85bd 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_appliance_driver.py @@ -45,7 +45,8 @@ class EdgeApplianceDriver(object): def _assemble_edge(self, name, appliance_size="compact", deployment_container_id=None, datacenter_moid=None, enable_aesni=True, dist=False, - enable_fips=False, remote_access=False): + enable_fips=False, remote_access=False, + description=None): edge = { 'name': name, 'fqdn': None, @@ -62,6 +63,9 @@ class EdgeApplianceDriver(object): 'applianceSize': appliance_size }, } + if description: + edge['description'] = description + if not dist: edge['type'] = "gatewayServices" edge['vnics'] = {'vnics': []} @@ -470,13 +474,15 @@ class EdgeApplianceDriver(object): def deploy_edge(self, resource_id, name, internal_network, jobdata=None, dist=False, wait_for_exec=False, loadbalancer_enable=True, - appliance_size=nsxv_constants.LARGE, async=True): + appliance_size=nsxv_constants.LARGE, async=True, + description=None): task_name = 'deploying-%s' % name edge_name = name edge = self._assemble_edge( edge_name, datacenter_moid=self.datacenter_moid, deployment_container_id=self.deployment_container_id, - appliance_size=appliance_size, remote_access=True, dist=dist) + appliance_size=appliance_size, remote_access=True, dist=dist, + description=description) appliance = self._assemble_edge_appliance(self.resource_pool_id, self.datastore_id) if appliance: diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index 97e40bb6df..9a58cfed48 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -30,6 +30,7 @@ from neutron.common import exceptions as n_exc from neutron import context as q_context from neutron.extensions import l3 from neutron.plugins.common import constants as plugin_const +from neutron import version from vmware_nsx._i18n import _, _LE, _LW from vmware_nsx.common import exceptions as nsx_exc @@ -137,7 +138,8 @@ class EdgeManager(object): lrouter['id'], lrouter['name'], internal_network=None, jobdata=jobdata, wait_for_exec=True, appliance_size=appliance_size, - dist=(edge_type == nsxv_constants.VDR_EDGE), async=async) + dist=(edge_type == nsxv_constants.VDR_EDGE), async=async, + description=version.version_info.release_string()) return task def _deploy_backup_edges_on_db(self, context, num, @@ -1395,7 +1397,8 @@ def create_lrouter(nsxv_manager, context, lrouter, lswitch=None, dist=False): # as we're not in a database transaction now task = nsxv_manager.deploy_edge( router_id, router_name, internal_network=None, - dist=dist, jobdata=jobdata, appliance_size=appliance_size) + dist=dist, jobdata=jobdata, appliance_size=appliance_size, + description=version.version_info.release_string()) task.wait(task_const.TaskState.RESULT) @@ -1427,7 +1430,8 @@ def create_dhcp_service(context, nsxv_manager, network): # Deploy an Edge for dhcp service return nsxv_manager.deploy_edge( network['id'], edge_name, nsx_network_id, jobdata=jobdata, - appliance_size=vcns_const.SERVICE_SIZE_MAPPING['dhcp']) + appliance_size=vcns_const.SERVICE_SIZE_MAPPING['dhcp'], + description=version.version_info.release_string()) def delete_dhcp_service(context, nsxv_manager, network_id): diff --git a/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py b/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py index 320d598aec..9f7f2dc925 100644 --- a/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py +++ b/vmware_nsx/tests/unit/nsx_v/vshield/test_edge_utils.py @@ -22,6 +22,7 @@ from neutron.common import exceptions as n_exc from neutron import context from neutron.plugins.common import constants as plugin_const from neutron.tests.unit import testlib_api +from neutron import version from vmware_nsx.common import nsxv_constants from vmware_nsx.db import nsxv_db from vmware_nsx.plugins.nsx_v.vshield.common import ( @@ -131,7 +132,8 @@ class EdgeUtilsTestCase(EdgeUtilsTestCaseMixin): 'lrouter': lrouter, 'lswitch': None, 'context': self.ctx}, - appliance_size=vcns_const.SERVICE_SIZE_MAPPING['router']) + appliance_size=vcns_const.SERVICE_SIZE_MAPPING['router'], + description=version.version_info.release_string()) class EdgeManagerTestCase(EdgeUtilsTestCaseMixin):