blob: f65901c9d4c970a3d306ddbeac525d62beb62e60 [file] [log] [blame]
Hyunsun Moon0d457362017-06-27 17:19:41 +09001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Hyunsun Moon0d457362017-06-27 17:19:41 +09003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.openstacknode.api;
17
18/**
19 * Defines the initialization states of OpenStack node.
20 */
21public enum NodeState {
22
23 /**
24 * Indicates the node is newly added.
25 */
26 INIT {
27 @Override
28 public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
29 handler.processInitState(osNode);
30 }
31
32 @Override
33 public NodeState nextState() {
34 return DEVICE_CREATED;
35 }
36 },
37 /**
38 * Indicates bridge devices are added according to the node state.
39 */
40 DEVICE_CREATED {
41 @Override
42 public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
43 handler.processDeviceCreatedState(osNode);
44 }
45
46 @Override
47 public NodeState nextState() {
48 return PORT_CREATED;
49 }
50 },
51 /**
52 * Indicates required ports are added.
53 */
54 PORT_CREATED {
55 @Override
56 public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
57 handler.processPortCreatedState(osNode);
58 }
59
60 @Override
61 public NodeState nextState() {
62 return COMPLETE;
63 }
64 },
65 /**
66 * Indicates node initialization is done.
67 */
68 COMPLETE {
69 @Override
70 public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
71 handler.processCompleteState(osNode);
72 }
73
74 @Override
75 public NodeState nextState() {
76 return COMPLETE;
77 }
78
79 },
80 /**
81 * Indicates node is broken.
82 */
83 INCOMPLETE {
84 @Override
85 public void process(OpenstackNodeHandler handler, OpenstackNode osNode) {
86 handler.processIncompleteState(osNode);
87 }
88
89 @Override
90 public NodeState nextState() {
91 return INIT;
92 }
93 };
94
95 public abstract void process(OpenstackNodeHandler handler, OpenstackNode osNode);
96 public abstract NodeState nextState();
97}