From 21b92b16d904371621302232570e67c02f392869 Mon Sep 17 00:00:00 2001 From: Luji7 Date: Mon, 31 Oct 2016 11:47:27 +0800 Subject: Fix Issue-Id: GSO-84 Change-Id: Ib786f58335f7f6700cc435c5ac6030d347f0f71d Signed-off-by: Luji7 --- .../src/main/webapp/lifecyclemgr/js/gsolcm.js | 76 ++++++++++++++++------ 1 file changed, 56 insertions(+), 20 deletions(-) (limited to 'openo-portal') diff --git a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js index 57643c8c..afc459c3 100644 --- a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js +++ b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js @@ -146,12 +146,14 @@ function fetchGsoTemplateInputParameters(templateId) { $.when( fetchTemplateParameterDefinitions(templateId), fetchGsoNestingTemplateParameters(templateId), - fetchVimInfo() + fetchVimInfo(), + fetchSdnController() ).then( - function (templateParameterResponse, nestingTempatesParas, vimInfoResponse) { + function (templateParameterResponse, nestingTempatesParas, vimInfoResponse, sdnControllersResponse) { var inputParas = concat(templateParameterResponse[0].inputs, nestingTempatesParas); var vims = translateToVimInfo(vimInfoResponse[0]); - templateParameters = translateToTemplateParameters(inputParas, vims); + var sdnControllers = translateToSdnControllers(sdnControllersResponse[0]); + templateParameters = translateToTemplateParameters(inputParas, vims, sdnControllers); defer.resolve(templateParameters); } ); @@ -205,7 +207,13 @@ function fetchGsoNestingTemplateParameters(templateId) { description: nodeTemplate.name + ' Location', required: 'true' }); - } + inputs.push({ + name: nodeTemplate.type + '.sdncontroller', + type: 'sdncontroller', + description: nodeTemplate.name + ' SDN Controller', + required: 'true' + }); + } nodeAggregatation.notify(inputs); } ); @@ -255,7 +263,7 @@ function pushAll(acc, array) { return result; } -function translateToTemplateParameters(inputs, vims) { +function translateToTemplateParameters(inputs, vims, controllers) { var inputParameters = []; var i; for (i = 0; i < inputs.length; i += 1) { @@ -269,17 +277,19 @@ function translateToTemplateParameters(inputs, vims) { value: inputs[i].defaultValue || '' }; } - return {changed: false, parameters: inputParameters, vimInfos: vims}; + return {changed: false, parameters: inputParameters, vimInfos: vims, sdnControllers: controllers}; } function fetchNfvoTemplateInputParameters(templateId) { var defer = $.Deferred(); $.when( fetchTemplateParameterDefinitions(templateId), - fetchVimInfo() + fetchVimInfo(), + fetchSdnController() ).then( - function (templateParameterResponse, vimInfoResponse) { + function (templateParameterResponse, vimInfoResponse, sdnControllerResponse) { var vims = translateToVimInfo(vimInfoResponse[0]); + var sdnControllers = translateToSdnControllers(sdnControllerResponse[0]); var inputParas = templateParameterResponse[0].inputs; inputParas.push({ name: 'location', @@ -287,7 +297,13 @@ function fetchNfvoTemplateInputParameters(templateId) { description: 'Location', required: 'true' }); - templateParameters = translateToTemplateParameters(inputParas, vims); + inputParas.push({ + name: 'sdncontroller', + type: 'sdncontroller', + description: 'SDN Controller', + required: 'true' + }); + templateParameters = translateToTemplateParameters(inputParas, vims, sdnControllers); defer.resolve(templateParameters); } ); @@ -300,7 +316,7 @@ function fetchSdnoTemplateInputParameters(templateId) { fetchTemplateParameterDefinitions(templateId) ).then( function (templateParameterResponse) { - templateParameters = translateToTemplateParameters(templateParameterResponse.inputs, []); + templateParameters = translateToTemplateParameters(templateParameterResponse.inputs, [], []); defer.resolve(templateParameters); } ); @@ -323,30 +339,50 @@ function fetchVimInfo() { }); } +function fetchSdnController() { + var sdnControllerUri = '/openoapi/extsys/v1/sdncontrollers'; + return $.ajax({ + type: "GET", + url: sdnControllerUri + }); +} + function translateToVimInfo(vims) { return vims.map(function (vim) { return { - vimId: vim.vimId, - vimName: vim.name + optionId: vim.vimId, + optionName: vim.name }; }); } +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 + generateLocationComponent(inputPara, vimInfos); - } else { + components = components + generateComboxComponent(inputPara, vimInfos); + } else if(inputPara.type === 'sdncontroller') { + components = components + generateComboxComponent(inputPara, sdnControllers); + } else { components = components + generateComponent(inputPara); } }); return components; } -function generateLocationComponent(inputPara, vimInfos) { +function generateComboxComponent(inputPara, items) { var component = '
' + '' + '
' + '
'; return component; } -function transformToOptions(vims) { +function transformToOptions(items) { var options = ''; var i; - for (i = 0; i < vims.length; i += 1) { - var option = ''; + for (i = 0; i < items.length; i += 1) { + var option = ''; options = options + option; } return options; -- cgit 1.2.3-korg