Skip to content

Commit

Permalink
Add sla filter on deployment type (#23)
Browse files Browse the repository at this point in the history
* Remove outdated help text for timeout

* Added sla filter on deployment type
  • Loading branch information
maricaantonacci authored Mar 9, 2020
1 parent 2d1749b commit abbfa17
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def configure():

selected_tosca = request.args['selected_tosca']

slas = sla.get_slas(access_token, settings.orchestratorConf['slam_url'], settings.orchestratorConf['cmdb_url'])
slas = sla.get_slas(access_token, settings.orchestratorConf['slam_url'], settings.orchestratorConf['cmdb_url'], toscaInfo[selected_tosca]["deployment_type"])

app.logger.debug("Template: " + json.dumps(toscaInfo[selected_tosca]))

Expand Down
40 changes: 32 additions & 8 deletions app/sla.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,26 @@ def get_sla_extra_info(access_token, service_id, cmdb_url):

return sitename, endpoint, service_type, iam_enabled

def get_slas(access_token, slam_url, cmdb_url):
def is_enabling_services(deployment_type, service_type):

headers = {'Authorization': 'bearer %s' % (access_token)}
if deployment_type == "":
return True

if deployment_type == "CLOUD":
return True if service_type in [ "org.openstack.nova", "com.amazonaws.ec2" ] else False
elif deployment_type == "MARATHON":
return True if "eu.indigo-datacloud.marathon" in service_type else False
elif deployment_type == "CHRONOS":
return True if "eu.indigo-datacloud.chronos" in service_type else False
elif deployment_type == "QCG":
return True if service_type == "eu.deep.qcg" else False
else:
return True

def get_slas(access_token, slam_url, cmdb_url, deployment_type=""):


headers = {'Authorization': 'bearer %s' % access_token}

url = slam_url + "/preferences/" + session['organisation_name']

Expand All @@ -31,12 +48,19 @@ def get_slas(access_token, slam_url, cmdb_url):
response.raise_for_status()
slas = response.json()['sla']

filtered_slas = []
for i in range(len(slas)):
sitename, endpoint, service_type, iam_enabled = get_sla_extra_info(access_token,slas[i]['services'][0]['service_id'], cmdb_url)
slas[i]['service_id']=slas[i]['services'][0]['service_id']
slas[i]['service_type']=service_type
slas[i]['sitename']=sitename
slas[i]['endpoint']=endpoint
slas[i]['iam_enabled']=iam_enabled

return slas
if is_enabling_services(deployment_type, service_type):
slas[i]['service_id']=slas[i]['services'][0]['service_id']
slas[i]['service_type']=service_type
slas[i]['sitename']=sitename
slas[i]['endpoint']=endpoint
slas[i]['iam_enabled']=iam_enabled

filtered_slas.append(slas[i])


return filtered_slas

1 change: 0 additions & 1 deletion app/templates/advanced_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<label class="form-check-label" style="white-space: nowrap;" for="providerTimeout">Set deployment creation timeout (min) </label>
<input type="number" class="form-control" id="providerTimeout" name="extra_opts.providerTimeout" style="width: 4em; height: 30px" min="5" value="" disabled>
</div>
<small id="providerTimeoutHelp" class="form-text text-muted">Supported only for <strong>managed</strong> long-running service deployments</small>
</div>

<div class="form-check">
Expand Down
22 changes: 22 additions & 0 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ def loadToscaTemplates(directory):
return toscaTemplates


def getdeploymenttype(nodes):
deployment_type = ""
for (j, u) in nodes.items():
if deployment_type == "":
for (k, v) in u.items():
if k == "type" and v == "tosca.nodes.indigo.Compute":
deployment_type = "CLOUD"
break
if k == "type" and v == "tosca.nodes.indigo.Container.Application.Docker.Marathon":
deployment_type = "MARATHON"
break
if k == "type" and v == "tosca.nodes.indigo.Container.Application.Docker.Chronos":
deployment_type = "CHRONOS"
break
if k == "type" and v == "tosca.nodes.indigo.Qcg.Job":
deployment_type = "QCG"
break
return deployment_type

def extractToscaInfo(toscaDir, tosca_pars_dir, toscaTemplates):
toscaInfo = {}
for tosca in toscaTemplates:
Expand Down Expand Up @@ -78,6 +97,9 @@ def extractToscaInfo(toscaDir, tosca_pars_dir, toscaTemplates):

if 'inputs' in template['topology_template']:
toscaInfo[tosca]['inputs'] = template['topology_template']['inputs']

if 'node_templates' in template['topology_template']:
toscaInfo[tosca]['deployment_type'] = getdeploymenttype(template['topology_template']['node_templates'])

## add parameters code here
tabs = {}
Expand Down

0 comments on commit abbfa17

Please sign in to comment.