forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNic.java
More file actions
165 lines (126 loc) · 4.66 KB
/
Nic.java
File metadata and controls
165 lines (126 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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.
package com.cloud.vm;
import java.net.URI;
import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.Mode;
import com.cloud.utils.fsm.FiniteState;
import com.cloud.utils.fsm.StateMachine;
/**
* Nic represents one nic on the VM.
*/
public interface Nic extends Identity, InternalIdentity {
enum Event {
ReservationRequested, ReleaseRequested, CancelRequested, OperationCompleted, OperationFailed,
}
public enum State implements FiniteState<State, Event> {
Allocated("Resource is allocated but not reserved"), Reserving("Resource is being reserved right now"), Reserved("Resource has been reserved."), Releasing(
"Resource is being released"), Deallocating("Resource is being deallocated");
String _description;
@Override
public StateMachine<State, Event> getStateMachine() {
return s_fsm;
}
@Override
public State getNextState(Event event) {
return s_fsm.getNextState(this, event);
}
@Override
public List<State> getFromStates(Event event) {
return s_fsm.getFromStates(this, event);
}
@Override
public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
private State(String description) {
_description = description;
}
@Override
public String getDescription() {
return _description;
}
final static private StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
static {
s_fsm.addTransition(State.Allocated, Event.ReservationRequested, State.Reserving);
s_fsm.addTransition(State.Reserving, Event.CancelRequested, State.Allocated);
s_fsm.addTransition(State.Reserving, Event.OperationCompleted, State.Reserved);
s_fsm.addTransition(State.Reserving, Event.OperationFailed, State.Allocated);
s_fsm.addTransition(State.Reserved, Event.ReleaseRequested, State.Releasing);
s_fsm.addTransition(State.Releasing, Event.OperationCompleted, State.Allocated);
s_fsm.addTransition(State.Releasing, Event.OperationFailed, State.Reserved);
}
}
public enum ReservationStrategy {
PlaceHolder, Create, Start, Managed;
}
/**
* @return reservation id returned by the allocation source. This can be the String version of the database id if
* the
* allocation source does not need it's own implementation of the reservation id. This is passed back to the
* allocation source to release the resource.
*/
String getReservationId();
/**
* @return unique name for the allocation source.
*/
String getReserver();
/**
* @return the time a reservation request was made to the allocation source.
*/
Date getUpdateTime();
/**
* @return the reservation state of the resource.
*/
State getState();
ReservationStrategy getReservationStrategy();
boolean isDefaultNic();
String getMacAddress();
/**
* @return network profile id that this
*/
long getNetworkId();
/**
* @return the vm instance id that this nic belongs to.
*/
long getInstanceId();
int getDeviceId();
Mode getMode();
URI getIsolationUri();
URI getBroadcastUri();
VirtualMachine.Type getVmType();
AddressFormat getAddressFormat();
boolean getSecondaryIp();
//
// IPv4
//
String getIPv4Address();
String getIPv4Netmask();
String getIPv4Gateway();
//
// IPv6
//
String getIPv6Gateway();
String getIPv6Cidr();
String getIPv6Address();
Integer getMtu();
}