aboutsummaryrefslogtreecommitdiffstats
path: root/portal-lifecyclemgr/src/main
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2017-01-25 03:41:07 +0000
committerGerrit Code Review <gerrit@open-o.org>2017-01-25 03:41:07 +0000
commit8f7e7751c35e9821dfa316aed675bf79b564369d (patch)
tree320ad22a6a727ae80c8e669340dc080b850de759 /portal-lifecyclemgr/src/main
parenta3ff4d9efe123418be94f74587309a1842db3300 (diff)
parent6adc7511d2405362cda6cdcf8d7875ac60b10077 (diff)
Merge "Change the coding on the new sg framework"
Diffstat (limited to 'portal-lifecyclemgr/src/main')
-rw-r--r--portal-lifecyclemgr/src/main/webapp/lifecyclemgr/InputData.html31
-rw-r--r--portal-lifecyclemgr/src/main/webapp/lifecyclemgr/gsolcmmain.html37
-rw-r--r--portal-lifecyclemgr/src/main/webapp/lifecyclemgr/i18n/lcm-template-parameters-i18n-en-US.properties1
-rw-r--r--portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js1359
-rw-r--r--portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js49
5 files changed, 593 insertions, 884 deletions
diff --git a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/InputData.html b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/InputData.html
index 2f8a4c15..b0ebdee9 100644
--- a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/InputData.html
+++ b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/InputData.html
@@ -41,32 +41,7 @@
var jsonData = JSON.parse((params.get("json")));
if (jsonData != null) {
- $("body").empty();
- for(var key in jsonData.inputParameters){
- var name = key;
- if(name.includes('.'))
- {
- name = key.substring(key.lastIndexOf('.')+1,key.length);
- }
- var paramValue = jsonData.inputParameters[key];
- if(name.indexOf('location') != -1) {
- var vimObj = getVimNameById(paramValue);
- if(vimObj != undefined){
- paramValue = vimObj.name;
- }
- }
- else if(name.indexOf('sdncontroller') != -1){
- var sdnControllerObj = getSdnControllerNameById(paramValue);
- if(sdnControllerObj != undefined){
- paramValue = sdnControllerObj.name;
- }
- }
- else{
- var nameObj = {name:key,showName:key};
- name = showName(nameObj);
- }
- $("body").append('<div class="mT15 form-group row" style="margin-top:35px;margin-left:15%"><div class="col-sm-5" align="left"><label class="control-label"><span style="font-size:16px;">'+ name + '</span></label></div><div class="col-sm-1" align="left"><span style="font-size:16px;">:</span></div><div class="col-sm-6"><input type="text" name="" maxlength="256" style="margin-left:10px;width:250px;padding-left: 5px" data-toggle="tooltip" data-placement="top" title="'+ paramValue + '" value="'+ paramValue + '" readonly disabled/></div></div>');
- }
+ document.getElementById("parametersDetail").innerHTML = convertInputsToUI('', 'show', jsonData.inputParameters);
}
});
@@ -80,7 +55,9 @@
</head>
<body>
-
+<form class="form-horizontal" role="form">
+<div id="parametersDetail"></div>
+</form>
</body>
</html> \ No newline at end of file
diff --git a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/gsolcmmain.html b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/gsolcmmain.html
index 587f7ded..4d62f00c 100644
--- a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/gsolcmmain.html
+++ b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/gsolcmmain.html
@@ -34,6 +34,7 @@
<script type="text/javascript" src="js/jquery.bootstrap-growl.min.js"></script>
<script type="text/javascript" src="js/jquery.isloading.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.12.1.min.js"></script>
+ <script type="text/javascript" src="js/dialog-min.js"></script>
<link href="css/jquery-ui-1.12.1.min.css" rel="stylesheet" />
<script type="text/javascript" src="js/bootstrap-table-filter-control.min.js"></script>
<script type="text/javascript">
@@ -98,7 +99,7 @@
window.operateEvents = {
'click .siteDeleteImg': function (e, value, row, index) {
// TO DO ajex call for delete
- var result = deleteNe(row.id, row);
+ var result = deleteService(row.id, row);
}
};
@@ -601,7 +602,39 @@
<label class="openo-ellipsis " style="width: 100%; display: block; height: 20px;">Loopback</label>
</div>
</div>
-
+<div class="modal fade" id="progressDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header" style="margin-left:10px;margin-bottom:5px;">
+ <h4 class="modal-title" id="idProgressTitle" style="text-align:center;"></h4>
+ </div>
+ <div class="modal-body" style="margin-left:10px;margin-bottom:5px;margin-right:10px;">
+ <div class="progress">
+ <div id="progressbar" class="progress-bar" role="progressbar" style="width: 10%;">
+ <span id ="progressValue">0%</span>
+ </div>
+ </div>
+ <div id="progressContent"></div>
+ </div>
+ </div>
+ </div>
+</div>
+<div class="modal fade" id="errorDialog" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
+ <div class="modal-dialog">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal"
+ aria-hidden="true">×
+ </button>
+ <h4 class="modal-title" id="errorDialogTitle" style="text-align:center;"></h4>
+ </div>
+ <div class="modal-body" id = "errorDialogReason" style="margin-left:20px;margin-bottom:5px;margin-right:10px;"></div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">close</button>
+ </div>
+ </div>
+ </div>
+</div>
</body>
</html>
diff --git a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/i18n/lcm-template-parameters-i18n-en-US.properties b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/i18n/lcm-template-parameters-i18n-en-US.properties
index ffbcd699..2218a754 100644
--- a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/i18n/lcm-template-parameters-i18n-en-US.properties
+++ b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/i18n/lcm-template-parameters-i18n-en-US.properties
@@ -1,3 +1,4 @@
+domainHost=Domain
tosca.nodes.sdn.ext.NS.ns_underlayervpn.ac1_ip=Left AC
tosca.nodes.sdn.ext.NS.ns_underlayervpn.ac1_peer_ip=Left CE IP
tosca.nodes.sdn.ext.NS.ns_underlayervpn.ac1_port=Left Port
diff --git a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js
index 80f2eda3..0976d011 100644
--- a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js
+++ b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js
@@ -14,868 +14,613 @@
* limitations under the License.
*/
var templateParameters = {
- changed: true,
- parameters: [],
- vimInfos: []
+ changed : true,
+ // the create params used for ui
+ paramJsonObj : {}
};
-var lcmHandler = function () {
- this._addOwnEvents();
- jQuery.i18n.properties({
- language:'en-US',
- name:'lcm-template-parameters-i18n',
- path:'i18n/',
- mode:'map'
- });
+var lcmHandler = function() {
+ this._addOwnEvents();
+ jQuery.i18n.properties({
+ language : 'en-US',
+ name : 'lcm-template-parameters-i18n',
+ path : 'i18n/',
+ mode : 'map'
+ });
};
lcmHandler.prototype = {
- _addOwnEvents: function () {
- $('#createNS').click(this.okAction);
- },
- okAction: function () {
- if(!checkLocation(templateParameters.parameters)) {
- alert('Location must be selected in Template Parameters');
- return;
- }
- $.isLoading({ text: "Creating service..." });
- var serviceInstance = {
- serviceTemplateId: $("#svcTempl").val(),
- serviceName: $('#svcName').val(),
- description: $('#svcDesc').val(),
- inputParameters: collectServiceParameters(templateParameters.parameters)
- };
- var gatewayService = '/openoapi/servicegateway/v1/services';
- $.when(
- fetchServiceTemplateBy(serviceInstance.serviceTemplateId)
- ).then(
- function(template) {
- serviceInstance.templateName = template.name;
- serviceInstance.serviceType = template.serviceType;
- return createNetworkServiceInstance(template, serviceInstance, gatewayService);
- }
- ).then(
- function(response) {
- $.isLoading('hide');
- if(response.status === 'success') {
- updateTable(response.instance);
- $('#vmAppDialog').removeClass('in').css('display', 'none');
- } else {
- showErrorMessage('Create service failed', response.errorResult);
- }
- }
- );
- }
-};
-
-function showErrorMessage(title, result) {
- var info = '<br/>' + '<h5>' + title + '</h5><hr/>';
- info = info + '<h6>Status: ' + result.status + '</h6><p/>';
- info = info + '<h6>Description: </h6>';
- if(result.statusDescription.forEach === undefined) {
- info = info + '<h6>' + result.statusDescription + '</h6><p/>';
- } else {
- result.statusDescription.forEach(function(message) {
- info = info + '<h6>' + message + '</h6><p/>';
- });
- }
- info = info + '<h6>Error code: '+ result.errorCode + '</h6>';
- $.bootstrapGrowl(info, {
- type: 'danger',
- align: 'center',
- width: "auto",
- delay: 10000,
- allow_dismiss: true
- });
-}
-
-function checkLocation(parameters) {
- var checkPass = true;
- var i = 0;
- for(i = 0; i < parameters.length; i++) {
- if(parameters[i].type === 'location') {
- var value = $('#' + parameters[i].id).val();
- if(value === undefined || value === 'select') {
- checkPass = false;
- }
+ _addOwnEvents : function() {
+ $('#createNS').click(this.okAction);
+ },
+ okAction : function() {
+ if (!checkInputs('create', templateParameters.paramJsonObj)) {
+ return;
}
+ var sengMsgObj = collectCreateParamfromUI('', 'create', templateParameters.paramJsonObj);
+ var gatewayService = '/openoapi/servicegateway/v1/services';
+ $.when(createServiceInstance(sengMsgObj))
+ .then(function(response) {
+ if (response.status === 'finished') {
+ $.when(queryService()).then(function(serviceInstance){
+ $('#sai').bootstrapTable("append", serviceInstance);
+ });
+ $('#vmAppDialog').removeClass('in').css('display','none');
+ } else {
+ showErrorMessage('Create service failed',response);
+ }
+ });
}
- return checkPass;
-}
+};
+/**
+ * init parameter tab
+ * @returns
+ */
function initParameterTab() {
// Service template was not changed. Do not re-initiate the parameter tab.
- if (!templateParameters.changed) {
- return;
- }
- var templateId = $("#svcTempl").val();
- if ('select' === templateId) {
- document.getElementById("templateParameterTab").innerHTML = '';
- return;
- }
- $.when(
- fetchServiceTemplateBy(templateId)
- ).then(
- function(template) {
- if(template.serviceType === 'GSO') {
- return fetchGsoTemplateInputParameters(templateId, template);
- } else if(template.serviceType === 'NFVO') {
- return fetchNfvoTemplateInputParameters(templateId, template);
- } else if(template.serviceType === 'SDNO') {
- return fetchSdnoTemplateInputParameters(templateId, template);
- }
- }
- ).then(
- function(parameters) {
- var components = transformToComponents(parameters);
- document.getElementById("templateParameterTab").innerHTML = components;
- }
- );
-}
-
-function fetchServiceTemplateBy(templateId) {
- var defer = $.Deferred();
- var serviceTemplateUri = '/openoapi/catalog/v1/servicetemplates/' + templateId;
- var template = {};
- $.when(
- $.ajax({
- type: "GET",
- url: serviceTemplateUri,
- contentType: "application/json"
- })
- ).then(
- function(response) {
- template.name = response.templateName;
- template.gsarId = response.csarId;
- template.id = response.id;
- template.nodeType = '';
- return fetchCsar(template.gsarId);
- }
- ).then(
- function(response) {
- if(response.type === 'GSAR') {
- template.serviceType = 'GSO';
- } else if(response.type === 'NSAR' || response.type === 'NFAR') {
- template.serviceType = 'NFVO';
- } else if(response.type === 'SSAR') {
- template.serviceType = "SDNO";
- }
- defer.resolve(template)
- }
- );
- return defer;
-}
-
-function fetchCsar(csarId) {
- var queryCsarUri = '/openoapi/catalog/v1/csars/' + csarId;
- return $.ajax({
- type: "GET",
- url: queryCsarUri,
- contentType: "application/json"
+ if (!templateParameters.changed) {
+ return;
+ }
+ var templateId = $("#svcTempl").val();
+ if ('select' === templateId) {
+ document.getElementById("templateParameterTab").innerHTML = '';
+ return;
+ }
+ $.when(fetchCreateParameters(templateId))
+ .then(function(createParam) {
+ // set the create param object
+ templateParameters.paramJsonObj = createParam.parameters;
+ // convert the create param to UI.
+ var components = convertCreateParamsToUI('create', createParam.parameters);
+ document.getElementById("templateParameterTab").innerHTML = components;
+ templateParameters.changed = false;
});
}
-function fetchGsoTemplateInputParameters(templateId, template) {
- var defer = $.Deferred();
- $.when(
- fetchTemplateParameterDefinitions(templateId),
- fetchGsoNestingTemplateParameters(templateId),
- fetchVimInfo(),
- fetchSdnController()
- ).then(
- function (templateParameterResponse, nestingTempatesParas, vimInfoResponse, sdnControllersResponse) {
- var inputs = templateParameterResponse[0].inputs.map(function(input) {
- input.showName = input.name;
- if(template.nodeType === null || template.nodeType === undefined || template.nodeType.length === 0) {
- input.i18nKey = input.name;
- } else {
- input.i18nKey = template.nodeType + '.' +input.name;
- }
- return input;
- });
- var inputParas = concat(inputs, nestingTempatesParas);
- var vims = translateToVimInfo(vimInfoResponse[0]);
- var sdnControllers = translateToSdnControllers(sdnControllersResponse[0]);
- templateParameters = translateToTemplateParameters(inputParas, vims, sdnControllers);
- defer.resolve(templateParameters);
- }
- );
- return defer;
-}
-
-function fetchGsoNestingTemplateParameters(templateId) {
- var defer = $.Deferred();
- $.when(
- fetchNodeTemplates(templateId)
- ).then(
- function(nodeTemplates) {
- var count = nodeTemplates.length;
- if(count ===0) {
- defer.resolve([]);
- return;
- }
- var nestingParasAggregatation = aggregate(count, function(nestingParas) {
- defer.resolve(nestingParas);
- });
- nodeTemplates.forEach(function(nodeTemplate) {
- var nestingNodeUri = '/openoapi/catalog/v1/servicetemplates/nesting?nodeTypeIds=' + nodeTemplate.type;
- $.when(
- $.ajax({
- type: "GET",
- url: nestingNodeUri
- })
- ).then(
- function(serviceTemplates) {
- var nodeAggregatation = aggregate(serviceTemplates.length, function(oneNodeParameters) {
- nestingParasAggregatation.notify(oneNodeParameters);
- });
- serviceTemplates.forEach(function(serviceTemplate) {
- if(serviceTemplate === null || serviceTemplate === undefined || serviceTemplate.inputs === undefined || serviceTemplate.csarId === undefined)
- {
- nodeAggregatation.notify([]);
- return;
- }
- var inputs = serviceTemplate.inputs.map(function(input) {
- input.showName = input.name;
- input.name = nodeTemplate.type + '.' + input.name;
- input.i18nKey = nodeTemplate.type + '.' + input.name;
- return input;
- });
- $.when(
- fetchCsar(serviceTemplate.csarId)
- ).then(
- function(response) {
- if(response.type === 'NSAR' || response.type === 'NFAR') {
- inputs.push({
- name: nodeTemplate.type + '.location',
- type: 'location',
- description: nodeTemplate.name + ' Location',
- required: 'true',
- showName: nodeTemplate.name + ' Location',
- i18nKey: nodeTemplate.name + ' Location'
- });
- inputs.push({
- name: nodeTemplate.type + '.sdncontroller',
- type: 'sdncontroller',
- description: nodeTemplate.name + ' SDN Controller',
- required: 'true',
- showName: nodeTemplate.name + ' SDN Controller',
- i18nKey: nodeTemplate.name + ' SDN Controller'
- });
- }
- nodeAggregatation.notify(inputs);
- }
- );
- });
- }
- );
- });
- }
- );
- return defer;
-}
-
-function fetchNodeTemplates(templateId) {
- var nodeTemplateUri = '/openoapi/catalog/v1/servicetemplates/'+ templateId +'/nodetemplates';
+/**
+ * generate the template to create parameters object
+ *
+ * @param templateId
+ * the template id
+ * @returns
+ */
+function fetchCreateParameters(templateId) {
+ //return $.getJSON("./conf/queryCreateParams.json");
+ var uri = '/openoapi/servicegateway/v1/createparameters/' + templateId;
return $.ajax({
- type: "GET",
- url: nodeTemplateUri
+ type : "GET",
+ url : uri
});
}
-function aggregate(n, deferFun) {
- var aggregation = $.Deferred();
- var count = n;
- var result = [];
- aggregation.progress(function(array) {
- pushAll(result, array);
- count--;
- if(count === 0) {
- deferFun(result);
- }
+/**
+ * convert the template params obj to html UI string
+ *
+ * @param identify the object identify, it should be '' when called
+ * @return the html component string
+ */
+function convertCreateParamsToUI(identify, createParam) {
+ var components = '';
+ // convert host to UI
+ if (undefined != createParam.domainHost && 'enum' === createParam.domainHost.type) {
+ components = components
+ + generateParamComponent(createParam.nodeType, identify,
+ createParam.domainHost, false);
+ }
+ // convert own param to UI
+ createParam.additionalParamForNs
+ .forEach(function(param) {
+ components = components
+ + generateParamComponent(createParam.nodeType,
+ identify, param, false);
+ });
+ // convert segments to UI
+ createParam.segments.forEach(function(segment) {
+ // each segment in a field set.
+ components = components + '<fieldset style="margin-left:25px;"><legend>'
+ + segment.nodeTemplateName + '</legend>';
+ // the identify for segment
+ var segmentIdentify = '' == identify ? segment.nodeTemplateName
+ : identify + '_' + segment.nodeTemplateName;
+ // convert segment to UI
+ components = components
+ + convertCreateParamsToUI(segmentIdentify, segment);
+ components = components + '</fieldset>';
});
- return aggregation;
-}
-
-function concat(array1, array2) {
- var result = [];
- pushAll(result, array1);
- pushAll(result, array2);
- return result;
-}
-
-function pushAll(acc, array) {
- var result = acc;
- array.forEach(function(element) {
- result.push(element)
- })
- return result;
-}
-
-function translateToTemplateParameters(inputs, vims, controllers) {
- var inputParameters = [];
- var i;
- for (i = 0; i < inputs.length; i += 1) {
- inputParameters[i] = {
- name: inputs[i].name,
- type: inputs[i].type,
- description: inputs[i].description,
- defaultValue: inputs[i].defaultValue,
- required: inputs[i].required,
- id: 'parameters_' + i,
- value: inputs[i].defaultValue || '',
- showName: inputs[i].showName
- };
- }
- return {changed: false, parameters: inputParameters, vimInfos: vims, sdnControllers: controllers};
-}
-
-function fetchNfvoTemplateInputParameters(templateId, template) {
- var defer = $.Deferred();
- $.when(
- fetchTemplateParameterDefinitions(templateId),
- fetchVimInfo(),
- fetchSdnController()
- ).then(
- function (templateParameterResponse, vimInfoResponse, sdnControllerResponse) {
- var vims = translateToVimInfo(vimInfoResponse[0]);
- var sdnControllers = translateToSdnControllers(sdnControllerResponse[0]);
- var inputParas = templateParameterResponse[0].inputs;
- inputParas = inputParas.map(function(input) {
- input.showName = input.name;
- input.i18nKey = template.nodeType + '.' + input.name;
- return input;
- });
- inputParas.push({
- name: 'location',
- type: 'location',
- description: 'Location',
- required: 'true',
- showName: 'Location',
- i18nKey: 'Location'
- });
- inputParas.push({
- name: 'sdncontroller',
- type: 'sdncontroller',
- description: 'SDN Controller',
- required: 'true',
- showName: 'SDN Controller',
- i18nKey: 'SDN Controller'
- });
- templateParameters = translateToTemplateParameters(inputParas, vims, sdnControllers);
- defer.resolve(templateParameters);
- }
- );
- return defer;
+ return components;
}
-function fetchSdnoTemplateInputParameters(templateId, template) {
- var defer = $.Deferred();
- $.when(
- fetchTemplateParameterDefinitions(templateId)
- ).then(
- function (templateParameterResponse) {
- var inputs = templateParameterResponse.inputs.map(function(input) {
- input.showName = input.name;
- input.i18nKey = template.nodeType + '.' + input.name;
- return input;
- })
- templateParameters = translateToTemplateParameters(inputs, [], []);
- defer.resolve(templateParameters);
- }
- );
- return defer;
-}
-function fetchTemplateParameterDefinitions(templateId) {
- var queryParametersUri = '/openoapi/catalog/v1/servicetemplates/' + templateId + '/parameters';
- return $.ajax({
- type: "GET",
- url: queryParametersUri
- });
+/**
+ * for each required parameter it could not be empty
+ * @param identify the identify of a segment
+ * @param createParam the create param object
+ * @returns the check result
+ */
+function checkInputs(identify, createParam) {
+ //check domain host
+ if (undefined != createParam.domainHost && 'enum' === createParam.domainHost.type) {
+ var value = collectParamValue(identify, createParam.domainHost);
+ if ('select' == value) {
+ var name = getParamLabel(createParam.nodeType, createParam.domainHost);
+ alert( name + ' is required.')
+ return false;
+ }
+ }
+ // check parameters
+ for(var i= 0; i < createParam.additionalParamForNs.length; i++){
+ var param = createParam.additionalParamForNs[i];
+ var value = collectParamValue(identify, param);
+ if(param.required && ('' === value || ('enum' == param.type && 'select' == value))){
+ // the param resource key is nodeType.paramName
+ var name = getParamLabel(createParam.nodeType, param);
+ alert(name + ' is required.')
+ return false;
+ }
+ }
+ // get segments param value from UI
+ var segmentcheckResult = true;
+ for(var i= 0; i < createParam.segments.length; i++){
+ var segment = createParam.segments[i];
+ // the identify for segment
+ var segmentIdentify = '' == identify ? segment.nodeTemplateName
+ : identify + '_' + segment.nodeTemplateName;
+ segmentcheckResult = checkInputs(segmentIdentify, segment);
+ if (!segmentcheckResult) {
+ break;
+ }
+ }
+ return segmentcheckResult;
}
-function fetchVimInfo() {
- var vimQueryUri = '/openoapi/extsys/v1/vims';
- return $.ajax({
- type: "GET",
- url: vimQueryUri
- });
-}
-function fetchSdnController() {
- var sdnControllerUri = '/openoapi/extsys/v1/sdncontrollers';
- return $.ajax({
- type: "GET",
- url: sdnControllerUri
- });
-}
+/**
+ * convert the template params obj to html UI string
+ *
+ * @param identify the object identify, it should be different every time
+ * @return the html component string
+ */
+function collectCreateParamfromUI(parentHost,identify, createParam) {
+ // the create params used for create msg
+ var paramSentObj = {
+ domainHost:'',
+ nodeTemplateName:'',
+ nodeType:'',
+ segments:[],
+ additionalParamForNs:{}
+ };
+ // get the domain value
+ if (undefined != createParam.domainHost && 'enum' === createParam.domainHost.type) {
+ var domain = collectParamValue(identify, createParam.domainHost);
+ paramSentObj.domainHost = collectParamValue(identify, createParam.domainHost)
+ }
+ //if parent domainHost is not '' and local domain host is'', it should be setted as parent
+ if('' != parentHost && '' == paramSentObj.domainHost){
+ paramSentObj.domainHost = parentHost;
+ }
+ paramSentObj.nodeTemplateName = createParam.nodeTemplateName;
+ paramSentObj.nodeType = createParam.nodeType;
-function translateToVimInfo(vims) {
- return vims.map(function (vim) {
- return {
- optionId: vim.vimId,
- optionName: vim.name
- };
+ // get own param value from UI
+ createParam.additionalParamForNs.forEach(function(param) {
+ paramSentObj.additionalParamForNs[param.name] = collectParamValue(identify, param);
});
-}
-
-function translateToSdnControllers(controllers) {
- return controllers.map(function(controller) {
- return {
- optionId: controller.sdnControllerId,
- optionName: controller.name
- };
- });
-}
-
-function transformToComponents(templateParas) {
- var inputs = templateParas.parameters;
- var vimInfos = templateParas.vimInfos;
- var sdnControllers = templateParas.sdnControllers;
- var components = '';
- inputs.forEach(function (inputPara) {
- if(inputPara.type === 'location') {
- components = components + generateComboxComponent(inputPara, vimInfos);
- } else if(inputPara.type === 'sdncontroller') {
- components = components + generateComboxComponent(inputPara, sdnControllers);
- } else {
- components = components + generateComponent(inputPara);
- }
+ // get segments param value from UI
+ createParam.segments.forEach(function(segment) {
+ // the identify for segment
+ var segmentIdentify = '' == identify ? segment.nodeTemplateName
+ : identify + '_' + segment.nodeTemplateName;
+ var segmentObj = collectCreateParamfromUI(paramSentObj.domainHost, segmentIdentify, segment);
+ paramSentObj.segments.push(segmentObj);
});
- return components;
+ return paramSentObj;
}
-function generateComboxComponent(inputPara, items) {
- var component = '<div class="form-group" style="margin-left:25px;margin-bottom:15px;">' +
- '<label class="col-sm-3 control-label">' +
- '<span>'+ inputPara.showName +'</span>' +
- '<span class="required">*</span>' +
- '</label>' +
- '<div class="col-sm-7">' +
- '<select class="form-control" style ="padding-top: 0px;padding-bottom: 0px;"' +
- ' id="' + inputPara.id + '" name="'+ inputPara.name +'">' +
- transformToOptions(items) +
- '</select></div></div>';
- return component;
+/**
+ * get a param value
+ * @param identify the identify of a segment
+ * @param param the param object
+ * @returns the value of the param
+ */
+function collectParamValue(identify, param) {
+ var value = $('#' + getParamId(identify, param)).val();
+ return value;
}
-function transformToOptions(items) {
- var options = '<option value="select">--select--</option>';
- var i;
- for (i = 0; i < items.length; i += 1) {
- var option = '<option value="' + items[i].optionId + '">' + items[i].optionName + '</option>';
- options = options + option;
- }
- return options;
+/**
+ * get the param id in ui
+ * @param identify
+ * @param param
+ * @returns
+ */
+function getParamId(identify, param) {
+ return '' ===identify ? param.name : identify + '_' + param.name;
}
-function generateComponent(inputPara) {
- var component = '<div class="mT15 form-group" style="margin-left:25px;">' +
- '<label class="col-sm-3 control-label">' +
- '<span>' + showName(inputPara) + '</span>' + generateRequiredLabel(inputPara) +
- '</label>' +
- '<div class="col-sm-7">' +
- '<input type="text" id="' + inputPara.id + '" name="parameter description" class="form-control" placeholder="' +
- showName(inputPara) + '" value="' + inputPara.value + '" />' +
- '</div></div>';
- return component;
+/**
+ * get the resource string of a param.
+ * @param nodeType node type
+ * @param param param object
+ * @returns resource string
+ */
+function getParamLabel(nodeType, param) {
+ var name = $.i18n.prop(nodeType + '.' + param.name);
+ if (name.length === 0 || name.slice(0, 1) === '[') {
+ name = param.name;
+ }
+ return name;
+}
+/**
+ * convert combox component
+ *
+ * @param inputPara
+ * @param items
+ * @param stringReadOnly
+ * @returns
+ */
+function generateParamComponent(nodeType, identify, param, strReadOnly) {
+ // the param resource key is nodeType.paramName
+ var name = getParamLabel(nodeType, param);
+ var id = getParamId(identify,param);
+ var component = '';
+ if (param.type === 'string') {
+ component = '<div class="mT15 form-group" style="margin-left:0px;">'
+ + '<label class="col-sm-5 control-label">'
+ + '<span>' + name + '</span>' + generateRequiredLabel(param)
+ + '</label>'
+ + '<div class="col-sm-5"><input type="text" id="' + id
+ + '" name="parameter description" class="form-control" placeholder="'
+ + name + '" value="' + param.defaultValue;
+ if(strReadOnly){
+ component = component + '" readonly="' + strReadOnly + '"/>'+ '</div></div>';
+ }else{
+ component = component + '"/>'+ '</div></div>';
+ }
+
+ } else if (param.type === 'enum') {
+ component = '<div class="form-group" style="margin-left:0px;margin-bottom:5px;">'
+ + '<label class="col-sm-5 control-label">'
+ + '<span>' + name + '</span>'
+ + '<span class="required">*</span>'
+ + '</label>'
+ + '<div class="col-sm-5">'
+ + '<select class="form-control" style ="padding-top: 0px;padding-bottom: 0px;"'
+ + ' id="' + id + '" name="' + param.name + '" value="' + param.defaultValue
+ + '">'
+ + this.transformToOptions(param.range)
+ + '</select></div></div>';
+ }
+ return component;
}
-function showName(inputPara) {
- var name = $.i18n.prop(inputPara.name)
- if(name.length === 0 || name.slice(0, 1) === '[') {
- name = inputPara.showName;
- }
- return name;
+/**
+ * transfer the enum range to html body
+ * @param items the map of the range
+ * @returns the html string
+ */
+function transformToOptions(items) {
+ var options = '<option value="select">--select--</option>';
+ var i;
+ for ( var key in items) {
+ var option = '<option value="' + key + '">' + items[key] + '</option>';
+ options = options + option;
+ }
+ return options;
}
+/**
+ * generate required identify to html string
+ * @param parameter the parameter object
+ * @returns the html string
+ */
function generateRequiredLabel(parameter) {
- var requiredLabel = '';
- if (parameter.required === 'true') {
- requiredLabel = '<span class="required">*</span>';
- }
- return requiredLabel;
+ var requiredLabel = '';
+ if (parameter.required === 'true') {
+ requiredLabel = '<span class="required">*</span>';
+ }
+ return requiredLabel;
}
-function createNetworkServiceInstance(template, serviceInstance, gatewayService) {
- if (template.serviceType === 'GSO') {
- return createGsoServiceInstance(gatewayService, serviceInstance, template);
- } else if (template.serviceType === 'NFVO') {
- return createNfvoServiceInstance(gatewayService, serviceInstance, template);
- } else if (template.serviceType === 'SDNO') {
- return createSdnoServiceInstance(gatewayService, serviceInstance);
- }
+/**
+ * create service
+ * @param sengMsgObj the parameters
+ * @returns
+ */
+function createServiceInstance(sengMsgObj) {
+ var defer = $.Deferred();
+ var parameter = {
+ 'service' : {
+ 'name' : $('#svcName').val(),
+ 'description' : $('#svcDesc').val(),
+ 'serviceDefId' : '', //no need now, reserved
+ 'templateId' : $("#svcTempl").val(),
+ 'parameters' : sengMsgObj
+ }
+ };
+ var serviceGatewayUri = '/openoapi/servicegateway/v1/services';
+ $.when($.ajax({
+ type : "POST",
+ url : serviceGatewayUri,
+ contentType : "application/json",
+ dataType : "json",
+ data : JSON.stringify(parameter)
+ }))
+ .then(function(response) {
+ return queryProgress('create service', response.service.serviceId,response.service.operationId);
+ }).then(function(result){
+ defer.resolve(result);
+ });
+ return defer;
}
-function createGsoServiceInstance(gatewayService, serviceInstance, serviceTemplate) {
- var defer = $.Deferred();
- var gsoLcmUri = '/openoapi/gso/v1/services';
- var parameter = {
- 'service': {
- 'name': serviceInstance.serviceName,
- 'description': serviceInstance.description,
- 'serviceDefId': serviceTemplate.gsarId,
- 'templateId': serviceInstance.serviceTemplateId,
- 'templateName': serviceTemplate.name,
- 'gatewayUri': gsoLcmUri,
- 'parameters': serviceInstance.inputParameters
+/**
+ *
+ * @param rowId
+ * @param row
+ * @returns
+ */
+function deleteService(rowId, row) {
+ var deleteHandle = function(result) {
+ if (result) {
+ var serviceId = row.serviceId;
+ var remove = function() {
+ $('#sai').bootstrapTable('remove', {
+ field : 'serviceId',
+ values : [ serviceId ]
+ });
+ };
+ var failFun = function(responseDesc) {
+ $.isLoading("hide");
+ showErrorMessage("Delete service failed", responseDesc);
+ }
+ $.when(deleteServiceInstance(serviceId))
+ .then(function(response) {
+ if (response.status === 'finished') {
+ remove();
+ } else {
+ showErrorMessage('Create service failed',response);
+ }
+ });
+ ;
}
- };
- $.when($.ajax({
- type: "POST",
- url: gatewayService,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(parameter)
- })).then(function(response) {
- if(response.result.status === 'success') {
- serviceInstance.serviceId = response.serviceId;
- var gsoServiceUri = '/openoapi/gso/v1/services/' + response.serviceId;
- var timerDefer = $.Deferred();
- var timeout = 3600000;
- var fun = function() {
- if(timeout === 0) {
- timerDefer.resolve({
- status: 'fail',
- statusDescription: 'Operation is timeout!',
- errorCode: ''
- });
- return;
- }
- timeout = timeout - 1000;
- $.when(
- $.ajax({
- type: "GET",
- url: gsoServiceUri
- })
- ).then(
- function(response) {
- if(response.result === 'success' || response.result === 'failed') {
- timerDefer.resolve(response);
- }
- }
- );
- };
- var timerId = setInterval(fun, 1000);
- $.when(timerDefer).then(
- function(responseDesc) {
- clearInterval(timerId);
- if(responseDesc.result === 'success') {
- defer.resolve({status: 'success', instance: serviceInstance});
- } else {
- defer.resolve({
- status: 'fail',
- errorResult: {
- status: responseDesc.result,
- statusDescription: 'fail to create the service',
- errorCode: ''
- }});
- }
- }
- );
- } else {
- defer.resolve({status: 'fail', errorResult: {status:'fail', statusDescription: 'fail to create the service', errorCode: ''}});
- }
- });
- return defer;
-}
-
-function createNfvoServiceInstance(gatewayService, serviceInstance, template) {
- var nfvoLcmUri = '/openoapi/nslcm/v1';
- serviceInstance.nsdId = template.id;
- return createServiceInstance(gatewayService, nfvoLcmUri, serviceInstance);
-}
-
-function createSdnoServiceInstance(gatewayService, serviceInstance) {
- var sdnoLcmUri = '/openoapi/sdnonslcm/v1';
- serviceInstance.nsdId = serviceInstance.serviceTemplateId;
- return createServiceInstance(gatewayService, sdnoLcmUri, serviceInstance);
-}
-
-function createServiceInstance(gatewayService, lcmUri, serviceInstance) {
- var nsUri = lcmUri + '/ns';
- var defer = $.Deferred();
- var sParameter = {
- 'nsdId': serviceInstance.nsdId,
- 'nsName': serviceInstance.serviceName,
- 'description': serviceInstance.description,
- 'gatewayUri': nsUri
- };
- $.when($.ajax({
- type: "POST",
- url: gatewayService,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(sParameter)
- })).then(function(response) {
- if(response.result.status === 'success') {
- var nsInstanceId = response.serviceId;
- serviceInstance.serviceId = nsInstanceId;
- var initNsUrl = nsUri + '/' + nsInstanceId + '/instantiate';
- var parameter = {
- 'gatewayUri': initNsUrl,
- 'nsInstanceId': nsInstanceId,
- 'additionalParamForNs': serviceInstance.inputParameters
- };
- return $.ajax({
- type: "POST",
- url: gatewayService,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(parameter)
- });
- } else {
- return response;
- }
- }).then(function(response) {
- if(response.result.status === 'success') {
- var jobId = response.serviceId;
- var jobStatusUri = lcmUri + '/jobs/' + jobId;
- var timerDefer = $.Deferred();
- var timeout = 3600000;
- var fun = function() {
- if(timeout === 0) {
- timerDefer.resolve({
- status: 'fail',
- statusDescription: 'Operation is timeout!',
- errorCode: ''
- });
- return;
- }
- timeout = timeout - 1000;
- $.when(
- $.ajax({
- type: "GET",
- url: jobStatusUri
- })
- ).then(
- function(jobResponse) {
- var responseDesc = jobResponse.responseDescriptor;
- if(responseDesc.status === 'finished' || responseDesc.status === 'error') {
- timerDefer.resolve(responseDesc);
- }
- }
- );
- };
- var timerId = setInterval(fun, 1000);
- $.when(timerDefer).then(
- function(responseDesc) {
- clearInterval(timerId);
- if(responseDesc.status === 'finished') {
- defer.resolve({status: 'success', instance: serviceInstance});
- } else {
- defer.resolve({
- status: 'fail',
- errorResult: {
- status: responseDesc.status,
- statusDescription: responseDesc.statusDescription,
- errorCode: responseDesc.errorCode
- }});
- }
- }
- );
- } else {
- defer.resolve({status: 'fail', errorResult: response.result});
- }
- });
- return defer;
+ };
+ bootbox.confirm("Do you confirm to delete service?", deleteHandle);
}
-
-function collectServiceParameters(parameters) {
- var serviceParameters = {};
- var i;
- for (i = 0; i < parameters.length; i += 1) {
- var value = $('#' + parameters[i].id).val();
- serviceParameters[parameters[i].name] = value;
- }
- return serviceParameters;
+/**
+ * sent delete instance msg
+ * @param serviceId the service id
+ * @returns
+ */
+function deleteServiceInstance(serviceId) {
+ var defer = $.Deferred();
+ var deleteUrl = '/openoapi/servicegateway/v1/services/' + serviceId;
+ $.when($.ajax({
+ type : "DELETE",
+ url : deleteUrl,
+ contentType : "application/json",
+ dataType : "json",
+ data : JSON.stringify(parameter)
+ }))
+ .then(function(response) {
+ return queryProgress('delete service', serviceId,response.operationId);
+ }).then(function(result){
+ defer.resolve(result);
+ });
+ return defer;
}
-function updateTable(serviceInstance) {
- serviceInstance.createTime = formatDate(new Date());
- $('#sai').bootstrapTable("append", serviceInstance);
-}
+/**
+ * query progress of the operation
+ * @param operation the operation string
+ * @param serviceId the service id
+ * @param operationId the operation id
+ * @returns
+ */
+function queryProgress(operation, serviceId, operationId) {
+ //show the progress dialog
+ $( "#idProgressTitle" ).text(operation);
+ $( "#progressContent" ).text('status:');
+ $( "#progressbar" ).attr("style","width: 0%");
+ $( "#progressDialog" ).modal({backdrop:'static', keyboard:false});
+ //set a timer for query operation
+ var defer = $.Deferred();
+ var queryProgressUril = '/openoapi/servicegateway/v1/services/' + serviceId + '/operations/' + operationId;
+ var timerDefer = $.Deferred();
+ var timeout = 3600000;
+ var fun = function() {
+ if (timeout === 0) {
+ timerDefer.resolve({
+ status : 'error',
+ reason : operation + ' timeout!',
+ });
+ return;
+ }
+ timeout = timeout - 1000;
+ $.when($.ajax({
+ type : "GET",
+ url : gsoServiceUri
+ }))
+ .then(function(response) {
+ //update progress
+ $( "#progressbar" ).attr("style","width: " + response.operation.progress.toString() + "%");
+ $( "#progressValue" ).text(response.operation.progress.toString() + '%');
+ $( "#progressContent" ).text('status: ' + response.operation.operationContent);
+ if (response.operation.result == 'finished' || response.operation.result == 'error') {
+ timerDefer.resolve({
+ status : response.operation.result ,
+ reason : response.operation.reason
+ });
+ }
+ });
+ };
+ var timerId = setInterval(fun, 1000);
+ $.when(timerDefer)
+ .then(function(responseDesc) {
+ clearInterval(timerId);
+ $('#progressDialog').modal('hide');
+ defer.resolve({
+ status : responseDesc.status,
+ reason : responseDesc.reason,
+ serviceId:serviceId
+ });
-function formatDate(date) {
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hh = date.getHours();
- var mm = date.getMinutes();
- var ss = date.getSeconds();
- return year + "-" + month + "-" + day + " " + hh + ":" + mm + ":" + ss;
+ });
+ return defer;
}
-function deleteNe(rowId, row) {
- var deleteHandle = function(result) {
- if(result) {
- $.isLoading({ text: "Deleting service..." });
- var instanceId = row.serviceId;
- var serviceType = row.serviceType;
- var gatewayService = '/openoapi/servicegateway/v1/services/' + instanceId + '/terminate';
- var remove = function () {
- $.isLoading( "hide" );
- $('#sai').bootstrapTable('remove', {field: 'serviceId', values: [instanceId]});
- };
- var failFun = function(responseDesc) {
- $.isLoading( "hide" );
- showErrorMessage("Delete service failed", responseDesc);
- }
- if(serviceType === 'GSO') {
- deleteGsoServiceInstance(gatewayService, instanceId, remove, failFun);
- } else if (serviceType === 'NFVO') {
- var nfvoLcmUri = '/openoapi/nslcm/v1';
- deleteNonGsoServiceInstance(gatewayService, nfvoLcmUri, instanceId, remove, failFun);
- } else if (serviceType === 'SDNO') {
- var sdnoLcmUri = '/openoapi/sdnonslcm/v1';
- deleteNonGsoServiceInstance(gatewayService, sdnoLcmUri, instanceId, remove, failFun);
- }
- }
- };
- bootbox.confirm("Do you confirm to delete service?", deleteHandle);
-}
-function deleteGsoServiceInstance(gatewayService, instanceId, remove, failFun) {
- var gsoLcmUri = '/openoapi/gso/v1/services';
- $.when(
- deleteNetworkServiceInstance(gatewayService, gsoLcmUri, instanceId)
- ).then(
- function(response) {
- var gsoServiceUri = '/openoapi/gso/v1/services/toposequence/' + instanceId;
- var timerDefer = $.Deferred();
- var timeout = 3600000;
- var fun = function() {
- if(timeout === 0) {
- timerDefer.resolve({
- status: 'fail',
- statusDescription: 'Operation is timeout!',
- errorCode: ''
- });
- return;
- }
- timeout = timeout - 1000;
- $.when(
- $.ajax({
- type: "GET",
- url: gsoServiceUri
- })
- ).then(
- function(response) {
- if(response.length == 0) {
- timerDefer.resolve({status:'success', statusDescription: 'success to delete the service', errorCode: ''});
- }
- }
- );
- };
- var timerId = setInterval(fun, 1000);
- $.when(timerDefer).then(
- function(responseDesc) {
- clearInterval(timerId);
- remove();
- if(responseDesc.status != 'success'){
- failFun({status: "fail", statusDescription: "delete service failed.", errorCode: "500"});
- }
- }
- );
- }
- );
+/**
+ * convert the input parameters to ui
+ * @param identify the identify of a segment
+ * @param createParam the create param object
+ * @returns the check result
+ */
+function convertInputsToUI(parentHost, identify, serviceParam) {
+ var components = '';
+ // convert host to UI
+ if (undefined != serviceParam.domainHost && '' != serviceParam.domainHost && parentHost != serviceParam.domainHost) {
+ var param ={
+ name:'domainHost',
+ type:'string',
+ defaultValue:getShowVal('domainHost', serviceParam.domainHost),
+ required:false
+ }
+ components = components + generateParamComponent(serviceParam.nodeType, identify,
+ param, true);
+ }
+ // convert own param to UI
+ for(var key in serviceParam.additionalParamForNs ){
+ var param ={
+ name: key,
+ type:'string',
+ defaultValue:getShowVal(key, serviceParam.additionalParamForNs[key]),
+ required:false
+ }
+ components = components + generateParamComponent(serviceParam.nodeType,
+ identify, param, true);
+ }
+ // convert segments to UI
+ serviceParam.segments.forEach(function(segment) {
+ // each segment in a field set.
+ components = components + '<div class="mT15 form-group"><fieldset style="margin-left:25px;"><legend>'
+ + segment.nodeTemplateName + '</legend>';
+ // the identify for segment
+ var segmentIdentify = '' == identify ? segment.nodeTemplateName
+ : identify + '_' + segment.nodeTemplateName;
+ // convert segment to UI
+ components = components
+ + convertInputsToUI(serviceParam.domainHost, segmentIdentify, segment);
+ components = components + '</fieldset></div>';
+ });
+ return components;
}
-function deleteNonGsoServiceInstance(gatewayService, lcmUri, instanceId, remove, failFun) {
- var nsUri = lcmUri + '/ns';
- $.when(
- terminateNetworkServiceInstance(gatewayService, nsUri, instanceId)
- ).then(
- function(response) {
- var jobId = response.jobId;
- var jobStatusUri = lcmUri + '/jobs/' + jobId;
- var timerDefer = $.Deferred();
- var timeout = 3600000;
- var fun = function() {
- if(timeout === 0) {
- timerDefer.resolve({
- status: 'fail',
- statusDescription: 'Operation is timeout!',
- errorCode: ''
- });
- return;
- }
- timeout = timeout - 1000;
- $.when(
- $.ajax({
- type: "GET",
- url: jobStatusUri
- })
- ).then(
- function(jobResponse) {
- var responseDesc = jobResponse.responseDescriptor;
- if(responseDesc.status === 'finished' || responseDesc.status === 'error') {
- timerDefer.resolve(responseDesc);
- }
- }
- );
- };
- var timerId = setInterval(fun, 1000);
- $.when(timerDefer).then(
- function(responseDesc) {
- clearInterval(timerId);
- if(responseDesc.status === 'finished') {
- $.when(
- deleteNetworkServiceInstance(gatewayService, nsUri, instanceId)
- ).then(
- function(nsResponse) {
- if(nsResponse.status === 'success') {
- remove();
- } else {
- failFun(nsResponse);
- }
- }
- ).fail(function() {
- failFun({status: "fail", statusDescription: "delete service failed.", errorCode: "500"});
- });
- } else {
- failFun(responseDesc);
- }
- }
- );
- }
- ).fail(function() {
- failFun({status: "fail", statusDescription: "delete service failed.", errorCode: "500"});
- });
+function getShowVal(paramName, paramValue){
+ if(paramName == 'domainHost'){
+ return getHostNameByVal(paramValue);
+ }
+ else if(paramName == 'location'){
+ return getVimNameById(paramValue);
+ }
+ else if(paramName == 'sdncontroller'){
+ return getSdnControllerNameById(paramValue);
+ }
+ else{
+ return paramValue;
+ }
}
-function deleteNetworkServiceInstance(gatewayService, nsUri, instanceId) {
- var instanceUri = nsUri + '/' + instanceId;
- var parameter = {
- 'operation': "DELETE",
- 'gatewayUri': instanceUri
- };
- return $.ajax({
- type: "POST",
- url: gatewayService,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(parameter)
- });
+function getHostNameByVal(hostDomain){
+ var requestUrl ="/openoapi/servicegateway/v1/domains";
+ var returnObj = '';
+ $.ajax({
+ type : "GET",
+ async: false,
+ url : requestUrl,
+ contentType : "application/json",
+ success : function(jsonobj) {
+ jsonobj.forEach(function(host){
+ if(host.host == hostDomain){
+ returnObj = host.name;
+ }
+ });
+ },
+ error : function(xhr, ajaxOptions, thrownError) {
+ alert("Error on getting link data : " + xhr.responseText);
+ }
+ });
+ return returnObj;
+}
+
+//get the vim name by id.
+function getVimNameById(vimId){
+ var requestUrl ="/openoapi/extsys/v1/vims/" + vimId;
+ var returnObj;
+ $
+ .ajax({
+ type : "GET",
+ async: false,
+ url : requestUrl,
+ contentType : "application/json",
+ success : function(jsonobj) {
+ // TODO return according to the json data received.
+ returnObj = jsonobj;
+ },
+ error : function(xhr, ajaxOptions, thrownError) {
+ alert("Error on getting link data : " + xhr.responseText);
+ }
+ });
+ return returnObj;
+}
+
+//get the sdn controller name by id.
+function getSdnControllerNameById(sdnControllerId){
+ var requestUrl ="/openoapi/extsys/v1/sdncontrollers/" + sdnControllerId;
+ var returnObj;
+ $
+ .ajax({
+ type : "GET",
+ async: false,
+ url : requestUrl,
+ contentType : "application/json",
+ success : function(jsonobj) {
+ // TODO return according to the json data received.
+ returnObj = jsonobj;
+ },
+ error : function(xhr, ajaxOptions, thrownError) {
+ alert("Error on getting link data : " + xhr.responseText);
+ }
+ });
+ return returnObj;
+}
+
+
+
+/**
+ * show error dialog
+ * @param title the title
+ * @param result the result
+ * @returns
+ */
+function showErrorMessage(title, result) {
+ //show the error dialog
+ $( "#errorDialogTitle" ).text(title);
+ $( "#errorDialogReason" ).text(result.reason);
+ $( "#errorDialog" ).modal({backdrop:'static', keyboard:false});
}
-function terminateNetworkServiceInstance(gatewayService, nsUri, instanceId) {
- var instanceUri = nsUri + '/' + instanceId;
- var nsTerminateUri = instanceUri + '/terminate';
- var terminateParameter = {
- 'nsInstanceId': instanceId,
- 'terminationType': "graceful",
- 'gracefulTerminationTimeout': "60",
- 'operation': "POST",
- 'gatewayUri': nsTerminateUri
- };
- return $.ajax({
- type: "POST",
- url: gatewayService,
- contentType: "application/json",
- dataType: "json",
- data: JSON.stringify(terminateParameter)
- });
+/**
+ * generate the template to create parameters object
+ *
+ * @param templateId the template id
+ * @returns
+ */
+function queryService(serviceId) {
+ var uri = '/openoapi/servicegateway/v1/services/' + serviceId;
+ return $.ajax({
+ type : "GET",
+ url : uri
+ });
}
diff --git a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js
index 8c6fecdd..f7a01ea2 100644
--- a/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js
+++ b/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/rest.js
@@ -169,7 +169,7 @@ function translateToTemplatesInfo(templates) {
/*******************************************Get Service**********************************************/
function loadGetServiceData(){
- var returnVal;
+ var returnVal = [];
var requestUrl = "/openoapi/inventory/v1/services";
var parameter = {
'sort': [],
@@ -220,53 +220,6 @@ function loadServiceDetails(serviceId){
return returnObj;
}
-//get the vim name by id.
-function getVimNameById(vimId){
-
- // TODO re-confirm the latest url.
- var requestUrl ="/openoapi/extsys/v1/vims/" + vimId;
- var returnObj;
- $
- .ajax({
- type : "GET",
- async: false,
- url : requestUrl,
- contentType : "application/json",
- success : function(jsonobj) {
- // TODO return according to the json data received.
- returnObj = jsonobj;
- },
- error : function(xhr, ajaxOptions, thrownError) {
- alert("Error on getting link data : " + xhr.responseText);
- }
- });
- return returnObj;
-}
-
-// get the sdn controller name by id.
-function getSdnControllerNameById(sdnControllerId){
-
- // TODO re-confirm the latest url.
- var requestUrl ="/openoapi/extsys/v1/sdncontrollers/" + sdnControllerId;
- var returnObj;
- $
- .ajax({
- type : "GET",
- async: false,
- url : requestUrl,
- contentType : "application/json",
- success : function(jsonobj) {
- // TODO return according to the json data received.
- returnObj = jsonobj;
- },
- error : function(xhr, ajaxOptions, thrownError) {
- alert("Error on getting link data : " + xhr.responseText);
- }
- });
- return returnObj;
-}
-
-
function anchorClick(serviceId){
var jsonData = loadServiceDetails(serviceId);