-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.exceptions;\r
-\r
-public class InvalidInputException extends Exception {\r
- public InvalidInputException(String message){\r
- super(message);\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.exceptions;
+
+public class InvalidInputException extends Exception {
+ public InvalidInputException(String message){
+ super(message);
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.exceptions;\r
-\r
-public class InvalidStateException extends Exception {\r
- public InvalidStateException(String message) {\r
- super(message);\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.exceptions;
+
+public class InvalidStateException extends Exception {
+ public InvalidStateException(String message) {
+ super(message);
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager;\r
-\r
-import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;\r
-import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;\r
-\r
-public interface LifecycleManager {\r
- String getNextState(String vnfType, String currentState, String event)\r
- throws NoTransitionDefinedException,LifecycleException;\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager;
+
+import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
+import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
+
+public interface LifecycleManager {
+ String getNextState(String vnfType, String currentState, String event)
+ throws NoTransitionDefinedException,LifecycleException;
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager.objects;\r
-\r
-public enum LCMResponse {\r
- INVALID_INPUT_PARAMETERS,\r
- NO_STATE_CHANGE,\r
- NO_TRANSITION_DEFINED,\r
- VALID_TRANSITION;\r
-\r
- public String toString(){\r
- return this.name();\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager.objects;
+
+public enum LCMResponse {
+ INVALID_INPUT_PARAMETERS,
+ NO_STATE_CHANGE,
+ NO_TRANSITION_DEFINED,
+ VALID_TRANSITION;
+
+ public String toString(){
+ return this.name();
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager.objects;\r
-\r
-public class LifecycleException extends Exception {\r
- public final String currentState;\r
- public final String event;\r
-\r
- public LifecycleException(Exception e,String currentState,String event){\r
- super(e);\r
- this.currentState = currentState;\r
- this.event = event;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager.objects;
+
+public class LifecycleException extends Exception {
+ public final String currentState;
+ public final String event;
+
+ public LifecycleException(Exception e,String currentState,String event){
+ super(e);
+ this.currentState = currentState;
+ this.event = event;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager.objects;\r
-\r
-public class NoTransitionDefinedException extends Exception {\r
- public final String currentState;\r
- public final String event;\r
-\r
- public NoTransitionDefinedException(String message,String currentState,String event){\r
- super(message);\r
- this.currentState = currentState;\r
- this.event = event;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager.objects;
+
+public class NoTransitionDefinedException extends Exception {
+ public final String currentState;
+ public final String event;
+
+ public NoTransitionDefinedException(String message,String currentState,String event){
+ super(message);
+ this.currentState = currentState;
+ this.event = event;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager.objects;\r
-\r
-public enum VNFOperationOutcome {\r
- SUCCESS,FAILURE,EXPIRE;\r
- public String toString(){\r
- return this.name();\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager.objects;
+
+public enum VNFOperationOutcome {
+ SUCCESS,FAILURE,EXPIRE;
+ public String toString(){
+ return this.name();
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.lifecyclemanager.impl;\r
-\r
-import com.att.eelf.configuration.EELFLogger;\r
-import com.att.eelf.configuration.EELFManager;\r
-import com.att.eelf.i18n.EELFResourceManager;\r
-import org.openecomp.appc.exceptions.InvalidInputException;\r
-import org.openecomp.appc.i18n.Msg;\r
-import org.openecomp.appc.lifecyclemanager.LifecycleManager;\r
-import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;\r
-import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;\r
-import org.openecomp.appc.statemachine.StateMachine;\r
-import org.openecomp.appc.statemachine.StateMetaDataReader;\r
-import org.openecomp.appc.statemachine.impl.StateMachineFactory;\r
-import org.openecomp.appc.statemachine.impl.readers.AppcOamMetaDataReader;\r
-import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader;\r
-import org.openecomp.appc.statemachine.objects.*;\r
-\r
-import java.util.Map;\r
-import java.util.concurrent.ConcurrentHashMap;\r
-\r
-public class LifecycleManagerImpl implements LifecycleManager{\r
-\r
- private StateMetaDataReader metadataReader;\r
- private static Map<String,StateMachine> stateMachineMap = new ConcurrentHashMap<>();\r
- private final EELFLogger logger = EELFManager.getInstance().getLogger(LifecycleManagerImpl.class);\r
- private final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();\r
-\r
- @Override\r
- public String getNextState(String vnfType, String currentState, String event) throws NoTransitionDefinedException,LifecycleException{\r
- if (logger.isTraceEnabled()) {\r
- logger.trace("Entering to getNextState with vnfType = "+ vnfType + ", currentState = " + currentState + ", event = " + event);\r
- }\r
-\r
- State nextState;\r
- StateMachine machine;\r
- StateMachineResponse response;\r
- try {\r
- machine = this.getStateMachine(vnfType);\r
- response = machine.handleEvent(new State(currentState),new Event(event));\r
- if(Response.NO_TRANSITION_DEFINED.equals(response.getResponse())){\r
- errorLogger.error(EELFResourceManager.format(Msg.VF_ILLEGAL_COMMAND, vnfType,event,currentState));\r
- throw new NoTransitionDefinedException("No Transition Defined for currentState = " + currentState + ", event = " + event,currentState,event);\r
- }\r
- nextState = response.getNextState();\r
- } catch (InvalidInputException e) {\r
- logger.error(e.getMessage());\r
- throw new LifecycleException(e,currentState,event);\r
- }\r
- if (logger.isTraceEnabled()) {\r
- logger.trace("Exiting from getNextState with (nextState = " + nextState.getStateName() + ")");\r
- }\r
- return nextState.getStateName();\r
- }\r
-\r
- private StateMachine getStateMachine(String vnfType){\r
- if (logger.isTraceEnabled()) {\r
- logger.trace("Entering to getNextState with vnfType = "+ vnfType);\r
- }\r
- if(vnfType == null){\r
- vnfType = "DEFAULT";\r
- }\r
- StateMachine machine = stateMachineMap.get(vnfType);\r
- if(machine == null){\r
- metadataReader = getMetadataReader(vnfType);\r
- StateMachineMetadata metadata = metadataReader.readMetadata();\r
- machine = StateMachineFactory.getStateMachine(metadata);\r
- stateMachineMap.put(vnfType,machine);\r
- }\r
-\r
- logger.trace("Exiting getStateMachine with StateMachine = " + stateMachineMap.get(vnfType).toString());\r
- return stateMachineMap.get(vnfType);\r
- }\r
-\r
- private StateMetaDataReader getMetadataReader(String vnfType) {\r
- return vnfType.equals("APPC") ? new AppcOamMetaDataReader() : new VnfMetaDataReader();\r
- }\r
-\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.lifecyclemanager.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.att.eelf.i18n.EELFResourceManager;
+import org.openecomp.appc.exceptions.InvalidInputException;
+import org.openecomp.appc.i18n.Msg;
+import org.openecomp.appc.lifecyclemanager.LifecycleManager;
+import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
+import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
+import org.openecomp.appc.statemachine.StateMachine;
+import org.openecomp.appc.statemachine.StateMetaDataReader;
+import org.openecomp.appc.statemachine.impl.StateMachineFactory;
+import org.openecomp.appc.statemachine.impl.readers.AppcOamMetaDataReader;
+import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader;
+import org.openecomp.appc.statemachine.objects.*;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class LifecycleManagerImpl implements LifecycleManager{
+
+ private StateMetaDataReader metadataReader;
+ private static Map<String,StateMachine> stateMachineMap = new ConcurrentHashMap<>();
+ private final EELFLogger logger = EELFManager.getInstance().getLogger(LifecycleManagerImpl.class);
+ private final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();
+
+ @Override
+ public String getNextState(String vnfType, String currentState, String event) throws NoTransitionDefinedException,LifecycleException{
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getNextState with vnfType = "+ vnfType + ", currentState = " + currentState + ", event = " + event);
+ }
+
+ State nextState;
+ StateMachine machine;
+ StateMachineResponse response;
+ try {
+ machine = this.getStateMachine(vnfType);
+ response = machine.handleEvent(new State(currentState),new Event(event));
+ if(Response.NO_TRANSITION_DEFINED.equals(response.getResponse())){
+ errorLogger.error(EELFResourceManager.format(Msg.VF_ILLEGAL_COMMAND, vnfType,event,currentState));
+ throw new NoTransitionDefinedException("No Transition Defined for currentState = " + currentState + ", event = " + event,currentState,event);
+ }
+ nextState = response.getNextState();
+ } catch (InvalidInputException e) {
+ logger.error(e.getMessage());
+ throw new LifecycleException(e,currentState,event);
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("Exiting from getNextState with (nextState = " + nextState.getStateName() + ")");
+ }
+ return nextState.getStateName();
+ }
+
+ private StateMachine getStateMachine(String vnfType){
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getNextState with vnfType = "+ vnfType);
+ }
+ if(vnfType == null){
+ vnfType = "DEFAULT";
+ }
+ StateMachine machine = stateMachineMap.get(vnfType);
+ if(machine == null){
+ metadataReader = getMetadataReader(vnfType);
+ StateMachineMetadata metadata = metadataReader.readMetadata();
+ machine = StateMachineFactory.getStateMachine(metadata);
+ stateMachineMap.put(vnfType,machine);
+ }
+
+ logger.trace("Exiting getStateMachine with StateMachine = " + stateMachineMap.get(vnfType).toString());
+ return stateMachineMap.get(vnfType);
+ }
+
+ private StateMetaDataReader getMetadataReader(String vnfType) {
+ return vnfType.equals("APPC") ? new AppcOamMetaDataReader() : new VnfMetaDataReader();
+ }
+
+}
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
================================================================================
- Copyright (C) 2017 Amdocs\r
- =============================================================================\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
- \r
- http://www.apache.org/licenses/LICENSE-2.0\r
- \r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
- \r
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+
ECOMP is a trademark and service mark of AT&T Intellectual Property.
- ============LICENSE_END=========================================================\r
- -->\r
-\r
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">\r
- <bean id="lifecycleManagerBean" class="org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl" scope="singleton">\r
- </bean>\r
-\r
- <service id="lcmService" interface="org.openecomp.appc.lifecyclemanager.LifecycleManager" ref="lifecycleManagerBean"/>\r
-\r
-</blueprint>\r
+ ============LICENSE_END=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+ <bean id="lifecycleManagerBean" class="org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl" scope="singleton">
+ </bean>
+
+ <service id="lcmService" interface="org.openecomp.appc.lifecyclemanager.LifecycleManager" ref="lifecycleManagerBean"/>
+
+</blueprint>
-###\r
+###
# ============LICENSE_START=======================================================
# ONAP : APPC
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
-# Copyright (C) 2017 Amdocs\r
-# =============================================================================\r
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-# \r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-# \r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License.\r
-# \r
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# 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.
+#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# ============LICENSE_END=========================================================\r
-###\r
-\r
-# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded \r
-# to supply configuration options \r
-org.openecomp.appc.bootstrap.file=appc.properties\r
-org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.\r
-\r
-#Property below provided by appc.properties\r
-appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm\r
-appc.LCM.poolMembers=<DMAAP_IP>:3904\r
-appc.LCM.service=dmaap\r
-appc.LCM.topic.write=APPC-TEST2\r
-appc.LCM.client.name=APPC-TEST-CLIENT-LC-MGMT-MAIN\r
-appc.LCM.provider.user=test\r
-appc.LCM.provider.pass=test\r
-\r
-\r
+# ============LICENSE_END=========================================================
+###
+
+# Define the name and path of any user-provided configuration (bootstrap) file that can be loaded
+# to supply configuration options
+org.openecomp.appc.bootstrap.file=appc.properties
+org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
+
+#Property below provided by appc.properties
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-LC-MGMT-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
+
+
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.openecomp.appc.exceptions.InvalidInputException;\r
-import org.openecomp.appc.lifecyclemanager.LifecycleManager;\r
-import org.openecomp.appc.statemachine.StateMetaDataReader;\r
-import org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl;\r
-import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;\r
-import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;\r
-import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader;\r
-import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader.VNFOperation;\r
-import org.openecomp.appc.statemachine.objects.Event;\r
-import org.openecomp.appc.statemachine.objects.State;\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-import org.openecomp.appc.statemachine.objects.Transition;\r
-\r
-import java.util.*;\r
-\r
-\r
-public class LifecycleManagerTest {\r
-\r
- private static final State[] VALID_LOCK_STATES = new State[] {\r
- new State("instantiated"),\r
- new State("configured"),\r
- new State("tested"),\r
- new State("running"),\r
- new State("error"),\r
- new State("unknown"),\r
- new State("created"),\r
- new State("not orchestrated"),\r
- new State("stopped"),\r
- };\r
-\r
- @Test\r
- public void handleEvent() throws InvalidInputException, LifecycleException, NoTransitionDefinedException {\r
-\r
- StateMachineMetadata metadata = getMetaDataReader().readMetadata();\r
- LifecycleManagerImpl lifecycleManager = new LifecycleManagerImpl();\r
-\r
- /*\r
- * Testing Positive Scenario passing the valid events and validating the StateMachineResponse\r
- */\r
- for(State state:metadata.getStates()){\r
-\r
- for(Transition transition:state.getTransitions()){\r
- Event event = transition.getEvent();\r
- State nextStateFromMetadata = transition.getNextState();\r
-\r
- String expectedNextState = lifecycleManager.getNextState(null,state.toString(),event.toString());\r
- Assert.assertEquals(expectedNextState,nextStateFromMetadata.toString());\r
- }\r
- }\r
-\r
- /*\r
- Testing Negative Scenarios, 1. Passing the valid Events for which Transition is not defined in\r
- Metadata and validating the StateMachineResponse 2. Passing the invalid events which are not\r
- registered as events in the StateMachineMetadata and validating StateMachineResponse\r
- */\r
- for(State state:metadata.getStates()){\r
-\r
- for(Transition transition:state.getTransitions()){\r
- List<Event> negativeEvents = getNegativeEvents(state,metadata.getEvents());\r
-\r
- for(Event negativeEvent:negativeEvents){\r
- boolean flag =false;\r
- try{\r
- lifecycleManager.getNextState(null,state.toString(),negativeEvent.toString());\r
-\r
- }\r
- catch (NoTransitionDefinedException e){\r
- flag =true;\r
- }\r
- Assert.assertEquals(flag,true);\r
-\r
- flag = false;\r
- try{\r
- lifecycleManager.getNextState(null,state.toString(),"PUT");\r
- }\r
- catch(LifecycleException e){\r
- flag = true;\r
- }\r
- Assert.assertTrue(flag);\r
-\r
- }\r
- }\r
- }\r
- }\r
-\r
- @Test\r
- public void testNotOrchestratedState() throws LifecycleException, NoTransitionDefinedException {\r
- LifecycleManager lifecycleManager = new LifecycleManagerImpl();\r
- String nextState = lifecycleManager.getNextState(\r
- null,"NOT ORCHESTRATED",VNFOperation.Configure.toString());\r
- Assert.assertEquals(nextState,"Configuring");\r
- }\r
-\r
- @Test(expected = NoTransitionDefinedException.class)\r
- public void testBakckingUpState() throws LifecycleException, NoTransitionDefinedException {\r
- LifecycleManager lifecycleManager = new LifecycleManagerImpl();\r
- lifecycleManager.getNextState(null,"Software_Uploading",VNFOperation.Configure.toString());\r
- }\r
-\r
- private List<Event> getNegativeEvents(State state,Set<Event> events) {\r
- List<Event> negativeEventList = new ArrayList<>();\r
- negativeEventList.addAll(events);\r
-\r
- for(Transition transition: state.getTransitions()){\r
- negativeEventList.remove(transition.getEvent());\r
- }\r
- return negativeEventList;\r
- }\r
-\r
- @Test\r
- public void testLockStates() throws LifecycleException, NoTransitionDefinedException {\r
- StateMachineMetadata metadata = getMetaDataReader().readMetadata();\r
- LifecycleManagerImpl lifecycleManager = new LifecycleManagerImpl();\r
-\r
- for(State state: metadata.getStates()) {\r
- if(isValidState(state, VALID_LOCK_STATES)) {\r
- assertSameNextState(lifecycleManager, state, VNFOperation.Lock);\r
- assertSameNextState(lifecycleManager, state, VnfMetaDataReader.VNFOperation.Unlock);\r
- assertSameNextState(lifecycleManager, state, VNFOperation.CheckLock);\r
- } else {\r
- assertNoNextState(lifecycleManager, state, VNFOperation.Lock);\r
- assertNoNextState(lifecycleManager, state, VNFOperation.Unlock);\r
- assertNoNextState(lifecycleManager, state, VNFOperation.CheckLock);\r
- }\r
- }\r
- }\r
-\r
- private boolean isValidState(State state, State[] validStates) {\r
- for(State validState: validStates) {\r
- if(validState.equals(state)) {\r
- return true;\r
- }\r
- }\r
- return false;\r
- }\r
-\r
- private void assertSameNextState(LifecycleManager lifecycleManager, State state, VNFOperation operation)\r
- throws LifecycleException, NoTransitionDefinedException {\r
- Assert.assertEquals(state.getStateName(),\r
- lifecycleManager.getNextState("no-matter", state.getStateName(), operation.toString()));\r
- }\r
-\r
- private void assertNoNextState(LifecycleManager lifecycleManager, State state, VNFOperation operation)\r
- throws LifecycleException {\r
- try {\r
- lifecycleManager.getNextState("no-matter", state.getStateName(), operation.toString());\r
- Assert.fail("lifecycleManager.getNextState() should fail for state [" + state\r
- + "], operation [" + operation + "]");\r
- } catch(NoTransitionDefinedException e) {\r
- // this exception is excepted\r
- }\r
- }\r
-\r
- private StateMetaDataReader getMetaDataReader() {\r
- return new VnfMetaDataReader();\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.appc.exceptions.InvalidInputException;
+import org.openecomp.appc.lifecyclemanager.LifecycleManager;
+import org.openecomp.appc.statemachine.StateMetaDataReader;
+import org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl;
+import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
+import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
+import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader;
+import org.openecomp.appc.statemachine.impl.readers.VnfMetaDataReader.VNFOperation;
+import org.openecomp.appc.statemachine.objects.Event;
+import org.openecomp.appc.statemachine.objects.State;
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+import org.openecomp.appc.statemachine.objects.Transition;
+
+import java.util.*;
+
+
+public class LifecycleManagerTest {
+
+ private static final State[] VALID_LOCK_STATES = new State[] {
+ new State("instantiated"),
+ new State("configured"),
+ new State("tested"),
+ new State("running"),
+ new State("error"),
+ new State("unknown"),
+ new State("created"),
+ new State("not orchestrated"),
+ new State("stopped"),
+ };
+
+ @Test
+ public void handleEvent() throws InvalidInputException, LifecycleException, NoTransitionDefinedException {
+
+ StateMachineMetadata metadata = getMetaDataReader().readMetadata();
+ LifecycleManagerImpl lifecycleManager = new LifecycleManagerImpl();
+
+ /*
+ * Testing Positive Scenario passing the valid events and validating the StateMachineResponse
+ */
+ for(State state:metadata.getStates()){
+
+ for(Transition transition:state.getTransitions()){
+ Event event = transition.getEvent();
+ State nextStateFromMetadata = transition.getNextState();
+
+ String expectedNextState = lifecycleManager.getNextState(null,state.toString(),event.toString());
+ Assert.assertEquals(expectedNextState,nextStateFromMetadata.toString());
+ }
+ }
+
+ /*
+ Testing Negative Scenarios, 1. Passing the valid Events for which Transition is not defined in
+ Metadata and validating the StateMachineResponse 2. Passing the invalid events which are not
+ registered as events in the StateMachineMetadata and validating StateMachineResponse
+ */
+ for(State state:metadata.getStates()){
+
+ for(Transition transition:state.getTransitions()){
+ List<Event> negativeEvents = getNegativeEvents(state,metadata.getEvents());
+
+ for(Event negativeEvent:negativeEvents){
+ boolean flag =false;
+ try{
+ lifecycleManager.getNextState(null,state.toString(),negativeEvent.toString());
+
+ }
+ catch (NoTransitionDefinedException e){
+ flag =true;
+ }
+ Assert.assertEquals(flag,true);
+
+ flag = false;
+ try{
+ lifecycleManager.getNextState(null,state.toString(),"PUT");
+ }
+ catch(LifecycleException e){
+ flag = true;
+ }
+ Assert.assertTrue(flag);
+
+ }
+ }
+ }
+ }
+
+ @Test
+ public void testNotOrchestratedState() throws LifecycleException, NoTransitionDefinedException {
+ LifecycleManager lifecycleManager = new LifecycleManagerImpl();
+ String nextState = lifecycleManager.getNextState(
+ null,"NOT ORCHESTRATED",VNFOperation.Configure.toString());
+ Assert.assertEquals(nextState,"Configuring");
+ }
+
+ @Test(expected = NoTransitionDefinedException.class)
+ public void testBakckingUpState() throws LifecycleException, NoTransitionDefinedException {
+ LifecycleManager lifecycleManager = new LifecycleManagerImpl();
+ lifecycleManager.getNextState(null,"Software_Uploading",VNFOperation.Configure.toString());
+ }
+
+ private List<Event> getNegativeEvents(State state,Set<Event> events) {
+ List<Event> negativeEventList = new ArrayList<>();
+ negativeEventList.addAll(events);
+
+ for(Transition transition: state.getTransitions()){
+ negativeEventList.remove(transition.getEvent());
+ }
+ return negativeEventList;
+ }
+
+ @Test
+ public void testLockStates() throws LifecycleException, NoTransitionDefinedException {
+ StateMachineMetadata metadata = getMetaDataReader().readMetadata();
+ LifecycleManagerImpl lifecycleManager = new LifecycleManagerImpl();
+
+ for(State state: metadata.getStates()) {
+ if(isValidState(state, VALID_LOCK_STATES)) {
+ assertSameNextState(lifecycleManager, state, VNFOperation.Lock);
+ assertSameNextState(lifecycleManager, state, VnfMetaDataReader.VNFOperation.Unlock);
+ assertSameNextState(lifecycleManager, state, VNFOperation.CheckLock);
+ } else {
+ assertNoNextState(lifecycleManager, state, VNFOperation.Lock);
+ assertNoNextState(lifecycleManager, state, VNFOperation.Unlock);
+ assertNoNextState(lifecycleManager, state, VNFOperation.CheckLock);
+ }
+ }
+ }
+
+ private boolean isValidState(State state, State[] validStates) {
+ for(State validState: validStates) {
+ if(validState.equals(state)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private void assertSameNextState(LifecycleManager lifecycleManager, State state, VNFOperation operation)
+ throws LifecycleException, NoTransitionDefinedException {
+ Assert.assertEquals(state.getStateName(),
+ lifecycleManager.getNextState("no-matter", state.getStateName(), operation.toString()));
+ }
+
+ private void assertNoNextState(LifecycleManager lifecycleManager, State state, VNFOperation operation)
+ throws LifecycleException {
+ try {
+ lifecycleManager.getNextState("no-matter", state.getStateName(), operation.toString());
+ Assert.fail("lifecycleManager.getNextState() should fail for state [" + state
+ + "], operation [" + operation + "]");
+ } catch(NoTransitionDefinedException e) {
+ // this exception is excepted
+ }
+ }
+
+ private StateMetaDataReader getMetaDataReader() {
+ return new VnfMetaDataReader();
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Rule;\r
-import org.junit.Test;\r
-import org.junit.rules.ExpectedException;\r
-import org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl;\r
-import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;\r
-import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;\r
-import org.openecomp.appc.statemachine.impl.readers.AppcOamMetaDataReader;\r
-import org.openecomp.appc.statemachine.impl.readers.AppcOamStates;\r
-\r
-import java.util.Arrays;\r
-import java.util.List;\r
-\r
-\r
-public class OamLifeCycleManagerTest {\r
- private static final String VNF_TYPE_APPC = "APPC";\r
- private static final String NO_DEFINITION_FORMAT = "No Transition Defined for currentState = %s, event = %s";\r
-\r
- private LifecycleManagerImpl lifecycleManager;\r
-\r
- @Rule\r
- public ExpectedException expectedException = ExpectedException.none();\r
-\r
- @Before\r
- public void setUp() throws Exception {\r
- lifecycleManager = new LifecycleManagerImpl();\r
- }\r
-\r
- private void validateProper(String state, String event, String expectedResult)\r
- throws LifecycleException, NoTransitionDefinedException {\r
- String nextState = lifecycleManager.getNextState(VNF_TYPE_APPC, state, event);\r
- Assert.assertEquals(String.format("Should return %s", expectedResult), expectedResult, nextState);\r
- }\r
-\r
- private void validateException(String state, String event) throws LifecycleException, NoTransitionDefinedException {\r
- expectedException.expect(NoTransitionDefinedException.class);\r
- expectedException.expectMessage(String.format(NO_DEFINITION_FORMAT, state, event));\r
- lifecycleManager.getNextState(VNF_TYPE_APPC, state, event);\r
-\r
- // Reset to no expectation\r
- expectedException = ExpectedException.none();\r
- }\r
-\r
- @Test\r
- public void testOamStateTransitionForMaintenanceMode() throws Exception {\r
- String event = AppcOamMetaDataReader.AppcOperation.MaintenanceMode.name();\r
- String expecteResult = AppcOamStates.EnteringMaintenanceMode.toString();\r
-\r
- for (AppcOamStates appcOamStates : AppcOamStates.values()) {\r
- String state = appcOamStates.toString();\r
- if (appcOamStates == AppcOamStates.Started) {\r
- validateProper(state, event, expecteResult);\r
- } else {\r
- validateException(state, event);\r
- }\r
- }\r
- }\r
-\r
- @Test\r
- public void testOamStateTransitionForStart() throws Exception {\r
- String event = AppcOamMetaDataReader.AppcOperation.Start.name();\r
- String expectResult = AppcOamStates.Starting.toString();\r
-\r
- List<AppcOamStates> goodStates = Arrays.asList(\r
- AppcOamStates.MaintenanceMode,\r
- AppcOamStates.Stopped,\r
- AppcOamStates.Stopping);\r
-\r
- for (AppcOamStates appcOamStates : AppcOamStates.values()) {\r
- String state = appcOamStates.toString();\r
- if (goodStates.contains(appcOamStates)) {\r
- validateProper(state, event, expectResult);\r
- } else {\r
- validateException(state, event);\r
- }\r
- }\r
- }\r
-\r
- @Test\r
- public void testOamStateTransitionForStop() throws Exception {\r
- String event = AppcOamMetaDataReader.AppcOperation.Stop.name();\r
- String expectResult = AppcOamStates.Stopping.toString();\r
-\r
- List<AppcOamStates> goodStates = Arrays.asList(\r
- AppcOamStates.Error,\r
- AppcOamStates.EnteringMaintenanceMode,\r
- AppcOamStates.MaintenanceMode,\r
- AppcOamStates.Started,\r
- AppcOamStates.Starting);\r
-\r
- for (AppcOamStates appcOamStates : AppcOamStates.values()) {\r
- String state = appcOamStates.toString();\r
- if (goodStates.contains(appcOamStates)) {\r
- validateProper(state, event, expectResult);\r
- } else {\r
- validateException(state, event);\r
- }\r
- }\r
- }\r
-\r
-\r
- @Test\r
- public void testOamStateTransitionForRestart() throws Exception {\r
- String event = AppcOamMetaDataReader.AppcOperation.Restart.name();\r
- String expectResult = AppcOamStates.Restarting.toString();\r
-\r
- List<AppcOamStates> goodStates = Arrays.asList(\r
- AppcOamStates.Error,\r
- AppcOamStates.EnteringMaintenanceMode,\r
- AppcOamStates.MaintenanceMode,\r
- AppcOamStates.Started,\r
- AppcOamStates.Starting,\r
- AppcOamStates.Stopped,\r
- AppcOamStates.Stopping);\r
-\r
- for (AppcOamStates appcOamStates : AppcOamStates.values()) {\r
- String state = appcOamStates.toString();\r
- if (goodStates.contains(appcOamStates)) {\r
- validateProper(state, event, expectResult);\r
- } else {\r
- validateException(state, event);\r
- }\r
- }\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.openecomp.appc.lifecyclemanager.impl.LifecycleManagerImpl;
+import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
+import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
+import org.openecomp.appc.statemachine.impl.readers.AppcOamMetaDataReader;
+import org.openecomp.appc.statemachine.impl.readers.AppcOamStates;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+public class OamLifeCycleManagerTest {
+ private static final String VNF_TYPE_APPC = "APPC";
+ private static final String NO_DEFINITION_FORMAT = "No Transition Defined for currentState = %s, event = %s";
+
+ private LifecycleManagerImpl lifecycleManager;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void setUp() throws Exception {
+ lifecycleManager = new LifecycleManagerImpl();
+ }
+
+ private void validateProper(String state, String event, String expectedResult)
+ throws LifecycleException, NoTransitionDefinedException {
+ String nextState = lifecycleManager.getNextState(VNF_TYPE_APPC, state, event);
+ Assert.assertEquals(String.format("Should return %s", expectedResult), expectedResult, nextState);
+ }
+
+ private void validateException(String state, String event) throws LifecycleException, NoTransitionDefinedException {
+ expectedException.expect(NoTransitionDefinedException.class);
+ expectedException.expectMessage(String.format(NO_DEFINITION_FORMAT, state, event));
+ lifecycleManager.getNextState(VNF_TYPE_APPC, state, event);
+
+ // Reset to no expectation
+ expectedException = ExpectedException.none();
+ }
+
+ @Test
+ public void testOamStateTransitionForMaintenanceMode() throws Exception {
+ String event = AppcOamMetaDataReader.AppcOperation.MaintenanceMode.name();
+ String expecteResult = AppcOamStates.EnteringMaintenanceMode.toString();
+
+ for (AppcOamStates appcOamStates : AppcOamStates.values()) {
+ String state = appcOamStates.toString();
+ if (appcOamStates == AppcOamStates.Started) {
+ validateProper(state, event, expecteResult);
+ } else {
+ validateException(state, event);
+ }
+ }
+ }
+
+ @Test
+ public void testOamStateTransitionForStart() throws Exception {
+ String event = AppcOamMetaDataReader.AppcOperation.Start.name();
+ String expectResult = AppcOamStates.Starting.toString();
+
+ List<AppcOamStates> goodStates = Arrays.asList(
+ AppcOamStates.MaintenanceMode,
+ AppcOamStates.Stopped,
+ AppcOamStates.Stopping);
+
+ for (AppcOamStates appcOamStates : AppcOamStates.values()) {
+ String state = appcOamStates.toString();
+ if (goodStates.contains(appcOamStates)) {
+ validateProper(state, event, expectResult);
+ } else {
+ validateException(state, event);
+ }
+ }
+ }
+
+ @Test
+ public void testOamStateTransitionForStop() throws Exception {
+ String event = AppcOamMetaDataReader.AppcOperation.Stop.name();
+ String expectResult = AppcOamStates.Stopping.toString();
+
+ List<AppcOamStates> goodStates = Arrays.asList(
+ AppcOamStates.Error,
+ AppcOamStates.EnteringMaintenanceMode,
+ AppcOamStates.MaintenanceMode,
+ AppcOamStates.Started,
+ AppcOamStates.Starting);
+
+ for (AppcOamStates appcOamStates : AppcOamStates.values()) {
+ String state = appcOamStates.toString();
+ if (goodStates.contains(appcOamStates)) {
+ validateProper(state, event, expectResult);
+ } else {
+ validateException(state, event);
+ }
+ }
+ }
+
+
+ @Test
+ public void testOamStateTransitionForRestart() throws Exception {
+ String event = AppcOamMetaDataReader.AppcOperation.Restart.name();
+ String expectResult = AppcOamStates.Restarting.toString();
+
+ List<AppcOamStates> goodStates = Arrays.asList(
+ AppcOamStates.Error,
+ AppcOamStates.EnteringMaintenanceMode,
+ AppcOamStates.MaintenanceMode,
+ AppcOamStates.Started,
+ AppcOamStates.Starting,
+ AppcOamStates.Stopped,
+ AppcOamStates.Stopping);
+
+ for (AppcOamStates appcOamStates : AppcOamStates.values()) {
+ String state = appcOamStates.toString();
+ if (goodStates.contains(appcOamStates)) {
+ validateProper(state, event, expectResult);
+ } else {
+ validateException(state, event);
+ }
+ }
+ }
+}
-<?xml version="1.0" encoding="UTF-8"?>\r
-<!--\r
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
================================================================================
- Copyright (C) 2017 Amdocs\r
- =============================================================================\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
- \r
- http://www.apache.org/licenses/LICENSE-2.0\r
- \r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
- \r
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+
ECOMP is a trademark and service mark of AT&T Intellectual Property.
- ============LICENSE_END=========================================================\r
- -->\r
-\r
-\r
-<features name="appc-lifecycle-management-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">\r
-\r
- <feature name='appc-lifecycle-management' description="application executor" version='${project.version}'>\r
- <bundle dependency="true">mvn:org.openecomp.appc/appc-common/${project.version}</bundle>\r
- <bundle>mvn:org.openecomp.appc/state-machine-lib/${project.version}</bundle>\r
- <bundle>mvn:org.openecomp.appc/appc-lifecycle-management-api/${project.version}</bundle>\r
- <bundle>mvn:org.openecomp.appc/appc-lifecycle-management-core/${project.version}</bundle>\r
- </feature>\r
-\r
-</features>\r
+ ============LICENSE_END=========================================================
+ -->
+
+
+<features name="appc-lifecycle-management-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
+
+ <feature name='appc-lifecycle-management' description="application executor" version='${project.version}'>
+ <bundle dependency="true">mvn:org.openecomp.appc/appc-common/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/state-machine-lib/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/appc-lifecycle-management-api/${project.version}</bundle>
+ <bundle>mvn:org.openecomp.appc/appc-lifecycle-management-core/${project.version}</bundle>
+ </feature>
+
+</features>
-<!--\r
+<!--
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
================================================================================
- Copyright (C) 2017 Amdocs\r
- =============================================================================\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
- \r
- http://www.apache.org/licenses/LICENSE-2.0\r
- \r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
- \r
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+
ECOMP is a trademark and service mark of AT&T Intellectual Property.
- ============LICENSE_END=========================================================\r
- -->\r
-\r
-<!-- Defines how we build the .zip file which is our distribution. -->\r
-\r
-<assembly\r
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">\r
- <id>controller</id>\r
- <formats>\r
- <format>zip</format>\r
- </formats>\r
-\r
- <!-- we want "system" and related files right at the root level\r
- as this file is suppose to be unzip on top of a karaf\r
- distro. -->\r
- <includeBaseDirectory>false</includeBaseDirectory>\r
-\r
- <fileSets>\r
- <fileSet>\r
- <directory>target/stage/</directory>\r
- <outputDirectory>${application.name}</outputDirectory>\r
- <fileMode>755</fileMode>\r
- <includes>\r
- <include>*.sh</include>\r
- </includes>\r
- </fileSet>\r
- <fileSet>\r
- <directory>target/stage/</directory>\r
- <outputDirectory>${application.name}</outputDirectory>\r
- <fileMode>644</fileMode>\r
- <excludes>\r
- <exclude>*.sh</exclude>\r
- </excludes>\r
- </fileSet>\r
- </fileSets>\r
-\r
-</assembly>\r
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>controller</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>755</fileMode>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/stage/</directory>
+ <outputDirectory>${application.name}</outputDirectory>
+ <fileMode>644</fileMode>
+ <excludes>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
-<!--\r
+<!--
============LICENSE_START=======================================================
ONAP : APPC
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
================================================================================
- Copyright (C) 2017 Amdocs\r
- =============================================================================\r
- Licensed under the Apache License, Version 2.0 (the "License");\r
- you may not use this file except in compliance with the License.\r
- You may obtain a copy of the License at\r
- \r
- http://www.apache.org/licenses/LICENSE-2.0\r
- \r
- Unless required by applicable law or agreed to in writing, software\r
- distributed under the License is distributed on an "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- See the License for the specific language governing permissions and\r
- limitations under the License.\r
- \r
+ Copyright (C) 2017 Amdocs
+ =============================================================================
+ 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.
+
ECOMP is a trademark and service mark of AT&T Intellectual Property.
- ============LICENSE_END=========================================================\r
- -->\r
-\r
-<!-- Defines how we build the .zip file which is our distribution. -->\r
-\r
-<assembly\r
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0\r
- http://maven.apache.org/xsd/assembly-1.1.0.xsd">\r
- <id>controller</id>\r
- <formats>\r
- <format>zip</format>\r
- </formats>\r
-\r
- <!-- we want "system" and related files right at the root level\r
- as this file is suppose to be unzip on top of a karaf\r
- distro. -->\r
- <includeBaseDirectory>false</includeBaseDirectory>\r
-\r
- <fileSets>\r
- <fileSet>\r
- <directory>target/assembly/</directory>\r
- <outputDirectory>.</outputDirectory>\r
- <excludes>\r
- </excludes>\r
- </fileSet>\r
- </fileSets>\r
-\r
-</assembly>\r
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- Defines how we build the .zip file which is our distribution. -->
+
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
+ http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+ <id>controller</id>
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <!-- we want "system" and related files right at the root level
+ as this file is suppose to be unzip on top of a karaf
+ distro. -->
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <fileSets>
+ <fileSet>
+ <directory>target/assembly/</directory>
+ <outputDirectory>.</outputDirectory>
+ <excludes>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
-###\r
+###
# ============LICENSE_START=======================================================
# ONAP : APPC
# ================================================================================
# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
# ================================================================================
-# Copyright (C) 2017 Amdocs\r
-# =============================================================================\r
-# Licensed under the Apache License, Version 2.0 (the "License");\r
-# you may not use this file except in compliance with the License.\r
-# You may obtain a copy of the License at\r
-# \r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-# \r
-# Unless required by applicable law or agreed to in writing, software\r
-# distributed under the License is distributed on an "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# See the License for the specific language governing permissions and\r
-# limitations under the License.\r
-# \r
+# Copyright (C) 2017 Amdocs
+# =============================================================================
+# 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.
+#
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
-# ============LICENSE_END=========================================================\r
-###\r
-\r
-#!/bin/bash\r
-\r
-ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}\r
-ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}\r
-ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}\r
-INSTALLERDIR=$(dirname $0)\r
-\r
-REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip\r
-\r
-if [ -f ${REPOZIP} ]\r
-then\r
- unzip -n -d ${ODL_HOME} ${REPOZIP}\r
-else\r
- echo "ERROR : repo zip ($REPOZIP) not found"\r
- exit 1\r
-fi\r
-\r
-COUNT=0\r
-while [ $COUNT -lt 10 ]; do\r
- ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} 2> /tmp/installErr\r
- cat /tmp/installErr\r
- if grep -q 'Failed to get the session' /tmp/installErr; then\r
- sleep 10\r
- else\r
- let COUNT=10\r
- fi\r
- let COUNT=COUNT+1\r
-done\r
-COUNT=0\r
-while [ $COUNT -lt 10 ]; do\r
- ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} 2> /tmp/installErr\r
- cat /tmp/installErr\r
- if grep -q 'Failed to get the session' /tmp/installErr; then\r
- sleep 10\r
- else\r
- let COUNT=10\r
- fi\r
- let COUNT=COUNT+1\r
-done\r
+# ============LICENSE_END=========================================================
+###
+
+#!/bin/bash
+
+ODL_HOME=${ODL_HOME:-/opt/opendaylight/current}
+ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client}
+ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"}
+INSTALLERDIR=$(dirname $0)
+
+REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip
+
+if [ -f ${REPOZIP} ]
+then
+ unzip -n -d ${ODL_HOME} ${REPOZIP}
+else
+ echo "ERROR : repo zip ($REPOZIP) not found"
+ exit 1
+fi
+
+COUNT=0
+while [ $COUNT -lt 10 ]; do
+ ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} 2> /tmp/installErr
+ cat /tmp/installErr
+ if grep -q 'Failed to get the session' /tmp/installErr; then
+ sleep 10
+ else
+ let COUNT=10
+ fi
+ let COUNT=COUNT+1
+done
+COUNT=0
+while [ $COUNT -lt 10 ]; do
+ ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} 2> /tmp/installErr
+ cat /tmp/installErr
+ if grep -q 'Failed to get the session' /tmp/installErr; then
+ sleep 10
+ else
+ let COUNT=10
+ fi
+ let COUNT=COUNT+1
+done
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine;\r
-\r
-import org.openecomp.appc.exceptions.InvalidInputException;\r
-import org.openecomp.appc.statemachine.objects.Event;\r
-import org.openecomp.appc.statemachine.objects.State;\r
-import org.openecomp.appc.statemachine.objects.StateMachineResponse;\r
-\r
-public interface StateMachine {\r
- StateMachineResponse handleEvent(State currentState, Event event) throws InvalidInputException;\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine;
+
+import org.openecomp.appc.exceptions.InvalidInputException;
+import org.openecomp.appc.statemachine.objects.Event;
+import org.openecomp.appc.statemachine.objects.State;
+import org.openecomp.appc.statemachine.objects.StateMachineResponse;
+
+public interface StateMachine {
+ StateMachineResponse handleEvent(State currentState, Event event) throws InvalidInputException;
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine;\r
-\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-\r
-public interface StateMetaDataReader {\r
- StateMachineMetadata readMetadata();\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine;
+
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+
+public interface StateMetaDataReader {
+ StateMachineMetadata readMetadata();
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl;\r
-\r
-import org.openecomp.appc.statemachine.StateMachine;\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-\r
-\r
-public class StateMachineFactory {\r
-\r
- private StateMachineFactory(){\r
-\r
- }\r
-\r
- public static StateMachine getStateMachine(StateMachineMetadata metadata){\r
- return new StateMachineImpl(metadata);\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl;
+
+import org.openecomp.appc.statemachine.StateMachine;
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+
+
+public class StateMachineFactory {
+
+ private StateMachineFactory(){
+
+ }
+
+ public static StateMachine getStateMachine(StateMachineMetadata metadata){
+ return new StateMachineImpl(metadata);
+ }
+}
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP : APPC\r
- * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
- * ================================================================================\r
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- * \r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * \r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.openecomp.appc.exceptions.InvalidInputException;\r
-import org.openecomp.appc.statemachine.StateMachine;\r
-import org.openecomp.appc.statemachine.objects.Event;\r
-import org.openecomp.appc.statemachine.objects.Response;\r
-import org.openecomp.appc.statemachine.objects.State;\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-import org.openecomp.appc.statemachine.objects.StateMachineResponse;\r
-import org.openecomp.appc.statemachine.objects.Transition;\r
-\r
-\r
-public class StateMachineImpl implements StateMachine {\r
-\r
- private final Set<State> states;\r
-\r
- private final Set<Event> events;\r
-\r
- StateMachineImpl(StateMachineMetadata metadata){\r
- this.states = new HashSet<>();\r
- this.states.addAll(metadata.getStates());\r
- this.events = new HashSet<>();\r
- this.events.addAll(metadata.getEvents());\r
- }\r
-\r
- public StateMachineResponse handleEvent(State inputState, Event event) throws InvalidInputException{\r
-\r
- if(!validateInputs(inputState,event)){\r
- throw new InvalidInputException("VNF State or incoming event is invalid. State = " +inputState + " event = " + event );\r
- }\r
-\r
- StateMachineResponse response = new StateMachineResponse();\r
- State currentState = null,nextState = null;\r
- for(State stateInSet:states){\r
- if(stateInSet.equals(inputState)){\r
- currentState = stateInSet;\r
- break;\r
- }\r
- }\r
- if (currentState != null) {\r
- for (Transition transition : currentState.getTransitions()) {\r
- if (event.equals(transition.getEvent())) {\r
- nextState = transition.getNextState();\r
- }\r
- }\r
- }\r
- if(nextState == null){\r
- response.setResponse(Response.NO_TRANSITION_DEFINED);\r
- }\r
- else if(inputState.equals(nextState)){\r
- response.setResponse(Response.NO_STATE_CHANGE);\r
- }\r
- else{\r
- response.setResponse(Response.VALID_TRANSITION);\r
- }\r
- response.setNextState(nextState);\r
- return response;\r
- }\r
-\r
- private boolean validateInputs(State state,Event event) {\r
- return state != null && event != null && this.states.contains(state) && this.events.contains(event);\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return "StateMachineImpl{" +\r
- "states=" + states +\r
- ", events=" + events +\r
- '}';\r
- }\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.openecomp.appc.exceptions.InvalidInputException;
+import org.openecomp.appc.statemachine.StateMachine;
+import org.openecomp.appc.statemachine.objects.Event;
+import org.openecomp.appc.statemachine.objects.Response;
+import org.openecomp.appc.statemachine.objects.State;
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+import org.openecomp.appc.statemachine.objects.StateMachineResponse;
+import org.openecomp.appc.statemachine.objects.Transition;
+
+
+public class StateMachineImpl implements StateMachine {
+
+ private final Set<State> states;
+
+ private final Set<Event> events;
+
+ StateMachineImpl(StateMachineMetadata metadata){
+ this.states = new HashSet<>();
+ this.states.addAll(metadata.getStates());
+ this.events = new HashSet<>();
+ this.events.addAll(metadata.getEvents());
+ }
+
+ public StateMachineResponse handleEvent(State inputState, Event event) throws InvalidInputException{
+
+ if(!validateInputs(inputState,event)){
+ throw new InvalidInputException("VNF State or incoming event is invalid. State = " +inputState + " event = " + event );
+ }
+
+ StateMachineResponse response = new StateMachineResponse();
+ State currentState = null,nextState = null;
+ for(State stateInSet:states){
+ if(stateInSet.equals(inputState)){
+ currentState = stateInSet;
+ break;
+ }
+ }
+ if (currentState != null) {
+ for (Transition transition : currentState.getTransitions()) {
+ if (event.equals(transition.getEvent())) {
+ nextState = transition.getNextState();
+ }
+ }
+ }
+ if(nextState == null){
+ response.setResponse(Response.NO_TRANSITION_DEFINED);
+ }
+ else if(inputState.equals(nextState)){
+ response.setResponse(Response.NO_STATE_CHANGE);
+ }
+ else{
+ response.setResponse(Response.VALID_TRANSITION);
+ }
+ response.setNextState(nextState);
+ return response;
+ }
+
+ private boolean validateInputs(State state,Event event) {
+ return state != null && event != null && this.states.contains(state) && this.events.contains(event);
+ }
+
+ @Override
+ public String toString() {
+ return "StateMachineImpl{" +
+ "states=" + states +
+ ", events=" + events +
+ '}';
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl.readers;\r
-\r
-import org.openecomp.appc.statemachine.StateMetaDataReader;\r
-import org.openecomp.appc.statemachine.objects.Event;\r
-import org.openecomp.appc.statemachine.objects.State;\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-\r
-public class AppcOamMetaDataReader implements StateMetaDataReader {\r
-\r
- public enum AppcOperation {\r
- MaintenanceMode,\r
- Restart,\r
- Start,\r
- Stop\r
- }\r
-\r
- @Override\r
- public StateMachineMetadata readMetadata() {\r
- State NOT_INSTANTIATED = new State(AppcOamStates.NotInstantiated.toString());\r
- State INSTANTIATED = new State(AppcOamStates.Instantiated.toString());\r
- State RESTARTING = new State(AppcOamStates.Restarting.toString());\r
- State STARTING = new State(AppcOamStates.Starting.toString());\r
- State STARTED = new State(AppcOamStates.Started.toString());\r
- State ENTERING_MAINTENANCE_MODE = new State(AppcOamStates.EnteringMaintenanceMode.toString());\r
- State MAINTENANCE_MODE = new State(AppcOamStates.MaintenanceMode.toString());\r
- State ERROR = new State(AppcOamStates.Error.toString());\r
- State UNKNOWN = new State(AppcOamStates.Unknown.toString());\r
- State STOPPING = new State(AppcOamStates.Stopping.toString());\r
- State STOPPED = new State(AppcOamStates.Stopped.toString());\r
-\r
- Event START = new Event(AppcOperation.Start.toString());\r
- Event STOP = new Event(AppcOperation.Stop.toString());\r
- Event MAINTENANCE_MODE_EVENT = new Event(AppcOperation.MaintenanceMode.toString());\r
- Event RESTART = new Event(AppcOperation.Restart.toString());\r
-\r
- StateMachineMetadata.StateMachineMetadataBuilder builder = new StateMachineMetadata\r
- .StateMachineMetadataBuilder();\r
-\r
- builder = builder.addState(NOT_INSTANTIATED);\r
- builder = builder.addState(INSTANTIATED);\r
- builder = builder.addState(STARTING);\r
- builder = builder.addState(STARTED);\r
- builder = builder.addState(ERROR);\r
- builder = builder.addState(UNKNOWN);\r
- builder = builder.addState(STOPPING);\r
- builder = builder.addState(STOPPED);\r
- builder = builder.addState(ENTERING_MAINTENANCE_MODE);\r
- builder = builder.addState(MAINTENANCE_MODE);\r
- builder = builder.addState(RESTARTING);\r
-\r
- builder = builder.addEvent(START);\r
- builder = builder.addEvent(STOP);\r
- builder = builder.addEvent(RESTART);\r
- builder = builder.addEvent(MAINTENANCE_MODE_EVENT);\r
-\r
- /*\r
- * for addTransition:\r
- * param 1: current state; param 2: received command/request; param 3: new transition state\r
- */\r
- // start\r
- builder = builder.addTransition(STOPPED, START, STARTING);\r
- builder = builder.addTransition(MAINTENANCE_MODE, START, STARTING);\r
- builder = builder.addTransition(ERROR, START, STARTING);\r
- // stop\r
- builder = builder.addTransition(STARTED, STOP, STOPPING);\r
- builder = builder.addTransition(STARTING, STOP, STOPPING);\r
- builder = builder.addTransition(ENTERING_MAINTENANCE_MODE, STOP, STOPPING);\r
- builder = builder.addTransition(MAINTENANCE_MODE, STOP, STOPPING);\r
- builder = builder.addTransition(ERROR, STOP, STOPPING);\r
- // maintenance mode\r
- builder = builder.addTransition(\r
- STARTED, MAINTENANCE_MODE_EVENT, ENTERING_MAINTENANCE_MODE);\r
- // restart\r
- builder = builder.addTransition(STOPPED, RESTART, RESTARTING);\r
- builder = builder.addTransition(STARTING, RESTART, RESTARTING);\r
- builder = builder.addTransition(STARTED, RESTART, RESTARTING);\r
- builder = builder.addTransition(ENTERING_MAINTENANCE_MODE, RESTART, RESTARTING);\r
- builder = builder.addTransition(MAINTENANCE_MODE, RESTART, RESTARTING);\r
- builder = builder.addTransition(ERROR, RESTART, RESTARTING);\r
-\r
- return builder.build();\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl.readers;
+
+import org.openecomp.appc.statemachine.StateMetaDataReader;
+import org.openecomp.appc.statemachine.objects.Event;
+import org.openecomp.appc.statemachine.objects.State;
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+
+public class AppcOamMetaDataReader implements StateMetaDataReader {
+
+ public enum AppcOperation {
+ MaintenanceMode,
+ Restart,
+ Start,
+ Stop
+ }
+
+ @Override
+ public StateMachineMetadata readMetadata() {
+ State NOT_INSTANTIATED = new State(AppcOamStates.NotInstantiated.toString());
+ State INSTANTIATED = new State(AppcOamStates.Instantiated.toString());
+ State RESTARTING = new State(AppcOamStates.Restarting.toString());
+ State STARTING = new State(AppcOamStates.Starting.toString());
+ State STARTED = new State(AppcOamStates.Started.toString());
+ State ENTERING_MAINTENANCE_MODE = new State(AppcOamStates.EnteringMaintenanceMode.toString());
+ State MAINTENANCE_MODE = new State(AppcOamStates.MaintenanceMode.toString());
+ State ERROR = new State(AppcOamStates.Error.toString());
+ State UNKNOWN = new State(AppcOamStates.Unknown.toString());
+ State STOPPING = new State(AppcOamStates.Stopping.toString());
+ State STOPPED = new State(AppcOamStates.Stopped.toString());
+
+ Event START = new Event(AppcOperation.Start.toString());
+ Event STOP = new Event(AppcOperation.Stop.toString());
+ Event MAINTENANCE_MODE_EVENT = new Event(AppcOperation.MaintenanceMode.toString());
+ Event RESTART = new Event(AppcOperation.Restart.toString());
+
+ StateMachineMetadata.StateMachineMetadataBuilder builder = new StateMachineMetadata
+ .StateMachineMetadataBuilder();
+
+ builder = builder.addState(NOT_INSTANTIATED);
+ builder = builder.addState(INSTANTIATED);
+ builder = builder.addState(STARTING);
+ builder = builder.addState(STARTED);
+ builder = builder.addState(ERROR);
+ builder = builder.addState(UNKNOWN);
+ builder = builder.addState(STOPPING);
+ builder = builder.addState(STOPPED);
+ builder = builder.addState(ENTERING_MAINTENANCE_MODE);
+ builder = builder.addState(MAINTENANCE_MODE);
+ builder = builder.addState(RESTARTING);
+
+ builder = builder.addEvent(START);
+ builder = builder.addEvent(STOP);
+ builder = builder.addEvent(RESTART);
+ builder = builder.addEvent(MAINTENANCE_MODE_EVENT);
+
+ /*
+ * for addTransition:
+ * param 1: current state; param 2: received command/request; param 3: new transition state
+ */
+ // start
+ builder = builder.addTransition(STOPPED, START, STARTING);
+ builder = builder.addTransition(MAINTENANCE_MODE, START, STARTING);
+ builder = builder.addTransition(ERROR, START, STARTING);
+ // stop
+ builder = builder.addTransition(STARTED, STOP, STOPPING);
+ builder = builder.addTransition(STARTING, STOP, STOPPING);
+ builder = builder.addTransition(ENTERING_MAINTENANCE_MODE, STOP, STOPPING);
+ builder = builder.addTransition(MAINTENANCE_MODE, STOP, STOPPING);
+ builder = builder.addTransition(ERROR, STOP, STOPPING);
+ // maintenance mode
+ builder = builder.addTransition(
+ STARTED, MAINTENANCE_MODE_EVENT, ENTERING_MAINTENANCE_MODE);
+ // restart
+ builder = builder.addTransition(STOPPED, RESTART, RESTARTING);
+ builder = builder.addTransition(STARTING, RESTART, RESTARTING);
+ builder = builder.addTransition(STARTED, RESTART, RESTARTING);
+ builder = builder.addTransition(ENTERING_MAINTENANCE_MODE, RESTART, RESTARTING);
+ builder = builder.addTransition(MAINTENANCE_MODE, RESTART, RESTARTING);
+ builder = builder.addTransition(ERROR, RESTART, RESTARTING);
+
+ return builder.build();
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl.readers;\r
-\r
-import org.osgi.framework.Bundle;\r
-\r
-public enum AppcOamStates {\r
- EnteringMaintenanceMode(0),\r
- Error(0),\r
- Instantiated(Bundle.INSTALLED),\r
- MaintenanceMode(0),\r
- NotInstantiated(Bundle.UNINSTALLED),\r
- Restarting(0),\r
- Started(Bundle.ACTIVE),\r
- Starting(Bundle.STARTING),\r
- Stopped(Bundle.RESOLVED),\r
- Stopping(Bundle.STOPPING),\r
- Unknown(0);\r
-\r
- int osgiBundleState;\r
-\r
- AppcOamStates(Integer bundleState) {\r
- osgiBundleState = bundleState;\r
- }\r
-\r
- public static AppcOamStates getOamStateFromBundleState(int bundleState) {\r
- for (AppcOamStates aState : values()) {\r
- if (aState.osgiBundleState == bundleState) {\r
- return aState;\r
- }\r
- }\r
- return Unknown;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl.readers;
+
+import org.osgi.framework.Bundle;
+
+public enum AppcOamStates {
+ EnteringMaintenanceMode(0),
+ Error(0),
+ Instantiated(Bundle.INSTALLED),
+ MaintenanceMode(0),
+ NotInstantiated(Bundle.UNINSTALLED),
+ Restarting(0),
+ Started(Bundle.ACTIVE),
+ Starting(Bundle.STARTING),
+ Stopped(Bundle.RESOLVED),
+ Stopping(Bundle.STOPPING),
+ Unknown(0);
+
+ int osgiBundleState;
+
+ AppcOamStates(Integer bundleState) {
+ osgiBundleState = bundleState;
+ }
+
+ public static AppcOamStates getOamStateFromBundleState(int bundleState) {
+ for (AppcOamStates aState : values()) {
+ if (aState.osgiBundleState == bundleState) {
+ return aState;
+ }
+ }
+ return Unknown;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl.readers;\r
-\r
-import org.openecomp.appc.statemachine.StateMetaDataReader;\r
-import org.openecomp.appc.lifecyclemanager.objects.VNFOperationOutcome;\r
-import org.openecomp.appc.statemachine.objects.Event;\r
-import org.openecomp.appc.statemachine.objects.State;\r
-import org.openecomp.appc.statemachine.objects.StateMachineMetadata;\r
-\r
-public class VnfMetaDataReader implements StateMetaDataReader {\r
-\r
- public enum VNFOperation {\r
-\r
- Configure, Test, HealthCheck, Start, Terminate, Restart, Rebuild, Stop, ConfigModify,\r
- ConfigScaleOut,ConfigRestore,Backup, Snapshot,\r
- SoftwareUpload, LiveUpgrade, Rollback, Sync, Audit, Test_lic, Migrate, Evacuate,\r
- ConfigBackup, ConfigBackupDelete, ConfigExport,\r
- Lock(true), Unlock(true), CheckLock(true), StartApplication,StopApplication;\r
-\r
- private boolean builtIn;\r
-\r
- VNFOperation(boolean builtIn) {\r
- this.builtIn = builtIn;\r
- }\r
-\r
- VNFOperation() {\r
- this(false);\r
- }\r
- }\r
-\r
- private enum VNFStates {\r
- Not_Instantiated, Instantiated, Configuring, Configured, Testing, Tested, Rebuilding, Restarting, Starting,\r
- Error, Running, Unknown, Terminating, Stopping, Stopped,\r
- Backing_Up, Snapshotting, Software_Uploading, Upgrading, Rollbacking, Licensing, Migrating, Evacuating,\r
- NOT_ORCHESTRATED("NOT ORCHESTRATED"), Created;\r
-\r
- String stateName;\r
-\r
- VNFStates(String name) {\r
- this.stateName = name;\r
- }\r
-\r
- VNFStates() {\r
- this.stateName = name();\r
- }\r
-\r
- @Override\r
- public String toString() {\r
- return this.stateName;\r
- }\r
- }\r
-\r
- public StateMachineMetadata readMetadata() {\r
- {\r
- State NOT_INSTANTIATED = new State(VNFStates.Not_Instantiated.toString());\r
- State INSTANTIATED = new State(VNFStates.Instantiated.toString());\r
- State CONFIGURING = new State(VNFStates.Configuring.toString());\r
- State CONFIGURED = new State(VNFStates.Configured.toString());\r
- State TESTING = new State(VNFStates.Testing.toString());\r
- State TESTED = new State(VNFStates.Tested.toString());\r
- State REBUILDING = new State(VNFStates.Rebuilding.toString());\r
- State RESTARTING = new State(VNFStates.Restarting.toString());\r
- State STARTING = new State(VNFStates.Starting.toString());\r
- State ERROR = new State(VNFStates.Error.toString());\r
- State RUNNING = new State(VNFStates.Running.toString());\r
- State UNKNOWN = new State(VNFStates.Unknown.toString());\r
- State TERMINATING = new State(VNFStates.Terminating.toString());\r
- State STOPPING = new State(VNFStates.Stopping.toString());\r
- State STOPPED = new State(VNFStates.Stopped.toString());\r
- State NOT_ORCHESTRATED = new State(VNFStates.NOT_ORCHESTRATED.toString());\r
-\r
- State BACKING_UP = new State(VNFStates.Backing_Up.toString());\r
- State SNAPSHOTTING = new State(VNFStates.Snapshotting.toString());\r
- State SOFTWARE_UPLOADING = new State(VNFStates.Software_Uploading.toString());\r
- State UPGRADING = new State(VNFStates.Upgrading.toString());\r
- State ROLLBACKING = new State(VNFStates.Rollbacking.toString());\r
-\r
- State MIGRATING = new State(VNFStates.Migrating.toString());\r
- State EVACUATING = new State(VNFStates.Evacuating.toString());\r
- State CREATED= new State(VNFStates.Created.toString());\r
-\r
- Event START_APPLICATION = new Event(VNFOperation.StartApplication.toString());\r
- Event CONFIGURE = new Event(VNFOperation.Configure.toString());\r
- Event HEALTHCHECK = new Event(VNFOperation.HealthCheck.toString());\r
- Event TEST = new Event(VNFOperation.Test.toString());\r
- Event START = new Event(VNFOperation.Start.toString());\r
- Event TERMINATE = new Event(VNFOperation.Terminate.toString());\r
- Event RESTART = new Event(VNFOperation.Restart.toString());\r
- Event REBUILD = new Event(VNFOperation.Rebuild.toString());\r
- Event STOP = new Event(VNFOperation.Stop.toString());\r
- Event CONFIG_MODIFY = new Event(VNFOperation.ConfigModify.toString());\r
- Event CONFIG_SCALEOUT = new Event(VNFOperation.ConfigScaleOut.toString());\r
- Event CONFIG_RESTORE = new Event(VNFOperation.ConfigRestore.toString());\r
- Event BACKUP = new Event(VNFOperation.Backup.toString());\r
- Event SNAPSHOT = new Event(VNFOperation.Snapshot.toString());\r
- Event SOFTWARE_UPLOAD = new Event(VNFOperation.SoftwareUpload.toString());\r
- Event LIVE_UPGRADE = new Event(VNFOperation.LiveUpgrade.toString());\r
- Event ROLLBACK = new Event(VNFOperation.Rollback.toString());\r
- Event SYNC = new Event(VNFOperation.Sync.toString());\r
- Event AUDIT = new Event(VNFOperation.Audit.toString());\r
- Event MIGRATE = new Event(VNFOperation.Migrate.toString());\r
- Event EVACUATE = new Event(VNFOperation.Evacuate.toString());\r
- Event CONFIG_BACKUP = new Event(VNFOperation.ConfigBackup.toString());\r
- Event CONFIG_BACKUP_DELETE = new Event(VNFOperation.ConfigBackupDelete.toString());\r
- Event CONFIG_EXPORT = new Event(VNFOperation.ConfigExport.toString());\r
- Event STOP_APPLICATION= new Event(VNFOperation.StopApplication.toString());\r
-\r
- Event LOCK = new Event(VNFOperation.Lock.toString());\r
- Event UNLOCK = new Event(VNFOperation.Unlock.toString());\r
- Event CHECKLOCK = new Event(VNFOperation.CheckLock.toString());\r
-\r
- Event SUCCESS = new Event(VNFOperationOutcome.SUCCESS.toString());\r
- Event FAILURE = new Event(VNFOperationOutcome.FAILURE.toString());\r
-\r
-\r
- StateMachineMetadata.StateMachineMetadataBuilder builder = new StateMachineMetadata.StateMachineMetadataBuilder();\r
-\r
- builder = builder.addState(NOT_INSTANTIATED);\r
- builder = builder.addState(INSTANTIATED);\r
- builder = builder.addState(CONFIGURING);\r
- builder = builder.addState(CONFIGURED);\r
- builder = builder.addState(TESTING);\r
- builder = builder.addState(TESTED);\r
- builder = builder.addState(REBUILDING);\r
- builder = builder.addState(RESTARTING);\r
- builder = builder.addState(STARTING);\r
- builder = builder.addState(ERROR);\r
- builder = builder.addState(RUNNING);\r
- builder = builder.addState(UNKNOWN);\r
- builder = builder.addState(TERMINATING);\r
- builder = builder.addState(STOPPING);\r
- builder = builder.addState(STOPPED);\r
-\r
- builder = builder.addState(BACKING_UP);\r
- builder = builder.addState(SNAPSHOTTING);\r
- builder = builder.addState(SOFTWARE_UPLOADING);\r
- builder = builder.addState(UPGRADING);\r
- builder = builder.addState(ROLLBACKING);\r
- builder = builder.addState(MIGRATING);\r
- builder = builder.addState(EVACUATING);\r
- builder = builder.addState(NOT_ORCHESTRATED);\r
- builder = builder.addState(CREATED);\r
- builder = builder.addEvent(START_APPLICATION);\r
- builder = builder.addEvent(CONFIGURE);\r
- builder = builder.addEvent(TEST);\r
- builder = builder.addEvent(START);\r
- builder = builder.addEvent(TERMINATE);\r
- builder = builder.addEvent(RESTART);\r
- builder = builder.addEvent(REBUILD);\r
- builder = builder.addEvent(SUCCESS);\r
- builder = builder.addEvent(FAILURE);\r
- builder = builder.addEvent(STOP);\r
- builder = builder.addEvent(CONFIG_MODIFY);\r
- builder = builder.addEvent(CONFIG_SCALEOUT);\r
- builder = builder.addEvent(CONFIG_RESTORE);\r
- builder = builder.addEvent(HEALTHCHECK);\r
- builder = builder.addEvent(BACKUP);\r
- builder = builder.addEvent(SNAPSHOT);\r
- builder = builder.addEvent(SOFTWARE_UPLOAD);\r
- builder = builder.addEvent(LIVE_UPGRADE);\r
- builder = builder.addEvent(ROLLBACK);\r
- builder = builder.addEvent(SYNC);\r
- builder = builder.addEvent(AUDIT);\r
- builder = builder.addEvent(MIGRATE);\r
- builder = builder.addEvent(EVACUATE);\r
- builder = builder.addEvent(LOCK);\r
- builder = builder.addEvent(UNLOCK);\r
- builder = builder.addEvent(CHECKLOCK);\r
- builder = builder.addEvent(CONFIG_BACKUP);\r
- builder = builder.addEvent(CONFIG_BACKUP_DELETE);\r
- builder = builder.addEvent(CONFIG_EXPORT);\r
- builder = builder.addEvent(STOP_APPLICATION);\r
-\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,TEST,TESTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,START,STARTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,RESTART,RESTARTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,STOP,STOPPING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,LOCK,NOT_ORCHESTRATED);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,UNLOCK,NOT_ORCHESTRATED);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CHECKLOCK,NOT_ORCHESTRATED);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,STOP_APPLICATION,STOPPING);\r
- builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_BACKUP,NOT_ORCHESTRATED);\r
-\r
- builder = builder.addTransition(CREATED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(CREATED,TEST,TESTING);\r
- builder = builder.addTransition(CREATED,START,STARTING);\r
- builder = builder.addTransition(CREATED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(CREATED,RESTART,RESTARTING);\r
- builder = builder.addTransition(CREATED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(CREATED,STOP,STOPPING);\r
- builder = builder.addTransition(CREATED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(CREATED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(CREATED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(CREATED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(CREATED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(CREATED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(CREATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(CREATED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(CREATED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(CREATED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(CREATED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(CREATED,LOCK,CREATED);\r
- builder = builder.addTransition(CREATED,UNLOCK,CREATED);\r
- builder = builder.addTransition(CREATED,CHECKLOCK,CREATED);\r
- builder = builder.addTransition(CREATED,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(CREATED,STOP_APPLICATION,STOPPING);\r
- builder = builder.addTransition(CREATED,CONFIG_BACKUP,CREATED);\r
-\r
- builder = builder.addTransition(INSTANTIATED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(INSTANTIATED,TEST,TESTING);\r
- builder = builder.addTransition(INSTANTIATED,START,STARTING);\r
- builder = builder.addTransition(INSTANTIATED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(INSTANTIATED,RESTART,RESTARTING);\r
- builder = builder.addTransition(INSTANTIATED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(INSTANTIATED,STOP,STOPPING);\r
- builder = builder.addTransition(INSTANTIATED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(INSTANTIATED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(INSTANTIATED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(INSTANTIATED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(INSTANTIATED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(INSTANTIATED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(INSTANTIATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(INSTANTIATED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(INSTANTIATED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(INSTANTIATED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(INSTANTIATED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(INSTANTIATED,LOCK,INSTANTIATED);\r
- builder = builder.addTransition(INSTANTIATED,UNLOCK,INSTANTIATED);\r
- builder = builder.addTransition(INSTANTIATED,CHECKLOCK,INSTANTIATED);\r
-\r
- builder = builder.addTransition(CONFIGURED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(CONFIGURED,TEST,TESTING);\r
- builder = builder.addTransition(CONFIGURED,START,STARTING);\r
- builder = builder.addTransition(CONFIGURED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(CONFIGURED,RESTART,RESTARTING);\r
- builder = builder.addTransition(CONFIGURED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(CONFIGURED,STOP,STOPPING);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(CONFIGURED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(CONFIGURED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(CONFIGURED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(CONFIGURED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(CONFIGURED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(CONFIGURED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(CONFIGURED,SYNC,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,AUDIT,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(CONFIGURED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(CONFIGURED,LOCK,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,UNLOCK,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,CHECKLOCK,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP_DELETE,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,CONFIG_EXPORT,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURED,STOP_APPLICATION,STOPPING);\r
-\r
- builder = builder.addTransition(TESTED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(TESTED,TEST,TESTING);\r
- builder = builder.addTransition(TESTED,START,STARTING);\r
- builder = builder.addTransition(TESTED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(TESTED,RESTART,RESTARTING);\r
- builder = builder.addTransition(TESTED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(TESTED,STOP,STOPPING);\r
- builder = builder.addTransition(TESTED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(TESTED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(TESTED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(TESTED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(TESTED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(TESTED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(TESTED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(TESTED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(TESTED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(TESTED,SYNC,TESTED);\r
- builder = builder.addTransition(TESTED,AUDIT,TESTED);\r
- builder = builder.addTransition(TESTED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(TESTED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(TESTED,LOCK,TESTED);\r
- builder = builder.addTransition(TESTED,UNLOCK,TESTED);\r
- builder = builder.addTransition(TESTED,CHECKLOCK,TESTED);\r
- builder = builder.addTransition(TESTED,CONFIG_BACKUP,TESTED);\r
- builder = builder.addTransition(TESTED,CONFIG_BACKUP_DELETE,TESTED);\r
- builder = builder.addTransition(TESTED,CONFIG_EXPORT,TESTED);\r
- builder = builder.addTransition(TESTED,STOP_APPLICATION,STOPPING);\r
-\r
- builder = builder.addTransition(RUNNING,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(RUNNING,TEST,TESTING);\r
- builder = builder.addTransition(RUNNING,START,STARTING);\r
- builder = builder.addTransition(RUNNING,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(RUNNING,RESTART,RESTARTING);\r
- builder = builder.addTransition(RUNNING,REBUILD,REBUILDING);\r
- builder = builder.addTransition(RUNNING,STOP,STOPPING);\r
- builder = builder.addTransition(RUNNING,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(RUNNING,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(RUNNING,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(RUNNING,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(RUNNING,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(RUNNING,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(RUNNING,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(RUNNING,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(RUNNING,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(RUNNING,SYNC,RUNNING);\r
- builder = builder.addTransition(RUNNING,AUDIT,RUNNING);\r
- builder = builder.addTransition(RUNNING,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(RUNNING,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(RUNNING,LOCK,RUNNING);\r
- builder = builder.addTransition(RUNNING,UNLOCK,RUNNING);\r
- builder = builder.addTransition(RUNNING,CHECKLOCK,RUNNING);\r
- builder = builder.addTransition(RUNNING,CONFIG_BACKUP,RUNNING);\r
- builder = builder.addTransition(RUNNING,CONFIG_BACKUP_DELETE,RUNNING);\r
- builder = builder.addTransition(RUNNING,CONFIG_EXPORT,RUNNING);\r
- builder = builder.addTransition(RUNNING,STOP_APPLICATION,STOPPING);\r
-\r
- builder = builder.addTransition(ERROR,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(ERROR,TEST,TESTING);\r
- builder = builder.addTransition(ERROR,START,STARTING);\r
- builder = builder.addTransition(ERROR,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(ERROR,RESTART,RESTARTING);\r
- builder = builder.addTransition(ERROR,REBUILD,REBUILDING);\r
- builder = builder.addTransition(ERROR,STOP,STOPPING);\r
- builder = builder.addTransition(ERROR,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(ERROR,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(ERROR,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(ERROR,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(ERROR,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(ERROR,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(ERROR,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(ERROR,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(ERROR,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(ERROR,SYNC,ERROR);\r
- builder = builder.addTransition(ERROR,AUDIT,ERROR);\r
- builder = builder.addTransition(ERROR,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(ERROR,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(ERROR,LOCK,ERROR);\r
- builder = builder.addTransition(ERROR,UNLOCK,ERROR);\r
- builder = builder.addTransition(ERROR,CHECKLOCK,ERROR);\r
- builder = builder.addTransition(ERROR,CONFIG_BACKUP,ERROR);\r
- builder = builder.addTransition(ERROR,CONFIG_BACKUP_DELETE,ERROR);\r
- builder = builder.addTransition(ERROR,CONFIG_EXPORT,ERROR);\r
- builder = builder.addTransition(ERROR,STOP_APPLICATION,STOPPING);\r
-\r
- builder = builder.addTransition(UNKNOWN,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(UNKNOWN,TEST,TESTING);\r
- builder = builder.addTransition(UNKNOWN,START,STARTING);\r
- builder = builder.addTransition(UNKNOWN,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(UNKNOWN,RESTART,RESTARTING);\r
- builder = builder.addTransition(UNKNOWN,REBUILD,REBUILDING);\r
- builder = builder.addTransition(UNKNOWN,STOP,STOPPING);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(UNKNOWN,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(UNKNOWN,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(UNKNOWN,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(UNKNOWN,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(UNKNOWN,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(UNKNOWN,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(UNKNOWN,SYNC,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,AUDIT,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(UNKNOWN,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(UNKNOWN,LOCK,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,UNLOCK,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,CHECKLOCK,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP_DELETE,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,CONFIG_EXPORT,UNKNOWN);\r
- builder = builder.addTransition(UNKNOWN,STOP_APPLICATION,STOPPING);\r
-\r
- builder = builder.addTransition(STOPPED,CONFIGURE,CONFIGURING);\r
- builder = builder.addTransition(STOPPED,TEST,TESTING);\r
- builder = builder.addTransition(STOPPED,START,STARTING);\r
- builder = builder.addTransition(STOPPED,TERMINATE,TERMINATING);\r
- builder = builder.addTransition(STOPPED,RESTART,RESTARTING);\r
- builder = builder.addTransition(STOPPED,REBUILD,REBUILDING);\r
- builder = builder.addTransition(STOPPED,CONFIG_MODIFY,CONFIGURING);\r
- builder = builder.addTransition(STOPPED,CONFIG_SCALEOUT,CONFIGURING);\r
- builder = builder.addTransition(STOPPED,CONFIG_RESTORE,CONFIGURING);\r
- builder = builder.addTransition(STOPPED,HEALTHCHECK,TESTING);\r
- builder = builder.addTransition(STOPPED,BACKUP,BACKING_UP);\r
- builder = builder.addTransition(STOPPED,SNAPSHOT,SNAPSHOTTING);\r
- builder = builder.addTransition(STOPPED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);\r
- builder = builder.addTransition(STOPPED,LIVE_UPGRADE,UPGRADING);\r
- builder = builder.addTransition(STOPPED,ROLLBACK,ROLLBACKING);\r
- builder = builder.addTransition(STOPPED,MIGRATE,MIGRATING);\r
- builder = builder.addTransition(STOPPED,EVACUATE,EVACUATING);\r
- builder = builder.addTransition(STOPPED,LOCK,STOPPED);\r
- builder = builder.addTransition(STOPPED,UNLOCK,STOPPED);\r
- builder = builder.addTransition(STOPPED,CHECKLOCK,STOPPED);\r
-\r
- builder = builder.addTransition(CONFIGURING,SUCCESS,CONFIGURED);\r
- builder = builder.addTransition(CONFIGURING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(TESTING,SUCCESS,TESTED);\r
- builder = builder.addTransition(TESTING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(RESTARTING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(RESTARTING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(STARTING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(STARTING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(TERMINATING,SUCCESS,NOT_INSTANTIATED);\r
- builder = builder.addTransition(TERMINATING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(REBUILDING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(REBUILDING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(STOPPING,SUCCESS,STOPPED);\r
- builder = builder.addTransition(STOPPING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(BACKING_UP,SUCCESS,RUNNING);\r
- builder = builder.addTransition(BACKING_UP,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(SNAPSHOTTING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(SNAPSHOTTING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(SOFTWARE_UPLOADING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(SOFTWARE_UPLOADING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(UPGRADING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(UPGRADING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(ROLLBACKING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(ROLLBACKING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(MIGRATING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(MIGRATING,FAILURE,ERROR);\r
-\r
- builder = builder.addTransition(EVACUATING,SUCCESS,RUNNING);\r
- builder = builder.addTransition(EVACUATING,FAILURE,ERROR);\r
-\r
-\r
- builder = builder.addTransition(CONFIGURED,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(TESTED,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(ERROR,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(UNKNOWN,START_APPLICATION,STARTING);\r
- builder = builder.addTransition(RUNNING,START_APPLICATION,STARTING);\r
-\r
- return builder.build();\r
-\r
- }\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl.readers;
+
+import org.openecomp.appc.statemachine.StateMetaDataReader;
+import org.openecomp.appc.lifecyclemanager.objects.VNFOperationOutcome;
+import org.openecomp.appc.statemachine.objects.Event;
+import org.openecomp.appc.statemachine.objects.State;
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+
+public class VnfMetaDataReader implements StateMetaDataReader {
+
+ public enum VNFOperation {
+
+ Configure, Test, HealthCheck, Start, Terminate, Restart, Rebuild, Stop, ConfigModify,
+ ConfigScaleOut,ConfigRestore,Backup, Snapshot,
+ SoftwareUpload, LiveUpgrade, Rollback, Sync, Audit, Test_lic, Migrate, Evacuate,
+ ConfigBackup, ConfigBackupDelete, ConfigExport,
+ Lock(true), Unlock(true), CheckLock(true), StartApplication,StopApplication;
+
+ private boolean builtIn;
+
+ VNFOperation(boolean builtIn) {
+ this.builtIn = builtIn;
+ }
+
+ VNFOperation() {
+ this(false);
+ }
+ }
+
+ private enum VNFStates {
+ Not_Instantiated, Instantiated, Configuring, Configured, Testing, Tested, Rebuilding, Restarting, Starting,
+ Error, Running, Unknown, Terminating, Stopping, Stopped,
+ Backing_Up, Snapshotting, Software_Uploading, Upgrading, Rollbacking, Licensing, Migrating, Evacuating,
+ NOT_ORCHESTRATED("NOT ORCHESTRATED"), Created;
+
+ String stateName;
+
+ VNFStates(String name) {
+ this.stateName = name;
+ }
+
+ VNFStates() {
+ this.stateName = name();
+ }
+
+ @Override
+ public String toString() {
+ return this.stateName;
+ }
+ }
+
+ public StateMachineMetadata readMetadata() {
+ {
+ State NOT_INSTANTIATED = new State(VNFStates.Not_Instantiated.toString());
+ State INSTANTIATED = new State(VNFStates.Instantiated.toString());
+ State CONFIGURING = new State(VNFStates.Configuring.toString());
+ State CONFIGURED = new State(VNFStates.Configured.toString());
+ State TESTING = new State(VNFStates.Testing.toString());
+ State TESTED = new State(VNFStates.Tested.toString());
+ State REBUILDING = new State(VNFStates.Rebuilding.toString());
+ State RESTARTING = new State(VNFStates.Restarting.toString());
+ State STARTING = new State(VNFStates.Starting.toString());
+ State ERROR = new State(VNFStates.Error.toString());
+ State RUNNING = new State(VNFStates.Running.toString());
+ State UNKNOWN = new State(VNFStates.Unknown.toString());
+ State TERMINATING = new State(VNFStates.Terminating.toString());
+ State STOPPING = new State(VNFStates.Stopping.toString());
+ State STOPPED = new State(VNFStates.Stopped.toString());
+ State NOT_ORCHESTRATED = new State(VNFStates.NOT_ORCHESTRATED.toString());
+
+ State BACKING_UP = new State(VNFStates.Backing_Up.toString());
+ State SNAPSHOTTING = new State(VNFStates.Snapshotting.toString());
+ State SOFTWARE_UPLOADING = new State(VNFStates.Software_Uploading.toString());
+ State UPGRADING = new State(VNFStates.Upgrading.toString());
+ State ROLLBACKING = new State(VNFStates.Rollbacking.toString());
+
+ State MIGRATING = new State(VNFStates.Migrating.toString());
+ State EVACUATING = new State(VNFStates.Evacuating.toString());
+ State CREATED= new State(VNFStates.Created.toString());
+
+ Event START_APPLICATION = new Event(VNFOperation.StartApplication.toString());
+ Event CONFIGURE = new Event(VNFOperation.Configure.toString());
+ Event HEALTHCHECK = new Event(VNFOperation.HealthCheck.toString());
+ Event TEST = new Event(VNFOperation.Test.toString());
+ Event START = new Event(VNFOperation.Start.toString());
+ Event TERMINATE = new Event(VNFOperation.Terminate.toString());
+ Event RESTART = new Event(VNFOperation.Restart.toString());
+ Event REBUILD = new Event(VNFOperation.Rebuild.toString());
+ Event STOP = new Event(VNFOperation.Stop.toString());
+ Event CONFIG_MODIFY = new Event(VNFOperation.ConfigModify.toString());
+ Event CONFIG_SCALEOUT = new Event(VNFOperation.ConfigScaleOut.toString());
+ Event CONFIG_RESTORE = new Event(VNFOperation.ConfigRestore.toString());
+ Event BACKUP = new Event(VNFOperation.Backup.toString());
+ Event SNAPSHOT = new Event(VNFOperation.Snapshot.toString());
+ Event SOFTWARE_UPLOAD = new Event(VNFOperation.SoftwareUpload.toString());
+ Event LIVE_UPGRADE = new Event(VNFOperation.LiveUpgrade.toString());
+ Event ROLLBACK = new Event(VNFOperation.Rollback.toString());
+ Event SYNC = new Event(VNFOperation.Sync.toString());
+ Event AUDIT = new Event(VNFOperation.Audit.toString());
+ Event MIGRATE = new Event(VNFOperation.Migrate.toString());
+ Event EVACUATE = new Event(VNFOperation.Evacuate.toString());
+ Event CONFIG_BACKUP = new Event(VNFOperation.ConfigBackup.toString());
+ Event CONFIG_BACKUP_DELETE = new Event(VNFOperation.ConfigBackupDelete.toString());
+ Event CONFIG_EXPORT = new Event(VNFOperation.ConfigExport.toString());
+ Event STOP_APPLICATION= new Event(VNFOperation.StopApplication.toString());
+
+ Event LOCK = new Event(VNFOperation.Lock.toString());
+ Event UNLOCK = new Event(VNFOperation.Unlock.toString());
+ Event CHECKLOCK = new Event(VNFOperation.CheckLock.toString());
+
+ Event SUCCESS = new Event(VNFOperationOutcome.SUCCESS.toString());
+ Event FAILURE = new Event(VNFOperationOutcome.FAILURE.toString());
+
+
+ StateMachineMetadata.StateMachineMetadataBuilder builder = new StateMachineMetadata.StateMachineMetadataBuilder();
+
+ builder = builder.addState(NOT_INSTANTIATED);
+ builder = builder.addState(INSTANTIATED);
+ builder = builder.addState(CONFIGURING);
+ builder = builder.addState(CONFIGURED);
+ builder = builder.addState(TESTING);
+ builder = builder.addState(TESTED);
+ builder = builder.addState(REBUILDING);
+ builder = builder.addState(RESTARTING);
+ builder = builder.addState(STARTING);
+ builder = builder.addState(ERROR);
+ builder = builder.addState(RUNNING);
+ builder = builder.addState(UNKNOWN);
+ builder = builder.addState(TERMINATING);
+ builder = builder.addState(STOPPING);
+ builder = builder.addState(STOPPED);
+
+ builder = builder.addState(BACKING_UP);
+ builder = builder.addState(SNAPSHOTTING);
+ builder = builder.addState(SOFTWARE_UPLOADING);
+ builder = builder.addState(UPGRADING);
+ builder = builder.addState(ROLLBACKING);
+ builder = builder.addState(MIGRATING);
+ builder = builder.addState(EVACUATING);
+ builder = builder.addState(NOT_ORCHESTRATED);
+ builder = builder.addState(CREATED);
+ builder = builder.addEvent(START_APPLICATION);
+ builder = builder.addEvent(CONFIGURE);
+ builder = builder.addEvent(TEST);
+ builder = builder.addEvent(START);
+ builder = builder.addEvent(TERMINATE);
+ builder = builder.addEvent(RESTART);
+ builder = builder.addEvent(REBUILD);
+ builder = builder.addEvent(SUCCESS);
+ builder = builder.addEvent(FAILURE);
+ builder = builder.addEvent(STOP);
+ builder = builder.addEvent(CONFIG_MODIFY);
+ builder = builder.addEvent(CONFIG_SCALEOUT);
+ builder = builder.addEvent(CONFIG_RESTORE);
+ builder = builder.addEvent(HEALTHCHECK);
+ builder = builder.addEvent(BACKUP);
+ builder = builder.addEvent(SNAPSHOT);
+ builder = builder.addEvent(SOFTWARE_UPLOAD);
+ builder = builder.addEvent(LIVE_UPGRADE);
+ builder = builder.addEvent(ROLLBACK);
+ builder = builder.addEvent(SYNC);
+ builder = builder.addEvent(AUDIT);
+ builder = builder.addEvent(MIGRATE);
+ builder = builder.addEvent(EVACUATE);
+ builder = builder.addEvent(LOCK);
+ builder = builder.addEvent(UNLOCK);
+ builder = builder.addEvent(CHECKLOCK);
+ builder = builder.addEvent(CONFIG_BACKUP);
+ builder = builder.addEvent(CONFIG_BACKUP_DELETE);
+ builder = builder.addEvent(CONFIG_EXPORT);
+ builder = builder.addEvent(STOP_APPLICATION);
+
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,TEST,TESTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,START,STARTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,RESTART,RESTARTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,REBUILD,REBUILDING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,STOP,STOPPING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(NOT_ORCHESTRATED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,LOCK,NOT_ORCHESTRATED);
+ builder = builder.addTransition(NOT_ORCHESTRATED,UNLOCK,NOT_ORCHESTRATED);
+ builder = builder.addTransition(NOT_ORCHESTRATED,CHECKLOCK,NOT_ORCHESTRATED);
+ builder = builder.addTransition(NOT_ORCHESTRATED,START_APPLICATION,STARTING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,STOP_APPLICATION,STOPPING);
+ builder = builder.addTransition(NOT_ORCHESTRATED,CONFIG_BACKUP,NOT_ORCHESTRATED);
+
+ builder = builder.addTransition(CREATED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(CREATED,TEST,TESTING);
+ builder = builder.addTransition(CREATED,START,STARTING);
+ builder = builder.addTransition(CREATED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(CREATED,RESTART,RESTARTING);
+ builder = builder.addTransition(CREATED,REBUILD,REBUILDING);
+ builder = builder.addTransition(CREATED,STOP,STOPPING);
+ builder = builder.addTransition(CREATED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(CREATED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(CREATED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(CREATED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(CREATED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(CREATED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(CREATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(CREATED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(CREATED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(CREATED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(CREATED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(CREATED,LOCK,CREATED);
+ builder = builder.addTransition(CREATED,UNLOCK,CREATED);
+ builder = builder.addTransition(CREATED,CHECKLOCK,CREATED);
+ builder = builder.addTransition(CREATED,START_APPLICATION,STARTING);
+ builder = builder.addTransition(CREATED,STOP_APPLICATION,STOPPING);
+ builder = builder.addTransition(CREATED,CONFIG_BACKUP,CREATED);
+
+ builder = builder.addTransition(INSTANTIATED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,TEST,TESTING);
+ builder = builder.addTransition(INSTANTIATED,START,STARTING);
+ builder = builder.addTransition(INSTANTIATED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(INSTANTIATED,RESTART,RESTARTING);
+ builder = builder.addTransition(INSTANTIATED,REBUILD,REBUILDING);
+ builder = builder.addTransition(INSTANTIATED,STOP,STOPPING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(INSTANTIATED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(INSTANTIATED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(INSTANTIATED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(INSTANTIATED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(INSTANTIATED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(INSTANTIATED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(INSTANTIATED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(INSTANTIATED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(INSTANTIATED,LOCK,INSTANTIATED);
+ builder = builder.addTransition(INSTANTIATED,UNLOCK,INSTANTIATED);
+ builder = builder.addTransition(INSTANTIATED,CHECKLOCK,INSTANTIATED);
+
+ builder = builder.addTransition(CONFIGURED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,TEST,TESTING);
+ builder = builder.addTransition(CONFIGURED,START,STARTING);
+ builder = builder.addTransition(CONFIGURED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(CONFIGURED,RESTART,RESTARTING);
+ builder = builder.addTransition(CONFIGURED,REBUILD,REBUILDING);
+ builder = builder.addTransition(CONFIGURED,STOP,STOPPING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(CONFIGURED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(CONFIGURED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(CONFIGURED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(CONFIGURED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(CONFIGURED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(CONFIGURED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(CONFIGURED,SYNC,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,AUDIT,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(CONFIGURED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(CONFIGURED,LOCK,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,UNLOCK,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CHECKLOCK,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_BACKUP_DELETE,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,CONFIG_EXPORT,CONFIGURED);
+ builder = builder.addTransition(CONFIGURED,STOP_APPLICATION,STOPPING);
+
+ builder = builder.addTransition(TESTED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(TESTED,TEST,TESTING);
+ builder = builder.addTransition(TESTED,START,STARTING);
+ builder = builder.addTransition(TESTED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(TESTED,RESTART,RESTARTING);
+ builder = builder.addTransition(TESTED,REBUILD,REBUILDING);
+ builder = builder.addTransition(TESTED,STOP,STOPPING);
+ builder = builder.addTransition(TESTED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(TESTED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(TESTED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(TESTED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(TESTED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(TESTED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(TESTED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(TESTED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(TESTED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(TESTED,SYNC,TESTED);
+ builder = builder.addTransition(TESTED,AUDIT,TESTED);
+ builder = builder.addTransition(TESTED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(TESTED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(TESTED,LOCK,TESTED);
+ builder = builder.addTransition(TESTED,UNLOCK,TESTED);
+ builder = builder.addTransition(TESTED,CHECKLOCK,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_BACKUP,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_BACKUP_DELETE,TESTED);
+ builder = builder.addTransition(TESTED,CONFIG_EXPORT,TESTED);
+ builder = builder.addTransition(TESTED,STOP_APPLICATION,STOPPING);
+
+ builder = builder.addTransition(RUNNING,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(RUNNING,TEST,TESTING);
+ builder = builder.addTransition(RUNNING,START,STARTING);
+ builder = builder.addTransition(RUNNING,TERMINATE,TERMINATING);
+ builder = builder.addTransition(RUNNING,RESTART,RESTARTING);
+ builder = builder.addTransition(RUNNING,REBUILD,REBUILDING);
+ builder = builder.addTransition(RUNNING,STOP,STOPPING);
+ builder = builder.addTransition(RUNNING,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(RUNNING,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(RUNNING,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(RUNNING,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(RUNNING,BACKUP,BACKING_UP);
+ builder = builder.addTransition(RUNNING,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(RUNNING,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(RUNNING,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(RUNNING,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(RUNNING,SYNC,RUNNING);
+ builder = builder.addTransition(RUNNING,AUDIT,RUNNING);
+ builder = builder.addTransition(RUNNING,MIGRATE,MIGRATING);
+ builder = builder.addTransition(RUNNING,EVACUATE,EVACUATING);
+ builder = builder.addTransition(RUNNING,LOCK,RUNNING);
+ builder = builder.addTransition(RUNNING,UNLOCK,RUNNING);
+ builder = builder.addTransition(RUNNING,CHECKLOCK,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_BACKUP,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_BACKUP_DELETE,RUNNING);
+ builder = builder.addTransition(RUNNING,CONFIG_EXPORT,RUNNING);
+ builder = builder.addTransition(RUNNING,STOP_APPLICATION,STOPPING);
+
+ builder = builder.addTransition(ERROR,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(ERROR,TEST,TESTING);
+ builder = builder.addTransition(ERROR,START,STARTING);
+ builder = builder.addTransition(ERROR,TERMINATE,TERMINATING);
+ builder = builder.addTransition(ERROR,RESTART,RESTARTING);
+ builder = builder.addTransition(ERROR,REBUILD,REBUILDING);
+ builder = builder.addTransition(ERROR,STOP,STOPPING);
+ builder = builder.addTransition(ERROR,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(ERROR,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(ERROR,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(ERROR,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(ERROR,BACKUP,BACKING_UP);
+ builder = builder.addTransition(ERROR,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(ERROR,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(ERROR,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(ERROR,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(ERROR,SYNC,ERROR);
+ builder = builder.addTransition(ERROR,AUDIT,ERROR);
+ builder = builder.addTransition(ERROR,MIGRATE,MIGRATING);
+ builder = builder.addTransition(ERROR,EVACUATE,EVACUATING);
+ builder = builder.addTransition(ERROR,LOCK,ERROR);
+ builder = builder.addTransition(ERROR,UNLOCK,ERROR);
+ builder = builder.addTransition(ERROR,CHECKLOCK,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_BACKUP,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_BACKUP_DELETE,ERROR);
+ builder = builder.addTransition(ERROR,CONFIG_EXPORT,ERROR);
+ builder = builder.addTransition(ERROR,STOP_APPLICATION,STOPPING);
+
+ builder = builder.addTransition(UNKNOWN,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,TEST,TESTING);
+ builder = builder.addTransition(UNKNOWN,START,STARTING);
+ builder = builder.addTransition(UNKNOWN,TERMINATE,TERMINATING);
+ builder = builder.addTransition(UNKNOWN,RESTART,RESTARTING);
+ builder = builder.addTransition(UNKNOWN,REBUILD,REBUILDING);
+ builder = builder.addTransition(UNKNOWN,STOP,STOPPING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(UNKNOWN,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(UNKNOWN,BACKUP,BACKING_UP);
+ builder = builder.addTransition(UNKNOWN,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(UNKNOWN,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(UNKNOWN,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(UNKNOWN,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(UNKNOWN,SYNC,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,AUDIT,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,MIGRATE,MIGRATING);
+ builder = builder.addTransition(UNKNOWN,EVACUATE,EVACUATING);
+ builder = builder.addTransition(UNKNOWN,LOCK,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,UNLOCK,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CHECKLOCK,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_BACKUP_DELETE,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,CONFIG_EXPORT,UNKNOWN);
+ builder = builder.addTransition(UNKNOWN,STOP_APPLICATION,STOPPING);
+
+ builder = builder.addTransition(STOPPED,CONFIGURE,CONFIGURING);
+ builder = builder.addTransition(STOPPED,TEST,TESTING);
+ builder = builder.addTransition(STOPPED,START,STARTING);
+ builder = builder.addTransition(STOPPED,TERMINATE,TERMINATING);
+ builder = builder.addTransition(STOPPED,RESTART,RESTARTING);
+ builder = builder.addTransition(STOPPED,REBUILD,REBUILDING);
+ builder = builder.addTransition(STOPPED,CONFIG_MODIFY,CONFIGURING);
+ builder = builder.addTransition(STOPPED,CONFIG_SCALEOUT,CONFIGURING);
+ builder = builder.addTransition(STOPPED,CONFIG_RESTORE,CONFIGURING);
+ builder = builder.addTransition(STOPPED,HEALTHCHECK,TESTING);
+ builder = builder.addTransition(STOPPED,BACKUP,BACKING_UP);
+ builder = builder.addTransition(STOPPED,SNAPSHOT,SNAPSHOTTING);
+ builder = builder.addTransition(STOPPED,SOFTWARE_UPLOAD,SOFTWARE_UPLOADING);
+ builder = builder.addTransition(STOPPED,LIVE_UPGRADE,UPGRADING);
+ builder = builder.addTransition(STOPPED,ROLLBACK,ROLLBACKING);
+ builder = builder.addTransition(STOPPED,MIGRATE,MIGRATING);
+ builder = builder.addTransition(STOPPED,EVACUATE,EVACUATING);
+ builder = builder.addTransition(STOPPED,LOCK,STOPPED);
+ builder = builder.addTransition(STOPPED,UNLOCK,STOPPED);
+ builder = builder.addTransition(STOPPED,CHECKLOCK,STOPPED);
+
+ builder = builder.addTransition(CONFIGURING,SUCCESS,CONFIGURED);
+ builder = builder.addTransition(CONFIGURING,FAILURE,ERROR);
+
+ builder = builder.addTransition(TESTING,SUCCESS,TESTED);
+ builder = builder.addTransition(TESTING,FAILURE,ERROR);
+
+ builder = builder.addTransition(RESTARTING,SUCCESS,RUNNING);
+ builder = builder.addTransition(RESTARTING,FAILURE,ERROR);
+
+ builder = builder.addTransition(STARTING,SUCCESS,RUNNING);
+ builder = builder.addTransition(STARTING,FAILURE,ERROR);
+
+ builder = builder.addTransition(TERMINATING,SUCCESS,NOT_INSTANTIATED);
+ builder = builder.addTransition(TERMINATING,FAILURE,ERROR);
+
+ builder = builder.addTransition(REBUILDING,SUCCESS,RUNNING);
+ builder = builder.addTransition(REBUILDING,FAILURE,ERROR);
+
+ builder = builder.addTransition(STOPPING,SUCCESS,STOPPED);
+ builder = builder.addTransition(STOPPING,FAILURE,ERROR);
+
+ builder = builder.addTransition(BACKING_UP,SUCCESS,RUNNING);
+ builder = builder.addTransition(BACKING_UP,FAILURE,ERROR);
+
+ builder = builder.addTransition(SNAPSHOTTING,SUCCESS,RUNNING);
+ builder = builder.addTransition(SNAPSHOTTING,FAILURE,ERROR);
+
+ builder = builder.addTransition(SOFTWARE_UPLOADING,SUCCESS,RUNNING);
+ builder = builder.addTransition(SOFTWARE_UPLOADING,FAILURE,ERROR);
+
+ builder = builder.addTransition(UPGRADING,SUCCESS,RUNNING);
+ builder = builder.addTransition(UPGRADING,FAILURE,ERROR);
+
+ builder = builder.addTransition(ROLLBACKING,SUCCESS,RUNNING);
+ builder = builder.addTransition(ROLLBACKING,FAILURE,ERROR);
+
+ builder = builder.addTransition(MIGRATING,SUCCESS,RUNNING);
+ builder = builder.addTransition(MIGRATING,FAILURE,ERROR);
+
+ builder = builder.addTransition(EVACUATING,SUCCESS,RUNNING);
+ builder = builder.addTransition(EVACUATING,FAILURE,ERROR);
+
+
+ builder = builder.addTransition(CONFIGURED,START_APPLICATION,STARTING);
+ builder = builder.addTransition(TESTED,START_APPLICATION,STARTING);
+ builder = builder.addTransition(ERROR,START_APPLICATION,STARTING);
+ builder = builder.addTransition(UNKNOWN,START_APPLICATION,STARTING);
+ builder = builder.addTransition(RUNNING,START_APPLICATION,STARTING);
+
+ return builder.build();
+
+ }
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-public class Event{\r
-\r
- private String eventName;\r
-\r
- private Event(){\r
- // do nothing\r
- }\r
-\r
- @Override\r
- public int hashCode(){\r
- return this.eventName.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj){\r
- if(obj == null){\r
- return false;\r
- }\r
- if(!(obj instanceof Event)){\r
- return false;\r
- }\r
- Event event = (Event)obj;\r
- return this.eventName.equals(event.getEventName());\r
- }\r
-\r
- public Event(String eventName){\r
- this();\r
- this.eventName = eventName;\r
- }\r
-\r
- private String getEventName() {\r
- return eventName;\r
- }\r
-\r
- @Override\r
- public String toString(){\r
- return this.eventName;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+public class Event{
+
+ private String eventName;
+
+ private Event(){
+ // do nothing
+ }
+
+ @Override
+ public int hashCode(){
+ return this.eventName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj){
+ if(obj == null){
+ return false;
+ }
+ if(!(obj instanceof Event)){
+ return false;
+ }
+ Event event = (Event)obj;
+ return this.eventName.equals(event.getEventName());
+ }
+
+ public Event(String eventName){
+ this();
+ this.eventName = eventName;
+ }
+
+ private String getEventName() {
+ return eventName;
+ }
+
+ @Override
+ public String toString(){
+ return this.eventName;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-public enum Response {\r
- NO_TRANSITION_DEFINED,NO_STATE_CHANGE,VALID_TRANSITION;\r
- public String toString(){\r
- return this.name();\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+public enum Response {
+ NO_TRANSITION_DEFINED,NO_STATE_CHANGE,VALID_TRANSITION;
+ public String toString(){
+ return this.name();
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-public class State{\r
- private String stateName;\r
- private List<Transition> transitions;\r
-\r
- private State(){\r
- // do nothing\r
- }\r
-\r
- public State(String state){\r
- this();\r
- this.stateName = state;\r
- this.transitions = new ArrayList<>();\r
- }\r
-\r
- @Override\r
- public int hashCode(){\r
- return this.stateName.hashCode();\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj){\r
- if(obj == null){\r
- return false;\r
- }\r
- if(!(obj instanceof State)){\r
- return false;\r
- }\r
- State state = (State)obj;\r
- return this.stateName.equalsIgnoreCase(state.getStateName());\r
- }\r
-\r
- public String getStateName(){\r
- return stateName;\r
- }\r
-\r
- void addTransition(Transition transition){\r
- this.transitions.add(transition);\r
- }\r
-\r
- public List<Transition> getTransitions() {\r
- return transitions;\r
- }\r
-\r
- @Override\r
- public String toString(){\r
- return this.stateName;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class State{
+ private String stateName;
+ private List<Transition> transitions;
+
+ private State(){
+ // do nothing
+ }
+
+ public State(String state){
+ this();
+ this.stateName = state;
+ this.transitions = new ArrayList<>();
+ }
+
+ @Override
+ public int hashCode(){
+ return this.stateName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj){
+ if(obj == null){
+ return false;
+ }
+ if(!(obj instanceof State)){
+ return false;
+ }
+ State state = (State)obj;
+ return this.stateName.equalsIgnoreCase(state.getStateName());
+ }
+
+ public String getStateName(){
+ return stateName;
+ }
+
+ void addTransition(Transition transition){
+ this.transitions.add(transition);
+ }
+
+ public List<Transition> getTransitions() {
+ return transitions;
+ }
+
+ @Override
+ public String toString(){
+ return this.stateName;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-public class StateMachineMetadata {\r
-\r
- private Set<State> states;\r
- private Set<Event> events;\r
-\r
- private StateMachineMetadata(StateMachineMetadataBuilder builder){\r
- states = builder.states;\r
- events = builder.events;\r
- }\r
-\r
- public Set<State> getStates() {\r
- return states;\r
- }\r
-\r
- public Set<Event> getEvents() {\r
- return events;\r
- }\r
-\r
- public static class StateMachineMetadataBuilder{\r
-\r
- private Set<State> states;\r
- private Set<Event> events;\r
-\r
- public StateMachineMetadataBuilder(){\r
- states = new HashSet<>();\r
- events = new HashSet<>();\r
- }\r
-\r
- public StateMachineMetadataBuilder addState(State state){\r
- this.states.add(state);\r
- return this;\r
- }\r
-\r
- public StateMachineMetadataBuilder addEvent(Event event){\r
- this.events.add(event);\r
- return this;\r
- }\r
-\r
- public StateMachineMetadataBuilder addTransition(State currentState,Event event,State nextState){\r
- Transition transition = new Transition(event,nextState);\r
- currentState.addTransition(transition);\r
- return this;\r
- }\r
-\r
- public StateMachineMetadata build(){\r
- return new StateMachineMetadata(this);\r
- }\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class StateMachineMetadata {
+
+ private Set<State> states;
+ private Set<Event> events;
+
+ private StateMachineMetadata(StateMachineMetadataBuilder builder){
+ states = builder.states;
+ events = builder.events;
+ }
+
+ public Set<State> getStates() {
+ return states;
+ }
+
+ public Set<Event> getEvents() {
+ return events;
+ }
+
+ public static class StateMachineMetadataBuilder{
+
+ private Set<State> states;
+ private Set<Event> events;
+
+ public StateMachineMetadataBuilder(){
+ states = new HashSet<>();
+ events = new HashSet<>();
+ }
+
+ public StateMachineMetadataBuilder addState(State state){
+ this.states.add(state);
+ return this;
+ }
+
+ public StateMachineMetadataBuilder addEvent(Event event){
+ this.events.add(event);
+ return this;
+ }
+
+ public StateMachineMetadataBuilder addTransition(State currentState,Event event,State nextState){
+ Transition transition = new Transition(event,nextState);
+ currentState.addTransition(transition);
+ return this;
+ }
+
+ public StateMachineMetadata build(){
+ return new StateMachineMetadata(this);
+ }
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-\r
-public class StateMachineResponse {\r
- private State nextState;\r
- private Response response;\r
-\r
- public StateMachineResponse(){\r
- // do nothing\r
- }\r
-\r
- public State getNextState() {\r
- return nextState;\r
- }\r
-\r
- public Response getResponse() {\r
- return response;\r
- }\r
-\r
- public void setNextState(State nextState) {\r
- this.nextState = nextState;\r
- }\r
-\r
- public void setResponse(Response response) {\r
- this.response = response;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+
+public class StateMachineResponse {
+ private State nextState;
+ private Response response;
+
+ public StateMachineResponse(){
+ // do nothing
+ }
+
+ public State getNextState() {
+ return nextState;
+ }
+
+ public Response getResponse() {
+ return response;
+ }
+
+ public void setNextState(State nextState) {
+ this.nextState = nextState;
+ }
+
+ public void setResponse(Response response) {
+ this.response = response;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.objects;\r
-\r
-public class Transition {\r
- private Event event;\r
- private State nextState;\r
-\r
- private Transition(){\r
- // do nothing\r
- }\r
-\r
- Transition(Event event, State nextState){\r
- this();\r
- this.event = event;\r
- this.nextState = nextState;\r
- }\r
-\r
- public Event getEvent() {\r
- return event;\r
- }\r
-\r
- public State getNextState() {\r
- return nextState;\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.objects;
+
+public class Transition {
+ private Event event;
+ private State nextState;
+
+ private Transition(){
+ // do nothing
+ }
+
+ Transition(Event event, State nextState){
+ this();
+ this.event = event;
+ this.nextState = nextState;
+ }
+
+ public Event getEvent() {
+ return event;
+ }
+
+ public State getNextState() {
+ return nextState;
+ }
+}
-/*-\r
+/*-
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Copyright (C) 2017 Amdocs\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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\r
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
+ * 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.
*
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.openecomp.appc.statemachine.impl.readers;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Test;\r
-import org.osgi.framework.Bundle;\r
-\r
-import java.util.HashMap;\r
-import java.util.Map;\r
-\r
-public class AppcOamStatesTest {\r
-\r
- @Test\r
- public void testBasicFunctions() {\r
- AppcOamStates aState = AppcOamStates.EnteringMaintenanceMode;\r
- Assert.assertEquals("name() does not match", "EnteringMaintenanceMode", aState.name());\r
- Assert.assertEquals("toString() does not match", "EnteringMaintenanceMode", aState.toString());\r
- Assert.assertEquals("osgiBundleState does not match", 0, aState.osgiBundleState);\r
- }\r
-\r
- @Test\r
- public void testGetOamStateFromBundleState() {\r
- Map<Integer, AppcOamStates> resultMap = new HashMap<Integer, AppcOamStates>() {\r
- {\r
- put(Bundle.UNINSTALLED, AppcOamStates.NotInstantiated);\r
- put(Bundle.INSTALLED, AppcOamStates.Instantiated);\r
- put(Bundle.RESOLVED, AppcOamStates.Stopped);\r
- put(Bundle.STARTING, AppcOamStates.Starting);\r
- put(Bundle.STOPPING, AppcOamStates.Stopping);\r
- put(Bundle.ACTIVE, AppcOamStates.Started);\r
- }\r
- };\r
- for (Map.Entry<Integer, AppcOamStates> aEntry : resultMap.entrySet()) {\r
- Integer bundleState = aEntry.getKey();\r
- AppcOamStates oamState = aEntry.getValue();\r
- Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with oamState(%s)",\r
- bundleState, oamState), oamState, AppcOamStates.getOamStateFromBundleState(bundleState));\r
- }\r
-\r
- int bundleState = Bundle.START_TRANSIENT;\r
- Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with NotInstantiated state.",\r
- bundleState), AppcOamStates.NotInstantiated, AppcOamStates.getOamStateFromBundleState(bundleState));\r
-\r
- bundleState = Bundle.STOP_TRANSIENT;\r
- Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with NotInstantiated state.",\r
- bundleState), AppcOamStates.NotInstantiated, AppcOamStates.getOamStateFromBundleState(bundleState));\r
- }\r
-}\r
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.statemachine.impl.readers;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class AppcOamStatesTest {
+
+ @Test
+ public void testBasicFunctions() {
+ AppcOamStates aState = AppcOamStates.EnteringMaintenanceMode;
+ Assert.assertEquals("name() does not match", "EnteringMaintenanceMode", aState.name());
+ Assert.assertEquals("toString() does not match", "EnteringMaintenanceMode", aState.toString());
+ Assert.assertEquals("osgiBundleState does not match", 0, aState.osgiBundleState);
+ }
+
+ @Test
+ public void testGetOamStateFromBundleState() {
+ Map<Integer, AppcOamStates> resultMap = new HashMap<Integer, AppcOamStates>() {
+ {
+ put(Bundle.UNINSTALLED, AppcOamStates.NotInstantiated);
+ put(Bundle.INSTALLED, AppcOamStates.Instantiated);
+ put(Bundle.RESOLVED, AppcOamStates.Stopped);
+ put(Bundle.STARTING, AppcOamStates.Starting);
+ put(Bundle.STOPPING, AppcOamStates.Stopping);
+ put(Bundle.ACTIVE, AppcOamStates.Started);
+ }
+ };
+ for (Map.Entry<Integer, AppcOamStates> aEntry : resultMap.entrySet()) {
+ Integer bundleState = aEntry.getKey();
+ AppcOamStates oamState = aEntry.getValue();
+ Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with oamState(%s)",
+ bundleState, oamState), oamState, AppcOamStates.getOamStateFromBundleState(bundleState));
+ }
+
+ int bundleState = Bundle.START_TRANSIENT;
+ Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with NotInstantiated state.",
+ bundleState), AppcOamStates.NotInstantiated, AppcOamStates.getOamStateFromBundleState(bundleState));
+
+ bundleState = Bundle.STOP_TRANSIENT;
+ Assert.assertEquals(String.format("OSGI bundle state(%d) shoule associate with NotInstantiated state.",
+ bundleState), AppcOamStates.NotInstantiated, AppcOamStates.getOamStateFromBundleState(bundleState));
+ }
+}