Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions src/cdpy/dw.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def gather_clusters(self, env_crn=None):
return out

def create_cluster(self, env_crn: str, overlay: bool, aws_public_subnets: list = None,
aws_private_subnets: list = None, az_subnet: str = None, az_enable_az: bool = None):
aws_private_subnets: list = None, az_subnet: str = None, az_enable_az: bool = None,
private_load_balancer: bool = None):
self.sdk.validate_crn(env_crn)
if all(x is not None for x in [aws_private_subnets, aws_private_subnets]):
aws_options = dict(publicSubnetIds=aws_public_subnets, privateSubnetIds=aws_private_subnets)
Expand All @@ -87,10 +88,57 @@ def create_cluster(self, env_crn: str, overlay: bool, aws_public_subnets: list =
azure_options = None
return self.sdk.call(
svc='dw', func='create_cluster', ret_field='clusterId', environmentCrn=env_crn,
useOverlayNetwork=overlay, awsOptions=aws_options, azureOptions=azure_options
useOverlayNetwork=overlay, usePrivateLoadBalancer=private_load_balancer,
awsOptions=aws_options, azureOptions=azure_options
)

def delete_cluster(self, cluster_id: str, force: bool = False):
return self.sdk.call(
svc='dw', func='delete_cluster', squelch=[Squelch('NOT_FOUND')], clusterId=cluster_id, force=force
)

def create_vw(self, cluster_id:str, dbc_id:str, vw_type:str, name:str, template:str = None,
autoscaling_min_cluster:int = None, autoscaling_max_cluster:int = None,
common_configs:dict = None, application_configs:dict = None, ldap_groups:list = None,
enable_sso:bool = None, tags:dict = None):
autoscaling = {}
if autoscaling_min_cluster != 0:
autoscaling['minClusters'] = autoscaling_min_cluster
if autoscaling_max_cluster != 0:
autoscaling['maxClusters'] = autoscaling_max_cluster

tag_list = []
for key,value in tags.items():
tag_list.append({'key': key, 'value': value})

config = {}
if not common_configs is None and not common_configs:
config['commonConfigs'] = common_configs
if not application_configs is None and not application_configs:
config['applicationConfigs'] = application_configs
if not ldap_groups is None and not ldap_groups:
config['ldapGroups'] = ldap_groups
if not enable_sso is None:
config['enableSSO'] = enable_sso

return self.sdk.call(
svc='dw', func='create_vw', ret_field='vwId', clusterId=cluster_id, dbcId=dbc_id,
vwType=vw_type, name=name, template=template, autoscaling=autoscaling,
config=config, tags=tag_list
)

def delete_vw(self, cluster_id:str, vw_id:str):
return self.sdk.call(
svc='dw', func='delete_vw', squelch=[Squelch('NOT_FOUND')], clusterId=cluster_id, vwId=vw_id
)

def create_dbc(self, cluster_id:str, name:str, load_demo_data: bool = None):
return self.sdk.call(
svc='dw', func='create_dbc', ret_field='dbcId', clusterId = cluster_id, name=name,
loadDemoData = load_demo_data
)

def delete_dbc(self, cluster_id:str, dbc_id:str):
return self.sdk.call(
svc='dw', func='delete_dbc', squelch=[Squelch('NOT_FOUND')], clusterId=cluster_id, dbcId=dbc_id
)