Skip to content

Commit 5b4a6f2

Browse files
author
Alex Huang
committed
Changed networkconfigurations to network as per Sheng's suggestion
1 parent a495f34 commit 5b4a6f2

42 files changed

Lines changed: 544 additions & 533 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@
175175
import com.cloud.exception.InternalErrorException;
176176
import com.cloud.host.Host.Type;
177177
import com.cloud.hypervisor.Hypervisor.HypervisorType;
178-
import com.cloud.network.Network.BroadcastDomainType;
179-
import com.cloud.network.Network.TrafficType;
178+
import com.cloud.network.Networks.BroadcastDomainType;
179+
import com.cloud.network.Networks.TrafficType;
180180
import com.cloud.network.NetworkEnums.RouterPrivateIpStrategy;
181181
import com.cloud.resource.ServerResource;
182182
import com.cloud.resource.ServerResourceBase;

api/src/com/cloud/agent/api/to/NetworkTO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020
import java.net.URI;
2121

22-
import com.cloud.network.Network.BroadcastDomainType;
23-
import com.cloud.network.Network.TrafficType;
22+
import com.cloud.network.Networks.BroadcastDomainType;
23+
import com.cloud.network.Networks.TrafficType;
2424

2525
/**
2626
* Transfer object to transfer network settings.
Lines changed: 83 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,109 @@
11
/**
2-
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
3-
*
4-
* This software is licensed under the GNU General Public License v3 or later.
5-
*
6-
* It is free software: you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation, either version 3 of the License, or any later version.
9-
* This program is distributed in the hope that it will be useful,
10-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
* GNU General Public License for more details.
13-
*
14-
* You should have received a copy of the GNU General Public License
15-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
162
*
173
*/
184
package com.cloud.network;
195

206
import java.net.URI;
21-
import java.net.URISyntaxException;
7+
import java.util.List;
8+
import java.util.Set;
229

23-
import com.cloud.utils.exception.CloudRuntimeException;
10+
import com.cloud.acl.ControlledEntity;
11+
import com.cloud.network.Networks.BroadcastDomainType;
12+
import com.cloud.network.Networks.Mode;
13+
import com.cloud.network.Networks.TrafficType;
14+
import com.cloud.offering.NetworkOffering.GuestIpType;
15+
import com.cloud.utils.fsm.FiniteState;
16+
import com.cloud.utils.fsm.StateMachine;
2417

