Merge "NSX|v HA: deploy edges on 2 datastores"

This commit is contained in:
Jenkins 2016-06-23 07:50:18 +00:00 committed by Gerrit Code Review
commit 561a3f0e34
5 changed files with 56 additions and 9 deletions

View File

@ -430,6 +430,10 @@ nsxv_opts = [
deprecated_group="vcns",
help=_('Optional parameter identifying the ID of datastore to '
'deploy NSX Edges')),
cfg.StrOpt('ha_datastore_id',
help=_('Optional parameter identifying the ID of datastore to '
'deploy NSX Edges in addition to data_store_id in case'
'edge_ha is True')),
cfg.StrOpt('external_network',
deprecated_group="vcns",
help=_('(Required) Network ID for physical network '

View File

@ -2983,7 +2983,10 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
inventory = [(cfg.CONF.nsxv.resource_pool_id,
'resource_pool_id'),
(cfg.CONF.nsxv.datastore_id,
'datastore_id')]
'datastore_id'),
(cfg.CONF.nsxv.ha_datastore_id,
'ha_datastore_id'),
]
# Treat the cluster list
for cluster in cfg.CONF.nsxv.cluster_moid:
inventory.append((cluster, 'cluster_moid'))

View File

@ -91,6 +91,17 @@ class EdgeApplianceDriver(object):
return edge
def _assemble_edge_appliances(self, resource_pool_id, datastore_id,
ha_datastore_id):
appliances = []
if datastore_id:
appliances.append(self._assemble_edge_appliance(
resource_pool_id, datastore_id))
if ha_datastore_id and cfg.CONF.nsxv.edge_ha:
appliances.append(self._assemble_edge_appliance(
resource_pool_id, ha_datastore_id))
return appliances
def _assemble_edge_appliance(self, resource_pool_id, datastore_id):
appliance = {}
if resource_pool_id:
@ -511,10 +522,11 @@ class EdgeApplianceDriver(object):
deployment_container_id=self.deployment_container_id,
appliance_size=appliance_size, remote_access=False, dist=dist)
res_pool = res_pool or self.resource_pool_id
appliance = self._assemble_edge_appliance(res_pool,
self.datastore_id)
if appliance:
edge['appliances']['appliances'] = [appliance]
appliances = self._assemble_edge_appliances(res_pool,
self.datastore_id,
self.ha_datastore_id)
if appliances:
edge['appliances']['appliances'] = appliances
if not dist:
vnic_external = self._assemble_edge_vnic(
@ -602,10 +614,11 @@ class EdgeApplianceDriver(object):
appliance_size=appliance_size, remote_access=False, dist=dist)
edge['id'] = edge_id
res_pool = res_pool or self.resource_pool_id
appliance = self._assemble_edge_appliance(res_pool,
self.datastore_id)
if appliance:
edge['appliances']['appliances'] = [appliance]
appliances = self._assemble_edge_appliances(res_pool,
self.datastore_id,
self.ha_datastore_id)
if appliances:
edge['appliances']['appliances'] = appliances
if not dist:
vnic_external = self._assemble_edge_vnic(

View File

@ -48,6 +48,7 @@ class VcnsDriver(edge_appliance_driver.EdgeApplianceDriver,
self.deployment_container_id = cfg.CONF.nsxv.deployment_container_id
self.resource_pool_id = cfg.CONF.nsxv.resource_pool_id
self.datastore_id = cfg.CONF.nsxv.datastore_id
self.ha_datastore_id = cfg.CONF.nsxv.ha_datastore_id
self.external_network = cfg.CONF.nsxv.external_network
self._pid = None
self._task_manager = None

View File

@ -17,6 +17,7 @@ from eventlet import greenthread
import mock
from neutron.tests import base
from oslo_config import cfg
import six
from vmware_nsx.plugins.nsx_v.vshield.common import (
@ -602,3 +603,28 @@ class VcnsDriverTestCase(base.BaseTestCase):
}
lswitch = self.vcns_driver.create_lswitch('lswitch', tz_config)
self.vcns_driver.delete_lswitch(lswitch['uuid'])
class VcnsDriverHATestCase(VcnsDriverTestCase):
def setUp(self):
# add edge_ha and ha_datastore to the pre-defined configuration
self._data_store = 'fake-datastore'
self._ha_data_store = 'fake-datastore-2'
cfg.CONF.set_override('ha_datastore_id', self._ha_data_store,
group="nsxv")
cfg.CONF.set_override('edge_ha', True, group="nsxv")
super(VcnsDriverHATestCase, self).setUp()
self.vcns_driver.vcns.orig_deploy = self.vcns_driver.vcns.deploy_edge
self.vcns_driver.vcns.deploy_edge = self._fake_deploy_edge
def _fake_deploy_edge(self, request, async=True):
# validate the appliance structure in the request,
# and return the regular (fake) response
found_app = request['appliances']['appliances']
self.assertEqual(len(found_app), 2)
self.assertEqual(found_app[0]['datastoreId'], self._data_store)
self.assertEqual(found_app[1]['datastoreId'], self._ha_data_store)
return self.vcns_driver.vcns.orig_deploy(request, async)