Skip to content

Commit

Permalink
fix: dev: SDK-364: Oracle Multi AD changes required in qds-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
chattarajoy committed Jul 29, 2019
1 parent c75e31f commit afd612a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ install:
# command to run tests
script: py.test
env: BOTO_CONFIG=/tmp/nowhere
dist: trusty
16 changes: 10 additions & 6 deletions qds_sdk/cloud/oracle_bmc_cloud.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from qds_sdk.cloud.cloud import Cloud
import json
import ast

class OracleBmcCloud(Cloud):
'''
Expand Down Expand Up @@ -112,11 +113,8 @@ def set_network_config(self,
self.network_config['subnet_id'] = subnet_id
self.network_config['compartment_id'] = compartment_id
self.network_config['image_id'] = image_id
if availability_domain_info_map and availability_domain_info_map.strip():
try:
self.network_config['availability_domain_info_map'] = json.loads(availability_domain_info_map.strip())
except Exception as e:
raise Exception("Invalid JSON string for availability domain info map: %s" % e.message)
if availability_domain_info_map:
self.network_config['availability_domain_info_map'] = availability_domain_info_map

def set_storage_config(self,
storage_tenant_id=None,
Expand All @@ -133,6 +131,12 @@ def set_storage_config(self,
self.storage_config['block_volume_size'] = block_volume_size

def set_cloud_config_from_arguments(self, arguments):
if arguments.availability_domain_info_map:
try:
arguments.availability_domain_info_map = ast.literal_eval(arguments.availability_domain_info_map)
assert isinstance(arguments.availability_domain_info_map, list)
except Exception as e:
raise Exception("Invalid List format for availability_domain_info_map: %s" % e.message)
self.set_cloud_config(compute_tenant_id=arguments.compute_tenant_id,
compute_user_id=arguments.compute_user_id,
compute_key_finger_print=arguments.compute_key_finger_print,
Expand Down Expand Up @@ -239,4 +243,4 @@ def create_parser(self, argparser):
dest="block_volume_size",
default=None,
help="size (in GB) of each block volume to be mounted to an instance",
type=int)
type=int)
6 changes: 3 additions & 3 deletions tests/test_clusterv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_oracle_bmc_network_config(self):
def test_oracle_bmc_network_config_az_info_map(self):
sys.argv = ['qds.py', '--version', 'v2', '--cloud', 'ORACLE_BMC', 'cluster', 'create', '--label', 'test_label',
'--compartment-id', 'abc-compartment', '--image-id', 'abc-image', '--vcn-id', 'vcn-1',
'--availability-domain-info-map', '{"availability_domain": "AD-1", "subnet_id": "subnet-1"}']
'--availability-domain-info-map', str([{"availability_domain": "AD-1", "subnet_id": "subnet-1"}])]
Qubole.cloud = None
print_command()
Connection._api_call = Mock(return_value={})
Expand All @@ -159,8 +159,8 @@ def test_oracle_bmc_network_config_az_info_map(self):
'compartment_id': 'abc-compartment',
'image_id': 'abc-image',
'availability_domain_info_map':
{'availability_domain': 'AD-1',
'subnet_id': 'subnet-1'}}},
[{'availability_domain': 'AD-1',
'subnet_id': 'subnet-1'}]}},
'cluster_info': {'label': ['test_label']}})

def test_oracle_bmc_location_config(self):
Expand Down

0 comments on commit afd612a

Please sign in to comment.