2518
/**
26-
* Network includes all of the enums used within networking.
27-
*
19+
* A NetworkProfile defines the specifics of a network
20+
* owned by an account.
2821
*/
29-
public class Network {
30-
/**
31-
* Different ways to assign ip address to this network.
32-
*/
33-
public enum Mode {
34-
None,
35-
Static,
36-
Dhcp,
37-
ExternalDhcp;
38-
};
39-
40-
public enum AddressFormat {
41-
Ip4,
42-
Ip6,
43-
Mixed
22+
public interface Network extends ControlledEntity {
23+
enum Event {
24+
ImplementNetwork,
25+
DestroyNetwork,
26+
OperationSucceeded,
27+
OperationFailed;
4428
}
29+
30+
enum State implements FiniteState<State, Event> {
31+
Allocated("Indicates the network configuration is in allocated but not setup"),
32+
Setup("Indicates the network configuration is setup"),
33+
Implementing("Indicates the network configuration is being implemented"),
34+
Implemented("Indicates the network configuration is in use"),
35+
Destroying("Indicates the network configuration is being destroyed");
4536

46-
/**
47-
* Different types of broadcast domains.
48-
*/
49-
public enum BroadcastDomainType {
50-
Native(null, null),
51-
Vlan("vlan", Integer.class),
52-
Vswitch("vs", String.class),
53-
LinkLocal(null, null),
54-
Vnet("vnet", Long.class),
55-
UnDecided(null, null);
56-
57-
private String scheme;
58-
private Class<?> type;
59-
60-
private BroadcastDomainType(String scheme, Class<?> type) {
61-
this.scheme = scheme;
62-
this.type = type;
37+
@Override
38+
public StateMachine<State, Event> getStateMachine() {
39+
return s_fsm;
6340
}
64-
65-
/**
66-
* @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
67-
*/
68-
public String scheme() {
69-
return scheme;
41+
42+
@Override
43+
public State getNextState(Event event) {
44+
return s_fsm.getNextState(this, event);
7045
}
71-
72-
/**
73-
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
74-
*/
75-
public Class<?> type() {
76-
return type;
46+
47+
@Override
48+
public List<State> getFromStates(Event event) {
49+
return s_fsm.getFromStates(this, event);
7750
}
78-
79-
public <T> URI toUri(T value) {
80-
try {
81-
return new URI(scheme + "://" + value);
82-
} catch (URISyntaxException e) {
83-
throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
84-
}
51+
52+
@Override
53+
public Set<Event> getPossibleEvents() {
54+
return s_fsm.getPossibleEvents(this);
8555
}
86-
};
87-
88-
/**
89-
* Different types of network traffic in the data center.
90-
*/
91-
public enum TrafficType {
92-
Public,
93-
Guest,
94-
Storage,
95-
Management,
96-
Control,
97-
Vpn
98-
};
99-
100-
public enum IsolationType {
101-
None(null, null),
102-
Ec2("ec2", String.class),
103-
Vlan("vlan", Integer.class),
104-
Vswitch("vs", String.class),
105-
Undecided(null, null),
106-
Vnet("vnet", Long.class);
10756

108-
private final String scheme;
109-
private final Class<?> type;
57+
String _description;
11058

111-
private IsolationType(String scheme, Class<?> type) {
112-
this.scheme = scheme;
113-
this.type = type;
114-
}
115-
116-
public String scheme() {
117-
return scheme;
59+
@Override
60+
public String getDescription() {
61+
return _description;
11862
}
11963

120-
public Class<?> type() {
121-
return type;
64+
private State(String description) {
65+
_description = description;
12266
}
12367

124-
public <T> URI toUri(T value) {
125-
try {
126-
return new URI(scheme + "://" + value.toString());
127-
} catch (URISyntaxException e) {
128-
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
129-
}
68+
private static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
69+
static {
70+
s_fsm.addTransition(State.Allocated, Event.ImplementNetwork, State.Implementing);
71+
s_fsm.addTransition(State.Implementing, Event.OperationSucceeded, State.Implemented);
72+
s_fsm.addTransition(State.Implementing, Event.OperationFailed, State.Destroying);
73+
s_fsm.addTransition(State.Implemented, Event.DestroyNetwork, State.Destroying);
74+
s_fsm.addTransition(State.Destroying, Event.OperationSucceeded, State.Allocated);
75+
s_fsm.addTransition(State.Destroying, Event.OperationFailed, State.Implemented);
13076
}
13177
}
13278

133-
public enum BroadcastScheme {
134-
Vlan("vlan"),
135-
VSwitch("vswitch");
136-
137-
private String scheme;
138-
139-
private BroadcastScheme(String scheme) {
140-
this.scheme = scheme;
141-
}
142-
143-
@Override
144-
public String toString() {
145-
return scheme;
146-
}
147-
}
79+
/**
80+
* @return id of the network profile. Null means the network profile is not from the database.
81+
*/
82+
long getId();
83+
84+
Mode getMode();
85+
86+
BroadcastDomainType getBroadcastDomainType();
87+
88+
TrafficType getTrafficType();
89+
90+
String getGateway();
91+
92+
String getCidr();
93+
94+
long getDataCenterId();
95+
96+
long getNetworkOfferingId();
97+
98+
State getState();
99+
100+
long getRelated();
101+
102+
URI getBroadcastUri();
103+
104+
String getDns1();
105+
106+
String getDns2();
107+
108+
GuestIpType getGuestType();
148109
}

api/src/com/cloud/network/NetworkConfiguration.java

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)