aboutsummaryrefslogtreecommitdiffstats
path: root/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp')
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMachine.java34
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMetaDataReader.java31
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineFactory.java40
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineImpl.java98
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamMetaDataReader.java107
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamStates.java56
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/VnfMetaDataReader.java483
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Event.java65
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Response.java32
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/State.java77
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineMetadata.java78
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineResponse.java51
-rw-r--r--appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Transition.java48
13 files changed, 1200 insertions, 0 deletions
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMachine.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMachine.java
new file mode 100644
index 000000000..1c74861c3
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMachine.java
@@ -0,0 +1,34 @@
+/*-
+ * ============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;
+
+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;
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMetaDataReader.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMetaDataReader.java
new file mode 100644
index 000000000..0ddbd2f90
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/StateMetaDataReader.java
@@ -0,0 +1,31 @@
+/*-
+ * ============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;
+
+import org.openecomp.appc.statemachine.objects.StateMachineMetadata;
+
+public interface StateMetaDataReader {
+ StateMachineMetadata readMetadata();
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineFactory.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineFactory.java
new file mode 100644
index 000000000..6c7951f84
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineFactory.java
@@ -0,0 +1,40 @@
+/*-
+ * ============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 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);
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineImpl.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineImpl.java
new file mode 100644
index 000000000..124cf36d1
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/StateMachineImpl.java
@@ -0,0 +1,98 @@
+/*-
+ * ============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 +
+ '}';
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamMetaDataReader.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamMetaDataReader.java
new file mode 100644
index 000000000..e160e7f0e
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamMetaDataReader.java
@@ -0,0 +1,107 @@
+/*-
+ * ============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.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();
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamStates.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamStates.java
new file mode 100644
index 000000000..2f000d9cd
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/AppcOamStates.java
@@ -0,0 +1,56 @@
+/*-
+ * ============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.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;
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/VnfMetaDataReader.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/VnfMetaDataReader.java
new file mode 100644
index 000000000..e3e72f6d1
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/impl/readers/VnfMetaDataReader.java
@@ -0,0 +1,483 @@
+/*-
+ * ============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.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();
+
+ }
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Event.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Event.java
new file mode 100644
index 000000000..0808b1b55
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Event.java
@@ -0,0 +1,65 @@
+/*-
+ * ============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.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;
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Response.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Response.java
new file mode 100644
index 000000000..622a4274a
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Response.java
@@ -0,0 +1,32 @@
+/*-
+ * ============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.objects;
+
+public enum Response {
+ NO_TRANSITION_DEFINED,NO_STATE_CHANGE,VALID_TRANSITION;
+ public String toString(){
+ return this.name();
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/State.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/State.java
new file mode 100644
index 000000000..99d6a0ac2
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/State.java
@@ -0,0 +1,77 @@
+/*-
+ * ============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.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;
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineMetadata.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineMetadata.java
new file mode 100644
index 000000000..5a8984c73
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineMetadata.java
@@ -0,0 +1,78 @@
+/*-
+ * ============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.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);
+ }
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineResponse.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineResponse.java
new file mode 100644
index 000000000..7f78087fa
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/StateMachineResponse.java
@@ -0,0 +1,51 @@
+/*-
+ * ============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.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;
+ }
+}
diff --git a/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Transition.java b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Transition.java
new file mode 100644
index 000000000..b050268eb
--- /dev/null
+++ b/appc-lifecycle-management/state-machine-lib/src/main/java/org/openecomp/appc/statemachine/objects/Transition.java
@@ -0,0 +1,48 @@
+/*-
+ * ============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.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;
+ }
+}