diff options
Diffstat (limited to 'gui-clamp/ui-react')
22 files changed, 4902 insertions, 228 deletions
diff --git a/gui-clamp/ui-react/package.json b/gui-clamp/ui-react/package.json index 13d830e..ce2b071 100644 --- a/gui-clamp/ui-react/package.json +++ b/gui-clamp/ui-react/package.json @@ -97,6 +97,12 @@ ], [ "@babel/plugin-transform-runtime" + ], + [ + "@babel/plugin-proposal-private-methods", + { + "loose": true + } ] ] } diff --git a/gui-clamp/ui-react/src/api/ControlLoopService.js b/gui-clamp/ui-react/src/api/ControlLoopService.js index b3d987c..011d5ae 100644 --- a/gui-clamp/ui-react/src/api/ControlLoopService.js +++ b/gui-clamp/ui-react/src/api/ControlLoopService.js @@ -132,18 +132,6 @@ export default class ControlLoopService { return data; } - static async getToscaControlLoopDefinitions() { - - const response = await fetch(window.location.pathname + - 'restservices/clds/v2/toscaControlLoop/getElementDefinitions'); - - this.checkResponseForError(response); - - const data = await response; - - return data; - } - static async getCommonOrInstanceProperties(name, version, isCommon) { const params = { name: name, @@ -157,25 +145,4 @@ export default class ControlLoopService { return response; } - static async getToscaServiceTemplateSchema(section) { - - const params = { - section: section - } - - const response = await fetch(window.location.pathname + - 'restservices/clds/v2/toscaControlLoop/getJsonSchema' + '?' + (new URLSearchParams(params))); - - this.checkResponseForError(response); - - return response; - } - - static checkResponseForError(response) { - if (!response.ok) { - const message = `An error has occurred: ${ response.status }`; - throw new Error(message); - } - } - } diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ChangeOrderStateModal.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ChangeOrderStateModal.test.js new file mode 100644 index 0000000..4d288c6 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ChangeOrderStateModal.test.js @@ -0,0 +1,263 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React from 'react'; +import { mount, shallow } from 'enzyme'; +import toJson from "enzyme-to-json"; +import ChangeOrderStateModal from "./ChangeOrderStateModal"; +import { createMemoryHistory } from "history"; +import { act } from "react-dom/test-utils"; +import clLoopList from "./testFiles/controlLoopList.json"; +import orderedStateJson from "./testFiles/orderedStateJson.json"; +import ControlLoopService from "../../../api/ControlLoopService"; + +let logSpy = jest.spyOn(console, 'log') +const oldWindowLocation = window.location +describe('Verify ChangeOrderStateModal', () => { + const flushPromises = () => new Promise(setImmediate); + + beforeEach(() => { + logSpy.mockClear() + }) + + afterAll(() => { + window.location = oldWindowLocation + }) + + beforeAll(() => { + jest + .spyOn(global, 'fetch') + .mockImplementation(() => { + return { + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(orderedStateJson) + } + } + } + ) + + + delete window.location + + // create a new `window.location` object that's *almost* + // like the real thing + window.location = Object.defineProperties( + // start with an empty object on which to define properties + {}, + { + // grab all of the property descriptors for the + // `jsdom` `Location` object + ...Object.getOwnPropertyDescriptors(oldWindowLocation), + instantiationName: { + configurable: true, + value: "PMSH_Instance1", + }, + instantiationVersion: { + configurable: true, + value: "2.3.1", + } + }, + ) + }) + + it("renders without crashing", () => { + act(() => { + shallow(<ChangeOrderStateModal location={window.location}/>); + }) + }); + + it("renders correctly", () => { + act(() => { + const tree = shallow(<ChangeOrderStateModal location={window.location}/>); + expect(toJson(tree)).toMatchSnapshot(); + }) + }); + + it('should have two Button elements', () => { + act(() => { + const container = shallow(<ChangeOrderStateModal location={window.location}/>) + expect(container.find('Button').length).toEqual(2); + }) + }); + + it('should have one dropdown element', () => { + act(() => { + const container = shallow(<ChangeOrderStateModal location={ window.location }/>) + expect(container.find('Dropdown').length).toEqual(1); + }); + }); + + it('handleDropSelect called when dropdown clicked', () => { + const history = createMemoryHistory(); + const component = mount(<ChangeOrderStateModal history={ history } location={window.location}/>) + + act(() => { + component.find('Dropdown').get(0).props.onSelect(); + expect(logSpy).toHaveBeenCalledWith('handleDropDownChange called'); + }); + + component.unmount(); + }); + + it('handleClose called when bottom button clicked', () => { + const history = createMemoryHistory(); + const component = mount(<ChangeOrderStateModal history={ history } location={window.location}/>) + + act(() => { + component.find('[variant="secondary"]').simulate('click'); + expect(logSpy).toHaveBeenCalledWith('handleClose called'); + }); + + component.unmount(); + }); + + it('handleClose called when top-right button clicked', () => { + const history = createMemoryHistory(); + const component = mount(<ChangeOrderStateModal history={ history } location={window.location}/>) + + act(() => { + component.find('[size="sm"]').get(0).props.onHide(); + expect(logSpy).toHaveBeenCalledWith('handleClose called'); + }); + + component.unmount(); + }); + + it('handleSave called when save button clicked and response is ok', async () => { + jest.resetAllMocks() + const getInstanceOrderStateSpy = jest.spyOn(ControlLoopService, 'getInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(orderedStateJson) + } + }) + } + ) + + const changeInstanceOrderStateSpy = jest.spyOn(ControlLoopService, 'changeInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(clLoopList) + } + }) + } + ) + + const component = mount(<ChangeOrderStateModal location={window.location}/>) + + await act( async () => { + component.find('[variant="primary"]').simulate('click'); + await expect(getInstanceOrderStateSpy).toHaveBeenCalled() + await expect(changeInstanceOrderStateSpy).toHaveBeenCalled() + expect(logSpy).toHaveBeenNthCalledWith(1,"handleSave called"); + expect(logSpy).toHaveBeenNthCalledWith(2,"successAlert called"); + // await expect(logSpy).toHaveBeenCalledTimes(2); + }); + }); + + it('handleSave called when save button clicked and response is not ok', async () => { + jest.resetAllMocks() + const getInstanceOrderStateSpy = jest.spyOn(ControlLoopService, 'getInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(orderedStateJson) + } + }) + } + ) + + const changeInstanceOrderStateSpy = jest.spyOn(ControlLoopService, 'changeInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: false, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(clLoopList) + } + }) + } + ) + + const component = mount(<ChangeOrderStateModal location={window.location}/>) + + await act( async () => { + component.find('[variant="primary"]').simulate('click'); + await expect(getInstanceOrderStateSpy).toHaveBeenCalled() + await expect(changeInstanceOrderStateSpy).toHaveBeenCalled() + expect(logSpy).toHaveBeenNthCalledWith(1,"handleSave called"); + expect(logSpy).toHaveBeenNthCalledWith(2,"errorAlert called"); + // await expect(logSpy).toHaveBeenCalledTimes(2); + }); + }); + + it('Check useEffect is being called', async () => { + jest.resetAllMocks() + jest.spyOn(ControlLoopService, 'getInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(orderedStateJson) + } + }) + } + ) + + jest.spyOn(ControlLoopService, 'changeInstanceOrderState') + .mockImplementationOnce(() => { + return Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(clLoopList) + } + }) + } + ) + + const component = mount(<ChangeOrderStateModal location={window.location}/>) + + const useEffect = jest.spyOn(React, "useEffect"); + await act(async () => { + await flushPromises() + component.update() + await expect(useEffect).toHaveBeenCalled(); + }) + component.unmount(); + }); +}); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.js index fc150ef..b3b76c1 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.js @@ -21,9 +21,9 @@ import Modal from "react-bootstrap/Modal"; import Button from "react-bootstrap/Button"; import React, { useEffect, useState } from "react"; import styled from "styled-components"; -import { JSONEditor } from "@json-editor/json-editor"; import ControlLoopService from "../../../api/ControlLoopService"; import { Alert } from "react-bootstrap"; +import CommissioningUtils from "./utils/CommissioningUtils"; const ModalStyled = styled(Modal)` @media (min-width: 800px) { @@ -81,7 +81,12 @@ const CommissioningModal = (props) => { } if (toscaTemplateResponse.ok && toscaCommonProperties.ok) { - await renderJsonEditor(toscaTemplateResponse, toscaCommonProperties) + const renderedEditorObjects = CommissioningUtils.renderJsonEditor(toscaTemplateResponse, toscaCommonProperties) + setFullToscaTemplate((await renderedEditorObjects).fullTemplate) + setToscaJsonSchema((await renderedEditorObjects).propertySchema) + setJsonEditor((await renderedEditorObjects).editorTemp) + setToscaInitialValues((await renderedEditorObjects).toscaInitialValues) + } }, []); @@ -92,176 +97,31 @@ const CommissioningModal = (props) => { props.history.push('/'); } - const handleSave = () => { - updateTemplate(jsonEditor.getValue()) + const handleSave = async () => { + console.log("handleSave called") + if (jsonEditor != null) { + setFullToscaTemplate(await CommissioningUtils.updateTemplate(jsonEditor.getValue(), fullToscaTemplate)) + } } const handleCommission = async () => { + console.log("handleCommission called") + await ControlLoopService.deleteToscaTemplate('ToscaServiceTemplateSimple', "1.0.0") - .catch(error => error.message) const recommissioningResponse = await ControlLoopService.uploadToscaFile(fullToscaTemplate) - .catch(error => error.message) await receiveResponseFromCommissioning(recommissioningResponse) } const receiveResponseFromCommissioning = async (response) => { - - if (await response.ok) { - setAlertMessages(<Alert variant="success"> - <Alert.Heading>Commissioning Success</Alert.Heading> - <p>Altered Template was Successfully Uploaded</p> - <hr/> - </Alert>); - } - else { - setAlertMessages(<Alert variant="danger"> - <Alert.Heading>Commissioning Failure</Alert.Heading> - <p>Updated Template Failed to Upload</p> - <p>Status code: { await response.status }: { response.statusText }</p> - <p>Response Text: { await response.text() }</p> - <hr/> - </Alert>); - } + console.log("receiveResponseFromCommissioning called") + setAlertMessages(await CommissioningUtils.getAlertMessages(response)); }; - const renderJsonEditor = async (template, commonProps) => { - - const fullTemplate = await template.json() - - setFullToscaTemplate(fullTemplate) - const allNodeTemplates = fullTemplate.topology_template.node_templates - const shortenedNodeTemplatesObjectStartValues = {} - // Get the common properties to construct a schema - // Get valid start values at the same time - const commonNodeTemplatesJson = await commonProps.json().then(data => { - const nodeTemplatesArray = Object.entries(data) - const shortenedNodeTemplatesObject = {} - nodeTemplatesArray.forEach(([key, temp]) => { - const currentNodeTemplate = allNodeTemplates[key] - const propertiesObject = { - properties: temp.properties - } - - shortenedNodeTemplatesObject[key] = propertiesObject - - const propertiesStartValues = {} - - // Get all the existing start values to populate the properties in the schema - Object.entries(propertiesObject.properties).forEach(([propKey, prop]) => { - propertiesStartValues[propKey] = currentNodeTemplate.properties[propKey] - }) - - shortenedNodeTemplatesObjectStartValues[key] = propertiesStartValues - - }) - - setToscaInitialValues(shortenedNodeTemplatesObjectStartValues) - return shortenedNodeTemplatesObject; - }) - - const propertySchema = makeSchemaForCommonProperties(commonNodeTemplatesJson) - setToscaJsonSchema(propertySchema) - - editorTemp = createJsonEditor(propertySchema, shortenedNodeTemplatesObjectStartValues); - setJsonEditor(editorTemp) - } - - const updateTemplate = (userAddedCommonPropValues) => { - const nodeTemplates = fullToscaTemplate.topology_template.node_templates - const commonPropertyDataEntries = Object.entries(userAddedCommonPropValues) - - // This replaces the values for properties in the full tosca template - // that will be sent up to the api with the entries the user provided. - commonPropertyDataEntries.forEach(([templateKey, values]) => { - Object.entries(values).forEach(([propKey, propVal]) => { - nodeTemplates[templateKey].properties[propKey] = propVal - }) - }) - - fullToscaTemplate.topology_template.node_templates = nodeTemplates - - setFullToscaTemplate(fullToscaTemplate) - alert('Changes saved. Commission When Ready...') - } - - const makeSchemaForCommonProperties = (commonProps) => { - const commonPropsArr = Object.entries(commonProps) - - const newSchemaObject = {} - - newSchemaObject.title = "CommonProperties" - newSchemaObject.type = "object" - newSchemaObject.properties = {} - - commonPropsArr.forEach(([templateKey, template]) => { - - const propertiesObject = {} - Object.entries(template.properties).forEach(([propKey, prop]) => { - - propertiesObject[propKey] = { - type: getType(prop.type) - } - - }) - newSchemaObject.properties[templateKey] = { - options: { - "collapsed": true - }, - properties: propertiesObject - } - }) - - return newSchemaObject - - } - - const getType = (propertyType) => { - switch (propertyType) - { - case "string": - return "string" - case "integer": - return "integer" - case "list": - return "array" - case "object": - return "object" - default: - return "object" - } - } - - const createJsonEditor = (toscaModel, editorData) => { - JSONEditor.defaults.options.collapse = false; - - return new JSONEditor(document.getElementById("editor"), - { - schema: toscaModel, - startval: editorData, - theme: 'bootstrap4', - iconlib: 'fontawesome5', - object_layout: 'normal', - disable_properties: false, - disable_edit_json: true, - disable_array_reorder: true, - disable_array_delete_last_row: true, - disable_array_delete_all_rows: false, - array_controls_top: true, - keep_oneof_values: false, - collapsed: false, - show_errors: 'always', - display_required_only: false, - show_opt_in: false, - prompt_before_delete: true, - required_by_default: false, - }) - } - return ( <ModalStyled size="xl" show={ show } diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.test.js index 054450c..5ace94d 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/CommissioningModal.test.js @@ -17,16 +17,38 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - import React from 'react'; import { mount, shallow } from 'enzyme'; -import ReadAndConvertYaml from './ReadAndConvertYaml'; import toJson from "enzyme-to-json"; import { act } from "react-dom/test-utils"; import { createMemoryHistory } from "history"; import CommissioningModal from "./CommissioningModal"; +import commonProps from "./testFiles/commonProps.json"; +import fullTemp from "./testFiles/fullTemplate.json"; +import ControlLoopService from "../../../api/ControlLoopService"; + +let logSpy = jest.spyOn(console, 'log') +const commonProperties = JSON.parse(JSON.stringify(commonProps)) +const fullTemplate = JSON.parse(JSON.stringify(fullTemp)) +describe('Verify CommissioningModal', () => { + + const unmockedFetch = global.fetch + beforeAll(() => { + global.fetch = () => + Promise.resolve({ + status: 200, + text: () => "OK", + json: () => "{GlobalFetch}" + }) + }) -describe('Verify ReadAndConvertYaml', () => { + afterAll(() => { + global.fetch = unmockedFetch + }) + + beforeEach(() => { + logSpy.mockClear() + }) it("renders without crashing", () => { shallow(<CommissioningModal/>); @@ -45,25 +67,164 @@ describe('Verify ReadAndConvertYaml', () => { it('handleClose called when bottom button clicked', () => { const history = createMemoryHistory(); const component = mount(<CommissioningModal history={ history }/>) - const logSpy = jest.spyOn(console, 'log'); + // const logSpy = jest.spyOn(console, 'log'); act(() => { component.find('[variant="secondary"]').simulate('click'); expect(logSpy).toHaveBeenCalledWith('handleClose called'); }); + + component.unmount(); }); it('handleClose called when top-right button clicked', () => { const history = createMemoryHistory(); const component = mount(<CommissioningModal history={ history }/>) - const logSpy = jest.spyOn(console, 'log'); - act(() => { component.find('[size="xl"]').get(0).props.onHide(); expect(logSpy).toHaveBeenCalledWith('handleClose called'); }); + + component.unmount(); + }); + + it('handleSave called when save button clicked', () => { + const component = shallow(<CommissioningModal/>) + act(() => { + component.find('[variant="primary"]').simulate('click'); + expect(logSpy).toHaveBeenCalledWith("handleSave called"); + }); + }); + + it('getToscaTemplate gets called in useEffect with error', async() => { + const fetchMock = jest.spyOn(ControlLoopService, 'getToscaTemplate').mockImplementation(() => Promise.resolve({ + ok: false, + status: 200, + text: () => "OK", + json: () => fullTemplate + })) + + mount(<CommissioningModal/>) + await act(async () => { + expect(fetchMock).toHaveBeenCalled(); + }); }); + it('getCommonProperties gets called in useEffect with error', async() => { + const fetchMock = jest.spyOn(ControlLoopService, 'getToscaTemplate').mockImplementation(() => Promise.resolve({ + ok: false, + status: 200, + text: () => "OK", + json: () => commonProperties + })) + + mount(<CommissioningModal/>) + await act(async () => { + expect(fetchMock).toHaveBeenCalled(); + }); + }); + + it('useState gets called in useEffect with error', async() => { + const useStateSpy = jest.spyOn(React, 'useState') + jest + .spyOn(global, 'fetch') + .mockImplementation(() => + Promise.resolve({ + ok: false, + status: 200, + text: () => "OK", + json: () => "{useState}" + }) + ) + + mount(<CommissioningModal/>) + await act(async () => { + expect(useStateSpy).toHaveBeenCalledTimes(6); + }); + }); + + it('set state gets called for setFullToscaTemplate', () => { + const setFullToscaTemplate = jest.fn(); + const history = createMemoryHistory(); + jest + .spyOn(global, 'fetch') + .mockImplementation(() => + Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => fullTemplate + }) + ) + + mount(<CommissioningModal history={ history }/>) + act(async () => { + // expect(renderJsonEditor).toHaveBeenCalled(); + expect(setFullToscaTemplate).toHaveBeenCalledTimes(1); + }); + }); + + it('set state gets called for setToscaJsonSchema useEffect on success', () => { + const setToscaJsonEditor = jest.fn(); + const history = createMemoryHistory(); + jest + .spyOn(global, 'fetch') + .mockImplementation(() => + Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => fullTemplate + }) + ) + + mount(<CommissioningModal history={ history }/>) + act(async () => { + // expect(renderJsonEditor).toHaveBeenCalled(); + expect(setToscaJsonEditor).toHaveBeenCalledTimes(1); + }); + }); + + it('Check useEffect is being called', async () => { + const useEffect = jest.spyOn(React, "useEffect"); + mount(<CommissioningModal/>) + await act(async () => { + expect(useEffect).toHaveBeenCalled(); + }) + }); + + it('test handleCommission called on click', async () => { + const deleteToscaTemplateSpy = jest.spyOn(ControlLoopService, 'deleteToscaTemplate').mockImplementation(() => { + Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => "{handleCommissioning}" + }) + }) + const uploadToscaTemplateSpy = jest.spyOn(ControlLoopService, 'uploadToscaFile').mockImplementation(() => { + Promise.resolve({ + ok: true, + status: 200, + text: () => "OK", + json: () => "{uploadToscaFile}" + }) + }) + + + const useStateSpy = jest.spyOn(React, 'useState') + + const component = shallow(<CommissioningModal/>) + component.find('[variant="success mr-auto"]').simulate('click'); + + await act( async () => { + expect(logSpy).toHaveBeenCalledWith("handleCommission called") + expect(await deleteToscaTemplateSpy).toHaveBeenCalled() + expect(await uploadToscaTemplateSpy).toHaveBeenCalled() + expect(logSpy).toHaveBeenCalledWith("receiveResponseFromCommissioning called") + expect(useStateSpy).toHaveBeenCalled() + }) + }) }); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.js index 7968fe2..c2703cc 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.js @@ -30,7 +30,12 @@ const DeleteToscaTemplate = props => { const response = await ControlLoopService.deleteToscaTemplate(props.templateName, props.templateVersion) .catch(error => error.message); - console.log('Response is ok: ' + response.ok); + if(!response.ok) { + console.log('deleteTemplateHandler called with error'); + } else { + console.log('deleteTemplateHandler called'); + } + // console.log('Response is ok: ' + response.ok); props.onDeleteToscaServiceTemplate(response); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.test.js index e4d437a..c52bdea 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/DeleteToscaTemplate.test.js @@ -20,7 +20,6 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; -import GetToscaTemplate from './GetToscaTemplate'; import toJson from "enzyme-to-json"; import DeleteToscaTemplate from "./DeleteToscaTemplate"; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js index ba78b80..70c1f41 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.js @@ -24,11 +24,18 @@ import ControlLoopService from "../../../api/ControlLoopService"; const GetToscaTemplate = (props) => { const getTemplateHandler = async () => { - console.log('getTemplateHandler called') const response = await ControlLoopService.getToscaTemplate(props.templateName, props.templateVersion) .catch(error => error.message); + if(!response.ok) { + console.log('getToscaServiceTemplateHandler called with error') + + } else + { + console.log('getToscaServiceTemplateHandler called') + } + props.onGetToscaServiceTemplate(response); } diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js index 38da005..71fbeec 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/GetToscaTemplate.test.js @@ -21,9 +21,12 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import GetToscaTemplate from './GetToscaTemplate'; import toJson from "enzyme-to-json"; +import { act } from "react-dom/test-utils"; describe('Verify GetToscaTemplate', () => { + const flushPromises = () => new Promise(setImmediate); + it("renders without crashing", () => { shallow(<GetToscaTemplate/>); }); @@ -38,12 +41,41 @@ describe('Verify GetToscaTemplate', () => { expect(container.find('Button').length).toEqual(1); }); - it('button should call getTemplateHandler when clicked', async () => { - const component = mount(<GetToscaTemplate/>) + it('button should call getTemplateHandler when clicked when response is error', async () => { + + const onGetToscaServiceTemplate = jest.fn() + jest + .spyOn(global, 'fetch') + .mockImplementationOnce(async () => + Promise.resolve({ + ok: false, + status: 200, + json: () => { + return Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + } + } + ) + ) + + const component = mount(<GetToscaTemplate onGetToscaServiceTemplate={onGetToscaServiceTemplate}/>) const logSpy = jest.spyOn(console, 'log'); - component.find('[variant="primary"]').simulate('click'); - expect(logSpy).toHaveBeenCalledWith('getTemplateHandler called'); + await act(async () => { + component.find('[variant="primary"]').simulate('click'); + await flushPromises() + component.update() + expect(logSpy).toHaveBeenCalledWith('getToscaServiceTemplateHandler called with error'); + }); + component.unmount(); }); it('should have a Button element with specified text', () => { diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstantiationOrderStateChangeItem.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstantiationOrderStateChangeItem.test.js new file mode 100644 index 0000000..3981ea5 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstantiationOrderStateChangeItem.test.js @@ -0,0 +1,51 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import React from 'react'; +import { mount, shallow } from 'enzyme'; +import toJson from "enzyme-to-json"; +import InstantiationOrderStateChangeItem from "./InstantiationOrderStateChangeItem"; +import CommissioningUtils from "./utils/CommissioningUtils"; + +describe('Verify InstantiationOrderStateChangeItem', () => { + + it("renders without crashing", () => { + shallow(<InstantiationOrderStateChangeItem/>); + }); + + it("renders correctly", () => { + const tree = shallow(<InstantiationOrderStateChangeItem/>); + expect(toJson(tree)).toMatchSnapshot(); + }); + + it("renders correctly when orderState is uninitialized", () => { + const tree = shallow(<InstantiationOrderStateChangeItem orderState="UNINITIALISED" title="UNINITIALISED_TEST"/>); + expect(toJson(tree)).toMatchSnapshot(); + }); + + it("renders correctly when orderState is passive", () => { + const tree = shallow(<InstantiationOrderStateChangeItem orderState="PASSIVE" title="PASSIVE_TEST"/>); + expect(toJson(tree)).toMatchSnapshot(); + }); + + it("renders correctly when orderState is running", () => { + const tree = shallow(<InstantiationOrderStateChangeItem orderState="RUNNING" title="RUNNING_TEST"/>); + expect(toJson(tree)).toMatchSnapshot(); + }); +}); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js index 0eff5fe..5fc97c4 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.js @@ -66,6 +66,7 @@ const ReadAndConvertYaml = (props) => { setToscaTemplateData(toscaData); } else { setResponseOk(true); + console.log('Response is ok'); const toscaData = await toscaServiceTemplateResponse.json(); setToscaTemplateData(toscaData); setShowDeleteButton(true) diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js index 90d7185..03192a1 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/ReadAndConvertYaml.test.js @@ -20,32 +20,43 @@ import React from 'react'; import { mount, shallow } from 'enzyme'; import ReadAndConvertYaml from './ReadAndConvertYaml'; +import GetToscaTemplate from "./GetToscaTemplate"; import toJson from "enzyme-to-json"; import { act } from "react-dom/test-utils"; import { createMemoryHistory } from "history"; +let logSpy = jest.spyOn(console, 'log') describe('Verify ReadAndConvertYaml', () => { - beforeEach(() => { - fetch.resetMocks(); - fetch.mockImplementation(() => { - return Promise.resolve({ + const unmockedFetch = global.fetch + + const flushPromises = () => new Promise(setImmediate); + + beforeAll(() => { + global.fetch = () => + Promise.resolve({ ok: true, status: 200, - json: () => { - return Promise.resolve({ - "tosca_definitions_version": "tosca_simple_yaml_1_1_0", - "data_types": {}, - "policy_types": {}, - "topology_template": {}, - "name": "ToscaServiceTemplateSimple", - "version": "1.0.0", - "metadata": {}, - "id": "0.19518677404255147" - }); - } - }); - }); + text: () => "OK", + json: () => Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + }) + }) + + beforeEach(() => { + logSpy.mockClear() + }) + + afterAll(() => { + global.fetch = unmockedFetch }) it("renders without crashing", () => { @@ -64,36 +75,178 @@ describe('Verify ReadAndConvertYaml', () => { it('should call getToscaServiceTemplateHandler on click', async () => { const component = mount(<ReadAndConvertYaml/>); - const logSpy = jest.spyOn(console, 'log'); - act(async () => { + await act(async () => { + component.find('GetToscaTemplate').simulate('click'); + await flushPromises() + component.update() + await expect(logSpy).toHaveBeenCalledWith('getToscaServiceTemplateHandler called'); + }); + component.unmount() + }); + + it('should make unsuccessful call getToscaServiceTemplateHandler on click', async () => { + jest + .spyOn(global, 'fetch') + .mockImplementationOnce(async () => + Promise.resolve({ + ok: false, + status: 200, + json: () => { + return Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + } + } + ) + ) + const component = mount(<ReadAndConvertYaml/>); + + await act(async () => { + component.find('GetToscaTemplate').simulate('click'); + await flushPromises() + component.update() + expect(logSpy).toHaveBeenCalledWith('getToscaServiceTemplateHandler called with error'); + }); + component.unmount(); + }); + + it('should make unsuccessful call deleteToscaServiceTemplateHandler on click', async () => { + jest + .spyOn(global, 'fetch') + .mockImplementationOnce(() => + Promise.resolve({ + ok: true, + status: 200, + json: () => { + return Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + } + } + ) + ) + const component = mount(<ReadAndConvertYaml/>); + + await act(async () => { component.find('GetToscaTemplate').simulate('click'); - expect(logSpy).toHaveBeenCalledWith('getToscaServiceTemplateHandler called'); + await flushPromises() + component.update() + component.find('DeleteToscaTemplate').simulate('click'); + await flushPromises() + component.update() + expect(logSpy).toHaveBeenCalledWith('deleteTemplateHandler called'); }); + + component.unmount() + }); + + it('should make unsuccessful call deleteToscaServiceTemplateHandler on click', async () => { + const realUseState = React.useState + const stubInitialState = [true] + + const useStateSpy = jest.spyOn(React, 'useState') + useStateSpy.mockImplementationOnce(() => realUseState(stubInitialState)); + + jest + .spyOn(global, 'fetch') + .mockImplementationOnce(() => + Promise.resolve({ + ok: true, + status: 200, + json: () => { + return Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + } + } + ) + ) + const component = mount(<ReadAndConvertYaml/>); + + + await act(async () => { + component.find('GetToscaTemplate').simulate('click'); + await flushPromises() + component.update() + }); + + jest + .spyOn(global, 'fetch') + .mockImplementationOnce(() => + Promise.resolve({ + ok: false, + status: 200, + json: () => { + return Promise.resolve({ + "tosca_definitions_version": "tosca_simple_yaml_1_1_0", + "data_types": {}, + "policy_types": {}, + "topology_template": {}, + "name": "ToscaServiceTemplateSimple", + "version": "1.0.0", + "metadata": {}, + "id": "0.19518677404255147" + }) + } + } + ) + ) + + await act(async () => { + component.find('DeleteToscaTemplate').simulate('click'); + await flushPromises() + component.update() + expect(logSpy).toHaveBeenCalledWith('deleteTemplateHandler called with error'); + }); + component.unmount() }); it('handleClose called when bottom button clicked', () => { const history = createMemoryHistory(); const component = mount(<ReadAndConvertYaml history={ history }/>) - const logSpy = jest.spyOn(console, 'log'); act(() => { component.find('[variant="secondary"]').simulate('click'); expect(logSpy).toHaveBeenCalledWith('handleClose called'); }); + component.unmount() }); - it('handleClose called when top-right button clicked', () => { + it('handleClose called when top-right button clicked', async () => { const history = createMemoryHistory(); const component = mount(<ReadAndConvertYaml history={ history }/>) const logSpy = jest.spyOn(console, 'log'); - act(() => { + await act(async () => { component.find('[size="xl"]').get(0).props.onHide(); + await flushPromises() + component.update() expect(logSpy).toHaveBeenCalledWith('handleClose called'); }); + component.unmount() }); - }); diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ChangeOrderStateModal.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ChangeOrderStateModal.test.js.snap new file mode 100644 index 0000000..478b886 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/ChangeOrderStateModal.test.js.snap @@ -0,0 +1,114 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Verify ChangeOrderStateModal renders correctly 1`] = ` +<Styled(Modal) + backdrop="static" + keyboard={false} + onHide={[Function]} + show={true} + size="sm" +> + <ModalHeader + closeButton={true} + closeLabel="Close" + > + <ModalTitle> + Manage Instantiation + </ModalTitle> + </ModalHeader> + <div + style={ + Object { + "padding": "5px 5px 0 5px", + } + } + > + <ModalBody> + <Container + fluid={false} + > + <Dropdown + navbar={false} + onSelect={[Function]} + > + <DropdownToggle + id="dropdown-basic" + variant="dark" + > + Select Order State + </DropdownToggle> + <DropdownMenu + align="left" + alignRight={false} + flip={true} + > + <DropdownItem + as={ + Object { + "$$typeof": Symbol(react.forward_ref), + "render": [Function], + } + } + disabled={false} + eventKey="UNINITIALISED" + > + UNINITIALISED + </DropdownItem> + <DropdownItem + as={ + Object { + "$$typeof": Symbol(react.forward_ref), + "render": [Function], + } + } + disabled={false} + eventKey="PASSIVE" + > + PASSIVE + </DropdownItem> + <DropdownItem + as={ + Object { + "$$typeof": Symbol(react.forward_ref), + "render": [Function], + } + } + disabled={false} + eventKey="RUNNING" + > + RUNNING + </DropdownItem> + </DropdownMenu> + </Dropdown> + </Container> + <Styled(Alert) + show={false} + variant="danger" + > + Can't get instantiation ordered state: + <br /> + {} + </Styled(Alert)> + </ModalBody> + <styled.div /> + </div> + <ModalFooter> + <Button + active={false} + disabled={false} + onClick={[Function]} + variant="primary" + > + Save + </Button> + <Button + active={false} + disabled={false} + onClick={[Function]} + variant="secondary" + > + Close + </Button> + </ModalFooter> +</Styled(Modal)> +`; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/CommissioningModal.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/CommissioningModal.test.js.snap index 8c26ff6..5ed3f3e 100644 --- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/CommissioningModal.test.js.snap +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/CommissioningModal.test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Verify ReadAndConvertYaml renders correctly 1`] = ` +exports[`Verify CommissioningModal renders correctly 1`] = ` <Styled(Modal) backdrop="static" keyboard={false} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/InstantiationOrderStateChangeItem.test.js.snap b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/InstantiationOrderStateChangeItem.test.js.snap new file mode 100644 index 0000000..bbf92ca --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/__snapshots__/InstantiationOrderStateChangeItem.test.js.snap @@ -0,0 +1,27 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Verify InstantiationOrderStateChangeItem renders correctly 1`] = `<Fragment />`; + +exports[`Verify InstantiationOrderStateChangeItem renders correctly when orderState is passive 1`] = ` +<Fragment> + <styled.div> + PASSIVE_TEST + </styled.div> +</Fragment> +`; + +exports[`Verify InstantiationOrderStateChangeItem renders correctly when orderState is running 1`] = ` +<Fragment> + <styled.div> + RUNNING_TEST + </styled.div> +</Fragment> +`; + +exports[`Verify InstantiationOrderStateChangeItem renders correctly when orderState is uninitialized 1`] = ` +<Fragment> + <styled.div> + UNINITIALISED_TEST + </styled.div> +</Fragment> +`; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/commonProps.json b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/commonProps.json new file mode 100644 index 0000000..71f98f8 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/commonProps.json @@ -0,0 +1,1444 @@ +{ + "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop element for the http requests of PMSH microservice", + "type": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "typeVersion": "1.0.1", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "version": "1.0.1" + }, + "key": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop element for the operational policy for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop element for the K8S microservice for local chart", + "type": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop element for the monitoring policy for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.sample.GenericK8s_ControlLoopDefinition": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop for Hello World", + "type": "org.onap.policy.clamp.controlloop.ControlLoop", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "elements": { + "name": "elements", + "type": "list", + "typeVersion": "0.0.0", + "description": "Specifies a list of control loop element definitions that make up this control loop definition", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": { + "name": null, + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.ControlLoop", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "definedVersion": "1.2.3" + }, + "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop element for the K8S microservice for PMSH", + "type": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "definedVersion": "1.2.3" + }, + "org.onap.domain.pmsh.DerivedPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3", + "derivedFrom": null, + "metadata": {}, + "description": "Control loop for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "typeVersion": "1.0.0", + "properties": { + "provider": { + "name": "provider", + "type": "string", + "typeVersion": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": null, + "defaultValue": null, + "required": false, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "typeVersion": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "defaultValue": null, + "required": true, + "status": null, + "constraints": null, + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "typeVersion": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "defaultValue": null, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "typeVersion": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "defaultValue": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "validValues": null, + "equal": null, + "greaterThan": null, + "greaterOrEqual": "0", + "lessThan": null, + "lessOrEqual": null, + "rangeValues": null + } + ], + "keySchema": null, + "entrySchema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "typeIdentifier": { + "name": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "definedName": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "definedVersion": "1.2.3" + } +} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/controlLoopList.json b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/controlLoopList.json new file mode 100644 index 0000000..d549879 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/controlLoopList.json @@ -0,0 +1,59 @@ +{ + "controlLoopList": [ + { + "name": "PMSHInstance0", + "version": "1.0.1", + "definition": { + "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition", + "version": "1.2.3" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "PMSH control loop instance 0", + "elements": { + "709c62b3-8918-41b9-a747-d21eb79c6c20": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c20", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", + "version": "2.3.4" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "DCAE Control Loop Element for the PMSH instance 0 control loop" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c21": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c21", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Monitoring Policy Control Loop Element for the PMSH instance 0 control loop" + }, + "709c62b3-8918-41b9-a747-d21eb79c6c22": { + "id": "709c62b3-8918-41b9-a747-d21eb79c6c22", + "definition": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + }, + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "state": "UNINITIALISED", + "orderedState": "UNINITIALISED", + "description": "Operational Policy Control Loop Element for the PMSH instance 0 control loop" + } + } + } + ] +} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/fullTemplate.json b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/fullTemplate.json new file mode 100644 index 0000000..8b77554 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/fullTemplate.json @@ -0,0 +1,2194 @@ +{ + "policy_types": { + "onap.policies.Monitoring": { + "name": "onap.policies.Monitoring", + "version": "1.0.0", + "derived_from": "tosca.policies.Root", + "metadata": {}, + "description": "a base policy type for all policies that govern monitoring provisioning", + "properties": {}, + "key": { + "name": "onap.policies.Monitoring", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.policies.Monitoring", + "defined_version": "1.0.0" + }, + "onap.policies.Sirisha": { + "name": "onap.policies.Sirisha", + "version": "1.0.0", + "derived_from": "tosca.policies.Root", + "metadata": {}, + "description": "a base policy type for all policies that govern monitoring provisioning", + "properties": {}, + "key": { + "name": "onap.policies.Sirisha", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.policies.Sirisha", + "defined_version": "1.0.0" + }, + "onap.policies.controlloop.operational.Common": { + "name": "onap.policies.controlloop.operational.Common", + "version": "1.0.0", + "derived_from": "tosca.policies.Root", + "metadata": {}, + "description": "Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\nPolicy Types. This does NOT support the legacy Policy YAML policy type.\n", + "properties": { + "abatement": { + "name": "abatement", + "type": "boolean", + "type_version": "0.0.0", + "description": "Whether an abatement event message will be expected for the control loop from DCAE.", + "default_value": false, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "operations": { + "name": "operations", + "type": "list", + "type_version": "0.0.0", + "description": "List of operations to be performed when Control Loop is triggered.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatype.controlloop.Operation", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": null + }, + "trigger": { + "name": "trigger", + "type": "string", + "type_version": "0.0.0", + "description": "Initial operation to execute upon receiving an Onset event message for the Control Loop.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "timeout": { + "name": "timeout", + "type": "integer", + "type_version": "0.0.0", + "description": "Overall timeout for executing all the operations. This timeout should equal or exceed the total\ntimeout for each operation listed.\n", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "id": { + "name": "id", + "type": "string", + "type_version": "0.0.0", + "description": "The unique control loop id.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "key": { + "name": "onap.policies.controlloop.operational.Common", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.policies.controlloop.operational.Common", + "defined_version": "1.0.0" + }, + "onap.policies.controlloop.operational.common.Apex": { + "name": "onap.policies.controlloop.operational.common.Apex", + "version": "1.0.0", + "derived_from": "onap.policies.controlloop.operational.Common", + "metadata": {}, + "description": "Operational policies for Apex PDP", + "properties": { + "engineServiceParameters": { + "name": "engineServiceParameters", + "type": "string", + "type_version": "0.0.0", + "description": "The engine parameters like name, instanceCount, policy implementation, parameters etc.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "eventOutputParameters": { + "name": "eventOutputParameters", + "type": "string", + "type_version": "0.0.0", + "description": "The event output parameters.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "javaProperties": { + "name": "javaProperties", + "type": "string", + "type_version": "0.0.0", + "description": "Name/value pairs of properties to be set for APEX if needed.", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "eventInputParameters": { + "name": "eventInputParameters", + "type": "string", + "type_version": "0.0.0", + "description": "The event input parameters.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "key": { + "name": "onap.policies.controlloop.operational.common.Apex", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.policies.controlloop.operational.common.Apex", + "defined_version": "1.0.0" + }, + "onap.policies.monitoring.dcae-pm-subscription-handler": { + "name": "onap.policies.monitoring.dcae-pm-subscription-handler", + "version": "1.0.0", + "derived_from": "onap.policies.Monitoring", + "metadata": {}, + "description": null, + "properties": { + "pmsh_policy": { + "name": "pmsh_policy", + "type": "onap.datatypes.monitoring.subscription", + "type_version": "0.0.0", + "description": "PMSH Policy JSON", + "default_value": null, + "required": false, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + } + }, + "key": { + "name": "onap.policies.monitoring.dcae-pm-subscription-handler", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.policies.monitoring.dcae-pm-subscription-handler", + "defined_version": "1.0.0" + } + }, + "node_types": { + "org.onap.policy.clamp.controlloop.CDSControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.CDSControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "cds_blueprint_id": { + "name": "cds_blueprint_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.CDSControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.CDSControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.ControlLoop": { + "name": "org.onap.policy.clamp.controlloop.ControlLoop", + "version": "1.0.1", + "derived_from": "tosca.nodetypes.Root", + "metadata": {}, + "description": null, + "properties": { + "elements": { + "name": "elements", + "type": "list", + "type_version": "0.0.0", + "description": "Specifies a list of control loop element definitions that make up this control loop definition", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": { + "common": "true" + } + }, + "provider": { + "name": "provider", + "type": "string", + "type_version": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.ControlLoop", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.ControlLoop", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.ControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "version": "1.0.1", + "derived_from": "tosca.nodetypes.Root", + "metadata": {}, + "description": null, + "properties": { + "runningToPassiveTimeout": { + "name": "runningToPassiveTimeout", + "type": "integer", + "type_version": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from running to passive", + "default_value": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "valid_values": null, + "equal": null, + "greater_than": null, + "greater_or_equal": "0", + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "participantType": { + "name": "participantType", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": "The identity of the participant type that hosts this type of Control Loop Element", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "provider": { + "name": "provider", + "type": "string", + "type_version": "0.0.0", + "description": "Specifies the organization that provides the control loop element", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "startPhase": { + "name": "startPhase", + "type": "integer", + "type_version": "0.0.0", + "description": "A value indicating the start phase in which this control loop element will be started, the first start phase is zero. Control Loop Elements are started in their start_phase order and stopped in reverse start phase order. Control Loop Elements with the same start phase are started and stopped simultaneously", + "default_value": null, + "required": false, + "status": null, + "constraints": [ + { + "valid_values": null, + "equal": null, + "greater_than": null, + "greater_or_equal": "0", + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "passiveToUninitializedTimeout": { + "name": "passiveToUninitializedTimeout", + "type": "integer", + "type_version": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to uninitialized", + "default_value": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "valid_values": null, + "equal": null, + "greater_than": null, + "greater_or_equal": "0", + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "uninitializedToPassiveTimeout": { + "name": "uninitializedToPassiveTimeout", + "type": "integer", + "type_version": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from uninitialized to passive", + "default_value": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "valid_values": null, + "equal": null, + "greater_than": null, + "greater_or_equal": "0", + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "participant_id": { + "name": "participant_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + }, + "passiveToRunningTimeout": { + "name": "passiveToRunningTimeout", + "type": "integer", + "type_version": "0.0.0", + "description": "The maximum time in seconds to wait for a state chage from passive to running", + "default_value": 60.0, + "required": false, + "status": null, + "constraints": [ + { + "valid_values": null, + "equal": null, + "greater_than": null, + "greater_or_equal": "0", + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": { + "common": "true" + } + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "policy_id": { + "name": "policy_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "policy_type_id": { + "name": "policy_type_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "policy_id": { + "name": "policy_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "policy_type_id": { + "name": "policy_type_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.HttpControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "httpHeaders": { + "name": "httpHeaders", + "type": "map", + "type_version": "0.0.0", + "description": "HTTP headers to send on REST requests", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": null + }, + "baseUrl": { + "name": "baseUrl", + "type": "string", + "type_version": "0.0.0", + "description": "The base URL to be prepended to each path, identifies the host for the REST endpoints.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "configurationEntities": { + "name": "configurationEntities", + "type": "map", + "type_version": "0.0.0", + "description": "The connfiguration entities the Control Loop Element is managing and their associated REST requests", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.ConfigurationEntity", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "values": { + "name": "values", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "templates": { + "name": "templates", + "type": "list", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "chart": { + "name": "chart", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "requirements": { + "name": "requirements", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "configs": { + "name": "configs", + "type": "list", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.Participant": { + "name": "org.onap.policy.clamp.controlloop.Participant", + "version": "1.0.1", + "derived_from": "tosca.nodetypes.Root", + "metadata": {}, + "description": null, + "properties": { + "provider": { + "name": "provider", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.Participant", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.Participant", + "defined_version": "1.0.1" + }, + "org.onap.policy.clamp.controlloop.PolicyControlLoopElement": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.1", + "derived_from": "org.onap.policy.clamp.controlloop.ControlLoopElement", + "metadata": {}, + "description": null, + "properties": { + "policy_id": { + "name": "policy_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "policy_type_id": { + "name": "policy_type_id", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "requirements": null, + "key": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.1" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "defined_version": "1.0.1" + } + }, + "topology_template": { + "description": null, + "inputs": { + "pmsh_operational_policy": { + "name": "pmsh_operational_policy", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "value": null + }, + "pmsh_monitoring_policy": { + "name": "pmsh_monitoring_policy", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "value": null + } + }, + "node_templates": { + "org.onap.controlloop.HttpControlLoopParticipant": { + "name": "org.onap.controlloop.HttpControlLoopParticipant", + "version": "2.3.4", + "derived_from": null, + "metadata": {}, + "description": "Participant for Http requests", + "type": "org.onap.policy.clamp.controlloop.Participant", + "type_version": "1.0.1", + "properties": { + "provider": "ONAP" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.controlloop.HttpControlLoopParticipant", + "version": "2.3.4" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.Participant", + "version": "1.0.1" + }, + "key": { + "name": "org.onap.controlloop.HttpControlLoopParticipant", + "version": "2.3.4" + }, + "defined_name": "org.onap.controlloop.HttpControlLoopParticipant", + "defined_version": "2.3.4" + }, + "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop element for the http requests of PMSH microservice", + "type": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "type_version": "1.0.1", + "properties": { + "participantType": { + "name": "org.onap.k8s.controlloop.HttpControlLoopParticipant", + "version": "2.3.4" + }, + "configurationEntities": [ + { + "configurationEntityId": { + "name": "entity1", + "version": "1.0.1" + }, + "restSequence": [ + { + "restRequestId": { + "name": "request1", + "version": "1.0.1" + }, + "httpMethod": "PUT", + "path": "v1/kv/dcae-pmsh2", + "body": "{ \"control_loop_name\":\"pmsh-control-loop\", \"operational_policy_name\":\"pmsh-operational-policy\", \"aaf_password\":\"demo123456!\", \"aaf_identity\":\"dcae@dcae.onap.org\", \"cert_path\":\"/opt/app/pmsh/etc/certs/cert.pem\", \"key_path\":\"/opt/app/pmsh/etc/certs/key.pem\", \"ca_cert_path\":\"/opt/app/pmsh/etc/certs/cacert.pem\", \"enable_tls\":\"true\", \"pmsh_policy\":{ \"subscription\":{ \"subscriptionName\":\"ExtraPM-All-gNB-R2B\", \"administrativeState\":\"UNLOCKED\", \"fileBasedGP\":15, \"fileLocation\":\"\/pm\/pm.xml\", \"nfFilter\":{ \"nfNames\":[ \"^pnf.*\", \"^vnf.*\" ], \"modelInvariantIDs\":[ ], \"modelVersionIDs\":[ ], \"modelNames\":[ ] }, \"measurementGroups\":[ { \"measurementGroup\":{ \"measurementTypes\":[ { \"measurementType\":\"countera\" }, { \"measurementType\":\"counterb\" } ], \"managedObjectDNsBasic\":[ { \"DN\":\"dna\" }, { \"DN\":\"dnb\" } ] } }, { \"measurementGroup\":{ \"measurementTypes\":[ { \"measurementType\":\"counterc\" }, { \"measurementType\":\"counterd\" } ], \"managedObjectDNsBasic\":[ { \"DN\":\"dnc\" }, { \"DN\":\"dnd\" } ] } } ] } }, \"streams_subscribes\":{ \"aai_subscriber\":{ \"type\":\"message_router\", \"dmaap_info\":{ \"topic_url\":\"https://10.152.183.151:3905/events/AAI_EVENT\", \"client_role\":\"org.onap.dcae.aaiSub\", \"location\":\"san-francisco\", \"client_id\":\"1575976809466\" } }, \"policy_pm_subscriber\":{ \"type\":\"message_router\", \"dmaap_info\":{ \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\", \"client_role\":\"org.onap.dcae.pmSubscriber\", \"location\":\"san-francisco\", \"client_id\":\"1575876809456\" } } }, \"streams_publishes\":{ \"policy_pm_publisher\":{ \"type\":\"message_router\", \"dmaap_info\":{ \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.PM_SUBSCRIPTIONS\", \"client_role\":\"org.onap.dcae.pmPublisher\", \"location\":\"san-francisco\", \"client_id\":\"1475976809466\" } }, \"other_publisher\":{ \"type\":\"message_router\", \"dmaap_info\":{ \"topic_url\":\"https://10.152.183.151:3905/events/org.onap.dmaap.mr.SOME_OTHER_TOPIC\", \"client_role\":\"org.onap.dcae.pmControlPub\", \"location\":\"san-francisco\", \"client_id\":\"1875976809466\" } } } }", + "expectedResponse": 200 + } + ] + } + ], + "provider": "ONAP", + "startPhase": 1, + "uninitializedToPassiveTimeout": 180, + "httpHeaders": { + "Content-Type": "application/json" + }, + "participant_id": { + "name": "HttpParticipant0", + "version": "1.0.0" + }, + "baseUrl": "http://10.152.183.51:8500" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.HttpControlLoopElement", + "version": "1.0.1" + }, + "key": { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop element for the operational policy for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "policy_type_id": { + "name": "onap.policies.operational.pm-subscription-handler", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "provider": "Ericsson", + "policy_id": { + "get_input": "pmsh_operational_policy" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop element for the K8S microservice for local chart", + "type": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "K8sParticipant0", + "version": "1.0.0" + }, + "provider": "ONAP", + "chart": { + "chartId": { + "name": "nginx-ingress", + "version": "0.9.1" + }, + "releaseName": "nginxms", + "namespace": "test" + }, + "participantType": { + "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "version": "2.3.4" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop element for the monitoring policy for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "policy_type_id": { + "name": "onap.policies.monitoring.pm-subscription-handler", + "version": "1.0.0" + }, + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "provider": "Ericsson", + "policy_id": { + "get_input": "pmsh_monitoring_policy" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.PolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.k8s.controlloop.K8SControlLoopParticipant": { + "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "version": "2.3.4", + "derived_from": null, + "metadata": {}, + "description": "Participant for K8S", + "type": "org.onap.policy.clamp.controlloop.Participant", + "type_version": "1.0.1", + "properties": { + "provider": "ONAP" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "version": "2.3.4" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.Participant", + "version": "1.0.1" + }, + "key": { + "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "version": "2.3.4" + }, + "defined_name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "defined_version": "2.3.4" + }, + "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "provider": "Ericsson", + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.DerivedDerivedPolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.domain.sample.GenericK8s_ControlLoopDefinition": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop for Hello World", + "type": "org.onap.policy.clamp.controlloop.ControlLoop", + "type_version": "1.0.0", + "properties": { + "elements": [ + { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.database.Local_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.database.Http_PMSHMicroserviceControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.DerivedDerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement", + "version": "1.2.3" + }, + { + "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement", + "version": "1.2.3" + } + ], + "provider": "ONAP" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.ControlLoop", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.sample.GenericK8s_ControlLoopDefinition", + "defined_version": "1.2.3" + }, + "org.onap.policy.controlloop.PolicyControlLoopParticipant": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1", + "derived_from": null, + "metadata": {}, + "description": "Participant for DCAE microservices", + "type": "org.onap.policy.clamp.controlloop.Participant", + "type_version": "1.0.1", + "properties": { + "provider": "ONAP" + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.Participant", + "version": "1.0.1" + }, + "key": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + }, + "defined_name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "defined_version": "2.3.1" + }, + "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop element for the K8S microservice for PMSH", + "type": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "K8sParticipant0", + "version": "1.0.0" + }, + "provider": "ONAP", + "chart": { + "chartId": { + "name": "dcae-pmsh", + "version": "8.0.0" + }, + "namespace": "onap", + "releaseName": "pmshms", + "repository": { + "repoName": "chartmuseum", + "protocol": "http", + "address": "10.152.183.120", + "port": 80, + "userName": "onapinitializer", + "password": "demo123456!" + }, + "overrideParams": { + "global.masterPassword": "test" + } + }, + "participantType": { + "name": "org.onap.k8s.controlloop.K8SControlLoopParticipant", + "version": "2.3.4" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.K8SMicroserviceControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.database.PMSH_K8SMicroserviceControlLoopElement", + "defined_version": "1.2.3" + }, + "org.onap.domain.pmsh.DerivedPolicyControlLoopElement": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3", + "derived_from": null, + "metadata": {}, + "description": "Control loop for Performance Management Subscription Handling", + "type": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "type_version": "1.0.0", + "properties": { + "participant_id": { + "name": "org.onap.PM_Policy", + "version": "1.0.0" + }, + "provider": "Ericsson", + "participantType": { + "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant", + "version": "2.3.1" + } + }, + "requirements": null, + "capabilities": null, + "identifier": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "type_identifier": { + "name": "org.onap.policy.clamp.controlloop.DerivedPolicyControlLoopElement", + "version": "1.0.0" + }, + "key": { + "name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "version": "1.2.3" + }, + "defined_name": "org.onap.domain.pmsh.DerivedPolicyControlLoopElement", + "defined_version": "1.2.3" + } + }, + "policies": null, + "policies_as_map": {} + }, + "tosca_definitions_version": "tosca_simple_yaml_1_3", + "data_types": { + "onap.datatype.controlloop.Actor": { + "name": "onap.datatype.controlloop.Actor", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": "An actor/operation/target definition", + "properties": { + "payload": { + "name": "payload", + "type": "map", + "type_version": "0.0.0", + "description": "Name/value pairs of payload information passed by Policy to the actor", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": { + "clamp_possible_values": "ClampExecution:CDS/payload" + } + }, + "target": { + "name": "target", + "type": "onap.datatype.controlloop.Target", + "type_version": "0.0.0", + "description": "The resource the operation should be performed on.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "actor": { + "name": "actor", + "type": "string", + "type_version": "0.0.0", + "description": "The actor performing the operation.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "clamp_possible_values": "Dictionary:DefaultActors,ClampExecution:CDS/actor" + } + }, + "operation": { + "name": "operation", + "type": "string", + "type_version": "0.0.0", + "description": "The operation the actor is performing.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": { + "clamp_possible_values": "Dictionary:DefaultOperations,ClampExecution:CDS/operation" + } + } + }, + "constraints": [], + "key": { + "name": "onap.datatype.controlloop.Actor", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatype.controlloop.Actor", + "defined_version": null + }, + "onap.datatype.controlloop.Operation": { + "name": "onap.datatype.controlloop.Operation", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": "An operation supported by an actor", + "properties": { + "failure_retries": { + "name": "failure_retries", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke when the current operation has exceeded its max retries.", + "default_value": "final_failure_retries", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "id": { + "name": "id", + "type": "string", + "type_version": "0.0.0", + "description": "Unique identifier for the operation", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "failure_timeout": { + "name": "failure_timeout", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke when the time out for the operation occurs.", + "default_value": "final_failure_timeout", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "failure": { + "name": "failure", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke on Actor operation failure.", + "default_value": "final_failure", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "operation": { + "name": "operation", + "type": "onap.datatype.controlloop.Actor", + "type_version": "0.0.0", + "description": "The definition of the operation to be performed.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "failure_guard": { + "name": "failure_guard", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.", + "default_value": "final_failure_guard", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "retries": { + "name": "retries", + "type": "integer", + "type_version": "0.0.0", + "description": "The number of retries the actor should attempt to perform the operation.", + "default_value": 0.0, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "timeout": { + "name": "timeout", + "type": "integer", + "type_version": "0.0.0", + "description": "The amount of time for the actor to perform the operation.", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "failure_exception": { + "name": "failure_exception", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke when the current operation causes an exception.", + "default_value": "final_failure_exception", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "description": { + "name": "description", + "type": "string", + "type_version": "0.0.0", + "description": "A user-friendly description of the intent for the operation", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "success": { + "name": "success", + "type": "string", + "type_version": "0.0.0", + "description": "Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.", + "default_value": "final_success", + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "constraints": [], + "key": { + "name": "onap.datatype.controlloop.Operation", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatype.controlloop.Operation", + "defined_version": null + }, + "onap.datatype.controlloop.Target": { + "name": "onap.datatype.controlloop.Target", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": "Definition for a entity in A&AI to perform a control loop operation on", + "properties": { + "entityIds": { + "name": "entityIds", + "type": "map", + "type_version": "0.0.0", + "description": "Map of values that identify the resource. If none are provided, it is assumed that the\nentity that generated the ONSET event will be the target.\n", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": null + }, + "metadata": { + "clamp_possible_values": "ClampExecution:CSAR_RESOURCES" + } + }, + "targetType": { + "name": "targetType", + "type": "string", + "type_version": "0.0.0", + "description": "Category for the target type", + "default_value": null, + "required": true, + "status": null, + "constraints": [ + { + "valid_values": [ + "VNF", + "VM", + "VFMODULE", + "PNF" + ], + "equal": null, + "greater_than": null, + "greater_or_equal": null, + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "constraints": [], + "key": { + "name": "onap.datatype.controlloop.Target", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatype.controlloop.Target", + "defined_version": null + }, + "onap.datatypes.ToscaConceptIdentifier": { + "name": "onap.datatypes.ToscaConceptIdentifier", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "version": { + "name": "version", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "name": { + "name": "name", + "type": "string", + "type_version": "0.0.0", + "description": null, + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.ToscaConceptIdentifier", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.ToscaConceptIdentifier", + "defined_version": null + }, + "onap.datatypes.monitoring.managedObjectDNsBasic": { + "name": "onap.datatypes.monitoring.managedObjectDNsBasic", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "DN": { + "name": "DN", + "type": "string", + "type_version": "0.0.0", + "description": "Managed object distinguished name", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.managedObjectDNsBasic", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.managedObjectDNsBasic", + "defined_version": null + }, + "onap.datatypes.monitoring.managedObjectDNsBasics": { + "name": "onap.datatypes.monitoring.managedObjectDNsBasics", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "managedObjectDNsBasic": { + "name": "managedObjectDNsBasic", + "type": "map", + "type_version": "0.0.0", + "description": "Managed object distinguished name object", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.managedObjectDNsBasic", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.managedObjectDNsBasics", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.managedObjectDNsBasics", + "defined_version": null + }, + "onap.datatypes.monitoring.measurementGroup": { + "name": "onap.datatypes.monitoring.measurementGroup", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "measurementTypes": { + "name": "measurementTypes", + "type": "list", + "type_version": "0.0.0", + "description": "List of measurement types", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.measurementTypes", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + }, + "managedObjectDNsBasic": { + "name": "managedObjectDNsBasic", + "type": "list", + "type_version": "0.0.0", + "description": "List of managed object distinguished names", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.managedObjectDNsBasics", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.measurementGroup", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.measurementGroup", + "defined_version": null + }, + "onap.datatypes.monitoring.measurementGroups": { + "name": "onap.datatypes.monitoring.measurementGroups", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "measurementGroup": { + "name": "measurementGroup", + "type": "map", + "type_version": "0.0.0", + "description": "Measurement Group", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.measurementGroup", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.measurementGroups", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.measurementGroups", + "defined_version": null + }, + "onap.datatypes.monitoring.measurementType": { + "name": "onap.datatypes.monitoring.measurementType", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "measurementType": { + "name": "measurementType", + "type": "string", + "type_version": "0.0.0", + "description": "Measurement type", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.measurementType", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.measurementType", + "defined_version": null + }, + "onap.datatypes.monitoring.measurementTypes": { + "name": "onap.datatypes.monitoring.measurementTypes", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "measurementType": { + "name": "measurementType", + "type": "map", + "type_version": "0.0.0", + "description": "Measurement type object", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.measurementType", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.measurementTypes", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.measurementTypes", + "defined_version": null + }, + "onap.datatypes.monitoring.nfFilter": { + "name": "onap.datatypes.monitoring.nfFilter", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "modelVersionIDs": { + "name": "modelVersionIDs", + "type": "list", + "type_version": "0.0.0", + "description": "List of model version IDs", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + }, + "modelInvariantIDs": { + "name": "modelInvariantIDs", + "type": "list", + "type_version": "0.0.0", + "description": "List of model invariant IDs", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + }, + "modelNames": { + "name": "modelNames", + "type": "list", + "type_version": "0.0.0", + "description": "List of model names", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + }, + "nfNames": { + "name": "nfNames", + "type": "list", + "type_version": "0.0.0", + "description": "List of network functions", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "string", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.nfFilter", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.nfFilter", + "defined_version": null + }, + "onap.datatypes.monitoring.subscription": { + "name": "onap.datatypes.monitoring.subscription", + "version": "0.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "measurementGroups": { + "name": "measurementGroups", + "type": "list", + "type_version": "0.0.0", + "description": "Measurement Groups", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.measurementGroups", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + }, + "fileBasedGP": { + "name": "fileBasedGP", + "type": "integer", + "type_version": "0.0.0", + "description": "File based granularity period", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + }, + "fileLocation": { + "name": "fileLocation", + "type": "string", + "type_version": "0.0.0", + "description": "ROP file location", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + }, + "subscriptionName": { + "name": "subscriptionName", + "type": "string", + "type_version": "0.0.0", + "description": "Name of the subscription", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": {} + }, + "administrativeState": { + "name": "administrativeState", + "type": "string", + "type_version": "0.0.0", + "description": "State of the subscription", + "default_value": null, + "required": true, + "status": null, + "constraints": [ + { + "valid_values": [ + "LOCKED", + "UNLOCKED" + ], + "equal": null, + "greater_than": null, + "greater_or_equal": null, + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": {} + }, + "nfFilter": { + "name": "nfFilter", + "type": "map", + "type_version": "0.0.0", + "description": "Network function filter", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": { + "name": null, + "type": "onap.datatypes.monitoring.nfFilter", + "type_version": "0.0.0", + "description": null, + "constraints": [] + }, + "metadata": {} + } + }, + "constraints": [], + "key": { + "name": "onap.datatypes.monitoring.subscription", + "version": "0.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "onap.datatypes.monitoring.subscription", + "defined_version": null + }, + "org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest": { + "name": "org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest", + "version": "1.0.0", + "derived_from": "tosca.datatypes.Root", + "metadata": {}, + "description": null, + "properties": { + "body": { + "name": "body", + "type": "string", + "type_version": "0.0.0", + "description": "The body of the REST request for PUT and POST requests", + "default_value": null, + "required": false, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "expectedResponse": { + "name": "expectedResponse", + "type": "integer", + "type_version": "0.0.0", + "description": "THe expected HTTP status code for the REST request", + "default_value": null, + "required": true, + "status": null, + "constraints": [], + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "httpMethod": { + "name": "httpMethod", + "type": "string", + "type_version": "0.0.0", + "description": "The REST method to use", + "default_value": null, + "required": true, + "status": null, + "constraints": [ + { + "valid_values": [ + "POST", + "PUT", + "GET", + "DELETE" + ], + "equal": null, + "greater_than": null, + "greater_or_equal": null, + "less_than": null, + "less_or_equal": null, + "range_values": null + } + ], + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "restRequestId": { + "name": "restRequestId", + "type": "onap.datatypes.ToscaConceptIdentifier", + "type_version": "0.0.0", + "description": "The name and version of a REST request to be sent to a REST endpoint", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + }, + "path": { + "name": "path", + "type": "string", + "type_version": "0.0.0", + "description": "The path of the REST request relative to the base URL", + "default_value": null, + "required": true, + "status": null, + "constraints": null, + "key_schema": null, + "entry_schema": null, + "metadata": null + } + }, + "constraints": [], + "key": { + "name": "org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest", + "version": "1.0.0" + }, + "type": null, + "type_version": null, + "defined_name": "org.onap.datatypes.policy.clamp.controlloop.httpControlLoopElement.RestRequest", + "defined_version": "1.0.0" + } + } +} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/jsonEditorData.json b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/jsonEditorData.json new file mode 100644 index 0000000..c09424f --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/jsonEditorData.json @@ -0,0 +1,50 @@ +{ + "__data": [ + "Object" + ], + "copyClipboard": null, + "editors": [ + "Object" + ], + "element": "<div … />", + "expandRefs": [ + "Function anonymous" + ], + "expandSchema": [ + "Function anonymous" + ], + "iconlib": [ + "n" + ], + "options": [ + "Object" + ], + "ready": true, + "refs": [ + "Object" + ], + "root": [ + "o" + ], + "root_container": "<div … />", + "schema": [ + "Object" + ], + "template": "undefined", + "theme": [ + "o" + ], + "translate": [ + "Function translate" + ], + "translateProperty": [ + "Function translateProperty" + ], + "uuid": 0, + "validation_results": [ + "Array" + ], + "validator": [ + "t" + ] +} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/orderedStateJson.json b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/orderedStateJson.json new file mode 100644 index 0000000..91c892d --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/testFiles/orderedStateJson.json @@ -0,0 +1,9 @@ +{ + "orderedState": "PASSIVE", + "controlLoopIdentifierList": [ + { + "name": "PMSH_Instance1", + "version": "2.3.1" + } + ] +} diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.js new file mode 100644 index 0000000..2d98598 --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.js @@ -0,0 +1,178 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import { JSONEditor } from "@json-editor/json-editor"; +import { Alert } from "react-bootstrap"; +import React from "react"; + +const CommissioningUtils = { + makeSchemaForCommonProperties: (commonProps) => { + const commonPropsArr = Object.entries(commonProps) + + const newSchemaObject = {} + + newSchemaObject.title = "CommonProperties" + newSchemaObject.type = "object" + newSchemaObject.properties = {} + + commonPropsArr.forEach(([templateKey, template]) => { + + const propertiesObject = {} + Object.entries(template.properties).forEach(([propKey, prop]) => { + + propertiesObject[propKey] = { + type: CommissioningUtils.getType(prop.type) + } + + }) + newSchemaObject.properties[templateKey] = { + options: { + "collapsed": true + }, + properties: propertiesObject + } + }) + + return newSchemaObject + }, + getType: (propertyType) => { + switch (propertyType) + { + case "string": + return "string" + case "integer": + return "integer" + case "list": + return "array" + case "object": + return "object" + default: + return "object" + } + }, + createJsonEditor: (toscaModel, editorData) => { + JSONEditor.defaults.options.collapse = false; + + return new JSONEditor(document.getElementById("editor"), + { + schema: toscaModel, + startval: editorData, + theme: 'bootstrap4', + iconlib: 'fontawesome5', + object_layout: 'normal', + disable_properties: false, + disable_edit_json: true, + disable_array_reorder: true, + disable_array_delete_last_row: true, + disable_array_delete_all_rows: false, + array_controls_top: true, + keep_oneof_values: false, + collapsed: false, + show_errors: 'always', + display_required_only: false, + show_opt_in: false, + prompt_before_delete: true, + required_by_default: false, + }) + }, + renderJsonEditor: async (template, commonProps) => { + + const fullTemplate = await template.json() + + let toscaInitialValues + const allNodeTemplates = fullTemplate.topology_template.node_templates + const shortenedNodeTemplatesObjectStartValues = {} + // Get the common properties to construct a schema + // Get valid start values at the same time + const commonNodeTemplatesJson = await commonProps.json().then(data => { + const nodeTemplatesArray = Object.entries(data) + const shortenedNodeTemplatesObject = {} + nodeTemplatesArray.forEach(([key, temp]) => { + const currentNodeTemplate = allNodeTemplates[key] + const propertiesObject = { + properties: temp.properties + } + + shortenedNodeTemplatesObject[key] = propertiesObject + + const propertiesStartValues = {} + + // Get all the existing start values to populate the properties in the schema + Object.entries(propertiesObject.properties).forEach(([propKey, prop]) => { + propertiesStartValues[propKey] = currentNodeTemplate.properties[propKey] + }) + + shortenedNodeTemplatesObjectStartValues[key] = propertiesStartValues + + }) + + toscaInitialValues = shortenedNodeTemplatesObjectStartValues; + return shortenedNodeTemplatesObject; + }) + + const propertySchema = CommissioningUtils.makeSchemaForCommonProperties(commonNodeTemplatesJson); + + const editorTemp = CommissioningUtils.createJsonEditor(propertySchema, shortenedNodeTemplatesObjectStartValues); + + return { + fullTemplate: fullTemplate, + propertySchema: propertySchema, + editorTemp: editorTemp, + toscaInitialValues: toscaInitialValues + } + }, + getAlertMessages: async (response) => { + if (response.ok) { + return(<Alert variant="success"> + <Alert.Heading>Commissioning Success</Alert.Heading> + <p>Altered Template was Successfully Uploaded</p> + <hr/> + </Alert>); + } + else { + return(<Alert variant="danger"> + <Alert.Heading>Commissioning Failure</Alert.Heading> + <p>Updated Template Failed to Upload</p> + <p>Status code: { await response.status }: { response.statusText }</p> + <p>Response Text: { await response.text() }</p> + <hr/> + </Alert>); + } + }, + + updateTemplate: async (userAddedCommonPropValues, fullToscaTemplate) => { + const nodeTemplates = fullToscaTemplate.topology_template.node_templates + const commonPropertyDataEntries = Object.entries(userAddedCommonPropValues) + + // This replaces the values for properties in the full tosca template + // that will be sent up to the api with the entries the user provided. + commonPropertyDataEntries.forEach(([templateKey, values]) => { + Object.entries(values).forEach(([propKey, propVal]) => { + nodeTemplates[templateKey].properties[propKey] = propVal + }) + }) + + fullToscaTemplate.topology_template.node_templates = nodeTemplates + + alert('Changes saved. Commission When Ready...') + return fullToscaTemplate + } +} + +export default CommissioningUtils; diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.test.js new file mode 100644 index 0000000..8304ecb --- /dev/null +++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/utils/CommissioningUtils.test.js @@ -0,0 +1,94 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (C) 2021 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +import commonProps from "../testFiles/commonProps.json"; +import fullTemp from "../testFiles/fullTemplate.json"; +import CommissioningUtils from "./CommissioningUtils"; +import React from "react"; + +const commonProperties = JSON.parse(JSON.stringify(commonProps)) +const fullTemplate = JSON.parse(JSON.stringify(fullTemp)) + +describe('Verify CommissioningUtils', () => { + + const fullTemplatePromise = { + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(fullTemplate) + } + } + + const commonPropertiesPromise = { + ok: true, + status: 200, + text: () => "OK", + json: () => { + return Promise.resolve(commonProperties) + } + } + + it('test renderJsonEditor output is correct', async () => { + // Have to mock "editor" dom element for json editor to work in testing + document.body.innerHTML = '<div id="editor"></div>'; + + await expect((await CommissioningUtils.renderJsonEditor(fullTemplatePromise, commonPropertiesPromise)).editorTemp).toBeTruthy() + await expect((await CommissioningUtils.renderJsonEditor(fullTemplatePromise, commonPropertiesPromise)).fullTemplate).toBeTruthy() + await expect((await CommissioningUtils.renderJsonEditor(fullTemplatePromise, commonPropertiesPromise)).propertySchema).toBeTruthy() + await expect((await CommissioningUtils.renderJsonEditor(fullTemplatePromise, commonPropertiesPromise)).toscaInitialValues).toBeTruthy() + }) + + it('test the getType method object type', () => { + expect(CommissioningUtils.getType("object")).toBe("object") + }) + + it('test getAlertMessages with response ok', async () => { + const response = { + ok: true, + status: 200, + text: () => { + return Promise.resolve("OK") + }, + json: () => { + return Promise.resolve("{}") + } + } + + await expect(JSON.stringify(await CommissioningUtils.getAlertMessages(response))).toContain("Commissioning Success") + }) + + it('test getAlertMessages with response not ok', async () => { + const response = { + ok: false, + status: 200, + text: () => { + return Promise.resolve("Error") + }, + json: () => { + return Promise.resolve("{}") + } + } + + await expect(JSON.stringify(await CommissioningUtils.getAlertMessages(response))).toContain("Commissioning Failure") + }) + + + } +) |