accepting network and availability zone for instances in cluster
Standalone instance create call in trove already accepts neutron networks and availability zone information. In the similar manner, instances which are part of the cluster can now be supplied with a specific neutron network information and availability zone. This review is addressing the fix only for vertica datastore. Partial-Bug: #1447350 Change-Id: I5a1e9300dd0a16395769acda672943899f9ad0ad
This commit is contained in:
parent
f9583e5329
commit
c4946145cc
|
@ -152,12 +152,18 @@ class ClusterController(wsgi.Controller):
|
|||
instances = []
|
||||
for node in nodes:
|
||||
flavor_id = utils.get_id_from_href(node['flavorRef'])
|
||||
volume_size = nics = availability_zone = None
|
||||
if 'volume' in node:
|
||||
volume_size = int(node['volume']['size'])
|
||||
else:
|
||||
volume_size = None
|
||||
if 'nics' in node:
|
||||
nics = node['nics']
|
||||
if 'availability_zone' in node:
|
||||
availability_zone = node['availability_zone']
|
||||
|
||||
instances.append({"flavor_id": flavor_id,
|
||||
"volume_size": volume_size})
|
||||
"volume_size": volume_size,
|
||||
"nics": nics,
|
||||
"availability_zone": availability_zone})
|
||||
|
||||
cluster = models.Cluster.create(context, name, datastore,
|
||||
datastore_version, instances)
|
||||
|
|
|
@ -232,7 +232,9 @@ cluster = {
|
|||
"additionalProperties": True,
|
||||
"properties": {
|
||||
"flavorRef": flavorref,
|
||||
"volume": volume
|
||||
"volume": volume,
|
||||
"nics": nics,
|
||||
"availability_zone": non_empty_string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,6 +96,11 @@ class VerticaCluster(models.Cluster):
|
|||
|
||||
check_quotas(context.tenant, deltas)
|
||||
|
||||
nics = [instance.get('nics', None) for instance in instances]
|
||||
|
||||
azs = [instance.get('availability_zone', None)
|
||||
for instance in instances]
|
||||
|
||||
# Updating Cluster Task
|
||||
db_info = models.DBCluster.create(
|
||||
name=name, tenant_id=context.tenant,
|
||||
|
@ -106,16 +111,16 @@ class VerticaCluster(models.Cluster):
|
|||
"instance_type": "member"}
|
||||
|
||||
# Creating member instances
|
||||
for i in range(1, num_instances + 1):
|
||||
instance_name = "%s-member-%s" % (name, str(i))
|
||||
for i in range(0, num_instances):
|
||||
instance_name = "%s-member-%s" % (name, str(i + 1))
|
||||
inst_models.Instance.create(context, instance_name,
|
||||
flavor_id,
|
||||
datastore_version.image_id,
|
||||
[], [], datastore,
|
||||
datastore_version,
|
||||
volume_size, None,
|
||||
availability_zone=None,
|
||||
nics=None,
|
||||
nics=nics[i],
|
||||
availability_zone=azs[i],
|
||||
configuration_id=None,
|
||||
cluster_config=member_config)
|
||||
|
||||
|
|
|
@ -35,6 +35,19 @@ class TestClusterController(TestCase):
|
|||
def setUp(self):
|
||||
super(TestClusterController, self).setUp()
|
||||
self.controller = ClusterController()
|
||||
instances = [
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
"availability_zone": "az",
|
||||
"nics": [
|
||||
{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
|
||||
]
|
||||
}
|
||||
] * 5
|
||||
|
||||
self.cluster = {
|
||||
"cluster": {
|
||||
"name": "products",
|
||||
|
@ -42,38 +55,7 @@ class TestClusterController(TestCase):
|
|||
"type": "mongodb",
|
||||
"version": "2.4.10"
|
||||
},
|
||||
"instances": [
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
}
|
||||
]
|
||||
"instances": instances
|
||||
}
|
||||
}
|
||||
self.add_shard = {
|
||||
|
@ -170,11 +152,16 @@ class TestClusterController(TestCase):
|
|||
datastore = Mock()
|
||||
mock_get_datastore_version.return_value = (datastore,
|
||||
datastore_version)
|
||||
instances = [{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'}]
|
||||
instances = [
|
||||
{
|
||||
'volume_size': 1,
|
||||
'flavor_id': '1234',
|
||||
'availability_zone': 'az',
|
||||
'nics': [
|
||||
{'net-id': 'e89aa5fd-6b0a-436d-a75c-1545d34d5331'}
|
||||
]
|
||||
}
|
||||
] * 5
|
||||
mock_id_from_href.return_value = '1234'
|
||||
|
||||
mock_cluster = Mock()
|
||||
|
|
|
@ -33,6 +33,19 @@ class TestClusterController(trove_testtools.TestCase):
|
|||
def setUp(self):
|
||||
super(TestClusterController, self).setUp()
|
||||
self.controller = ClusterController()
|
||||
instances = [
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
"availability_zone": "az",
|
||||
"nics": [
|
||||
{"net-id": "e89aa5fd-6b0a-436d-a75c-1545d34d5331"}
|
||||
]
|
||||
}
|
||||
] * 3
|
||||
|
||||
self.cluster = {
|
||||
"cluster": {
|
||||
"name": "products",
|
||||
|
@ -40,26 +53,7 @@ class TestClusterController(trove_testtools.TestCase):
|
|||
"type": "vertica",
|
||||
"version": "7.1"
|
||||
},
|
||||
"instances": [
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
{
|
||||
"flavorRef": "7",
|
||||
"volume": {
|
||||
"size": 1
|
||||
},
|
||||
},
|
||||
]
|
||||
"instances": instances
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,9 +136,16 @@ class TestClusterController(trove_testtools.TestCase):
|
|||
datastore = Mock()
|
||||
mock_get_datastore_version.return_value = (datastore,
|
||||
datastore_version)
|
||||
instances = [{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'},
|
||||
{'volume_size': 1, 'flavor_id': '1234'}]
|
||||
instances = [
|
||||
{
|
||||
'volume_size': 1,
|
||||
'flavor_id': '1234',
|
||||
'availability_zone': 'az',
|
||||
'nics': [
|
||||
{'net-id': 'e89aa5fd-6b0a-436d-a75c-1545d34d5331'}
|
||||
]
|
||||
}
|
||||
] * 3
|
||||
mock_id_from_href.return_value = '1234'
|
||||
|
||||
mock_cluster = Mock()
|
||||
|
|
Loading…
Reference in New Issue