Skip to content

Commit dae3994

Browse files
committed
bug 7192: Added networktype parameter for the zone
status 7192: resolved fixed 1) Zone has networktype parameter now, 2 values are supported: Basic and Advanced. "networktype" field is created in data_center table. The parameter is being set at creation time; we don't allow to modify it with updateZone command. 2) Only vlan of Untagged Direct type can be created in Basic network zone; any other vlan except for Untagged Direct can be created in Advanced zone 3) Allow NULL guest vlan range for the zone. Only vlan of Direct type can be created in zone with NULL guest vlan. 4) "Default" zone is Basic by default. 5) Changed "vnet" parameter to "vlan" in updateZone command to be consistent with createZone
1 parent b577015 commit dae3994

15 files changed

Lines changed: 198 additions & 166 deletions

api/src/com/cloud/dc/DataCenter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*
1010
*/
1111
public interface DataCenter extends Grouping {
12+
public enum DataCenterNetworkType {
13+
Basic,
14+
Advanced
15+
}
1216
long getId();
1317
String getDns1();
1418
String getDns2();

core/.classpath

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="src" path="test"/>
5-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6-
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
7-
<classpathentry kind="lib" path="/thirdparty/xmlrpc-common-3.1.3.jar"/>
8-
<classpathentry kind="lib" path="/thirdparty/xmlrpc-client-3.1.3.jar"/>
9-
<classpathentry kind="lib" path="/thirdparty/gson-1.3.jar"/>
10-
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
11-
<classpathentry kind="lib" path="/thirdparty/cglib-nodep-2.2.jar"/>
12-
<classpathentry kind="lib" path="/thirdparty/commons-dbcp-1.2.2.jar"/>
13-
<classpathentry kind="lib" path="/thirdparty/commons-pool-1.4.jar"/>
14-
<classpathentry kind="lib" path="/thirdparty/ehcache-1.5.0.jar"/>
15-
<classpathentry kind="lib" path="/thirdparty/junit-4.8.1.jar"/>
16-
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar" sourcepath="/thirdparty/xen/XenServerJava"/>
17-
<classpathentry kind="lib" path="/thirdparty/trilead-ssh2-build213.jar"/>
18-
<classpathentry kind="lib" path="/thirdparty/commons-httpclient-3.1.jar"/>
19-
<classpathentry kind="lib" path="/thirdparty/commons-codec-1.4.jar"/>
20-
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
21-
<classpathentry kind="lib" path="/thirdparty/vmware-apputils.jar"/>
22-
<classpathentry kind="lib" path="/thirdparty/vmware-credstore.jar"/>
23-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-activation.jar"/>
24-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-axis.jar"/>
25-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen-core.jar"/>
26-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen-jdom.jar"/>
27-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen.license"/>
28-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen.readme"/>
29-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxrpc.jar"/>
30-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jdom.jar"/>
31-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-mailapi.jar"/>
32-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-saxpath.jar"/>
33-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-smtp.jar"/>
34-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-wbem.jar"/>
35-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.jar"/>
36-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.license"/>
37-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.readme"/>
38-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xerces.jar"/>
39-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xerces.readme"/>
40-
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xml-apis.jar"/>
41-
<classpathentry kind="lib" path="/thirdparty/vmware-vim.jar"/>
42-
<classpathentry kind="lib" path="/thirdparty/vmware-vim25.jar"/>
43-
<classpathentry kind="output" path="bin"/>
44-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="test"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
7+
<classpathentry kind="lib" path="/thirdparty/xmlrpc-common-3.1.3.jar"/>
8+
<classpathentry kind="lib" path="/thirdparty/xmlrpc-client-3.1.3.jar"/>
9+
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
10+
<classpathentry kind="lib" path="/thirdparty/cglib-nodep-2.2.jar"/>
11+
<classpathentry kind="lib" path="/thirdparty/commons-dbcp-1.2.2.jar"/>
12+
<classpathentry kind="lib" path="/thirdparty/commons-pool-1.4.jar"/>
13+
<classpathentry kind="lib" path="/thirdparty/ehcache-1.5.0.jar"/>
14+
<classpathentry kind="lib" path="/thirdparty/junit-4.8.1.jar"/>
15+
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar" sourcepath="/thirdparty/xen/XenServerJava"/>
16+
<classpathentry kind="lib" path="/thirdparty/trilead-ssh2-build213.jar"/>
17+
<classpathentry kind="lib" path="/thirdparty/commons-httpclient-3.1.jar"/>
18+
<classpathentry kind="lib" path="/thirdparty/commons-codec-1.4.jar"/>
19+
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
20+
<classpathentry kind="lib" path="/thirdparty/vmware-apputils.jar"/>
21+
<classpathentry kind="lib" path="/thirdparty/vmware-credstore.jar"/>
22+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-activation.jar"/>
23+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-axis.jar"/>
24+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen-core.jar"/>
25+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen-jdom.jar"/>
26+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen.license"/>
27+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxen.readme"/>
28+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jaxrpc.jar"/>
29+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-jdom.jar"/>
30+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-mailapi.jar"/>
31+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-saxpath.jar"/>
32+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-smtp.jar"/>
33+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-wbem.jar"/>
34+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.jar"/>
35+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.license"/>
36+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xalan.readme"/>
37+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xerces.jar"/>
38+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xerces.readme"/>
39+
<classpathentry kind="lib" path="/thirdparty/vmware-lib-xml-apis.jar"/>
40+
<classpathentry kind="lib" path="/thirdparty/vmware-vim.jar"/>
41+
<classpathentry kind="lib" path="/thirdparty/vmware-vim25.jar"/>
42+
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
43+
<classpathentry kind="output" path="bin"/>
44+
</classpath>

core/src/com/cloud/dc/DataCenterVO.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
import javax.persistence.Column;
2222
import javax.persistence.Entity;
23+
import javax.persistence.EnumType;
24+
import javax.persistence.Enumerated;
2325
import javax.persistence.GeneratedValue;
2426
import javax.persistence.GenerationType;
2527
import javax.persistence.Id;
@@ -67,17 +69,21 @@ public class DataCenterVO implements DataCenter {
6769

6870
@Column(name="domain")
6971
private String domain = null;
72+
73+
@Column(name="networktype")
74+
@Enumerated(EnumType.STRING)
75+
DataCenterNetworkType networkType;
7076

7177
@Column(name="mac_address", updatable = false, nullable=false)
7278
@TableGenerator(name="mac_address_sq", table="data_center", pkColumnName="id", valueColumnName="mac_address", allocationSize=1)
7379
private long macAddress = 1;
7480

75-
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId) {
76-
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain, domainId);
81+
public DataCenterVO(long id, String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType) {
82+
this(name, description, dns1, dns2, dns3, dns4, vnet, guestCidr, domain, domainId, zoneType);
7783
this.id = id;
7884
}
7985

80-
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId) {
86+
public DataCenterVO(String name, String description, String dns1, String dns2, String dns3, String dns4, String vnet, String guestCidr, String domain, Long domainId, DataCenterNetworkType zoneType) {
8187
this.name = name;
8288
this.description = description;
8389
this.dns1 = dns1;
@@ -88,6 +94,7 @@ public DataCenterVO(String name, String description, String dns1, String dns2, S
8894
this.guestNetworkCidr = guestCidr;
8995
this.domain = domain;
9096
this.domainId = domainId;
97+
this.networkType = zoneType;
9198
}
9299

93100
public Long getDomainId() {
@@ -183,5 +190,13 @@ public String getDomain() {
183190
public void setDomain(String domain) {
184191
this.domain = domain;
185192
}
193+
194+
public void setNetworkType(DataCenterNetworkType zoneNetworkType) {
195+
this.networkType = zoneNetworkType;
196+
}
197+
198+
public DataCenterNetworkType getNetworkType() {
199+
return networkType;
200+
}
186201

187202
}

server/.classpath

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="src" path="test"/>
5-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6-
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
7-
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
8-
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
9-
<classpathentry kind="lib" path="/thirdparty/cglib-nodep-2.2.jar"/>
10-
<classpathentry kind="lib" path="/thirdparty/ehcache-1.5.0.jar"/>
11-
<classpathentry kind="lib" path="/thirdparty/gson-1.3.jar"/>
12-
<classpathentry kind="lib" path="/thirdparty/commons-httpclient-3.1.jar"/>
13-
<classpathentry kind="lib" path="/thirdparty/httpcore-4.0.jar"/>
14-
<classpathentry kind="lib" path="/thirdparty/email.jar"/>
15-
<classpathentry kind="lib" path="/thirdparty/junit-4.8.1.jar"/>
16-
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar"/>
17-
<classpathentry kind="lib" path="/thirdparty/ws-commons-util-1.0.2.jar"/>
18-
<classpathentry kind="lib" path="/thirdparty/xmlrpc-client-3.1.3.jar"/>
19-
<classpathentry kind="lib" path="/thirdparty/xmlrpc-common-3.1.3.jar"/>
20-
<classpathentry kind="lib" path="/thirdparty/commons-codec-1.4.jar"/>
21-
<classpathentry kind="lib" path="/thirdparty/servlet-api.jar"/>
22-
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
23-
<classpathentry kind="lib" path="/thirdparty/trilead-ssh2-build213.jar"/>
24-
<classpathentry kind="lib" path="/thirdparty/xstream-1.3.1.jar"/>
25-
<classpathentry kind="output" path="bin"/>
26-
</classpath>
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="test"/>
5+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
6+
<classpathentry combineaccessrules="false" kind="src" path="/utils"/>
7+
<classpathentry kind="lib" path="/thirdparty/log4j-1.2.15.jar"/>
8+
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
9+
<classpathentry kind="lib" path="/thirdparty/cglib-nodep-2.2.jar"/>
10+
<classpathentry kind="lib" path="/thirdparty/ehcache-1.5.0.jar"/>
11+
<classpathentry kind="lib" path="/thirdparty/commons-httpclient-3.1.jar"/>
12+
<classpathentry kind="lib" path="/thirdparty/httpcore-4.0.jar"/>
13+
<classpathentry kind="lib" path="/thirdparty/email.jar"/>
14+
<classpathentry kind="lib" path="/thirdparty/junit-4.8.1.jar"/>
15+
<classpathentry kind="lib" path="/thirdparty/xenserver-5.5.0-1.jar"/>
16+
<classpathentry kind="lib" path="/thirdparty/ws-commons-util-1.0.2.jar"/>
17+
<classpathentry kind="lib" path="/thirdparty/xmlrpc-client-3.1.3.jar"/>
18+
<classpathentry kind="lib" path="/thirdparty/xmlrpc-common-3.1.3.jar"/>
19+
<classpathentry kind="lib" path="/thirdparty/commons-codec-1.4.jar"/>
20+
<classpathentry kind="lib" path="/thirdparty/servlet-api.jar"/>
21+
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
22+
<classpathentry kind="lib" path="/thirdparty/trilead-ssh2-build213.jar"/>
23+
<classpathentry kind="lib" path="/thirdparty/xstream-1.3.1.jar"/>
24+
<classpathentry kind="lib" path="/thirdparty/gson.jar"/>
25+
<classpathentry kind="output" path="bin"/>
26+
</classpath>

server/src/com/cloud/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,5 @@ public class ApiConstants {
160160
public static final String VNET = "vnet";
161161
public static final String VOLUME_ID = "volumeid";
162162
public static final String ZONE_ID = "zoneid";
163+
public static final String NETWORK_TYPE = "networktype";
163164
}

server/src/com/cloud/api/ApiResponseHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
import com.cloud.vm.UserVmVO;
102102
import com.cloud.vm.VMInstanceVO;
103103
import com.cloud.vm.VmStats;
104-
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
105104

106105
public class ApiResponseHelper {
107106

@@ -810,6 +809,7 @@ public static ZoneResponse createZoneResponse (DataCenterVO dataCenter) {
810809

811810
zoneResponse.setDomain(dataCenter.getDomain());
812811
zoneResponse.setDomainId(dataCenter.getDomainId());
812+
zoneResponse.setType(dataCenter.getNetworkType().toString());
813813
zoneResponse.setObjectName("zone");
814814
return zoneResponse;
815815
}

server/src/com/cloud/api/ResponseObjectTypeAdapter.java

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,52 +31,8 @@ public JsonElement serialize(ResponseObject responseObj, Type typeOfResponseObj,
3131
obj.addProperty("errortext", ((ExceptionResponse)responseObj).getErrorText());
3232
return obj;
3333
} else {
34-
// Get the declared fields from the response obj, create a new JSON Object, add props to it.
35-
// Once that object is done, create a new JSON Object with the response name and the JSON Obj as the name/value pair. Return that as the serialized element.
36-
Field[] fields = responseObj.getClass().getDeclaredFields();
37-
for (Field field : fields) {
38-
if ((field.getModifiers() & Modifier.TRANSIENT) != 0) {
39-
continue; // skip transient fields
40-
}
41-
42-
SerializedName serializedName = field.getAnnotation(SerializedName.class);
43-
if (serializedName == null) {
44-
continue; // skip fields w/o serialized name
45-
}
46-
47-
String propName = field.getName();
48-
Method method = getGetMethod(responseObj, propName);
49-
if (method != null) {
50-
try {
51-
Object fieldValue = method.invoke(responseObj);
52-
if (fieldValue != null) {
53-
if (fieldValue instanceof ResponseObject) {
54-
ResponseObject subObj = (ResponseObject)fieldValue;
55-
obj.add(serializedName.value(), serialize(subObj, subObj.getClass(), ctx));
56-
} else {
57-
if (fieldValue instanceof Number) {
58-
obj.addProperty(serializedName.value(), (Number)fieldValue);
59-
} else if (fieldValue instanceof Character) {
60-
obj.addProperty(serializedName.value(), (Character)fieldValue);
61-
} else if (fieldValue instanceof Boolean) {
62-
obj.addProperty(serializedName.value(), (Boolean)fieldValue);
63-
} else {
64-
obj.addProperty(serializedName.value(), fieldValue.toString());
65-
}
66-
}
67-
}
68-
} catch (IllegalArgumentException e) {
69-
s_logger.error("Illegal argument exception when calling ResponseObject " + responseObj.getClass().getName() + " get method for property: " + propName);
70-
} catch (IllegalAccessException e) {
71-
s_logger.error("Illegal access exception when calling ResponseObject " + responseObj.getClass().getName() + " get method for property: " + propName);
72-
} catch (InvocationTargetException e) {
73-
s_logger.error("Invocation target exception when calling ResponseObject " + responseObj.getClass().getName() + " get method for property: " + propName);
74-
}
75-
}
76-
}
77-
JsonObject response = new JsonObject();
78-
response.add(responseObj.getObjectName(), obj);
79-
return response;
34+
obj.add(responseObj.getObjectName(), ApiGsonHelper.getBuilder().create().toJsonTree(responseObj));
35+
return obj;
8036
}
8137
}
8238

server/src/com/cloud/api/commands/CreateZoneCmd.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,18 @@ public class CreateZoneCmd extends BaseCmd {
5757

5858
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the Zone")
5959
private String zoneName;
60-
61-
//FIXME - this parameter is called "vnet" in updateZone. Have to figure out which one is right
62-
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VNET for the Zone")
60+
61+
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the Zone")
6362
private String vlan;
6463

6564
@Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="Domain name for the Vms in the zone")
6665
private String domain;
6766

6867
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the ID of the containing domain, null for public zones")
6968
private Long domainId;
69+
70+
@Parameter(name=ApiConstants.NETWORK_TYPE, type=CommandType.STRING, required=true, description="network type of the zone, can be Basic or Advanced")
71+
private String networkType;
7072

7173
/////////////////////////////////////////////////////
7274
/////////////////// Accessors ///////////////////////
@@ -108,6 +110,10 @@ public Long getDomainId(){
108110
return domainId;
109111
}
110112

113+
public String getNetworkType(){
114+
return networkType;
115+
}
116+
111117
/////////////////////////////////////////////////////
112118
/////////////// API Implementation///////////////////
113119

server/src/com/cloud/api/commands/UpdateZoneCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public class UpdateZoneCmd extends BaseCmd {
6161
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the Zone")
6262
private String zoneName;
6363

64-
@Parameter(name=ApiConstants.VNET, type=CommandType.STRING, description="the VNET for the Zone")
65-
private String vnet;
64+
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the VLAN for the Zone")
65+
private String vlan;
6666

6767
// @Parameter(name=ApiConstants.DOMAIN, type=CommandType.STRING, description="Domain name for the Vms in the zone")
6868
// private String domain;
@@ -102,8 +102,8 @@ public String getZoneName() {
102102
return zoneName;
103103
}
104104

105-
public String getVnet() {
106-
return vnet;
105+
public String getVlan() {
106+
return vlan;
107107
}
108108

109109
// public String getDomain() {

server/src/com/cloud/api/response/ZoneResponse.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ public class ZoneResponse extends BaseResponse {
6363
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the containing domain, null for public zones")
6464
private Long domainId;
6565

66+
@SerializedName(ApiConstants.NETWORK_TYPE) @Param(description="the network type of the zone; can be Basic or Advanced")
67+
private String networkType;
68+
6669
public Long getId() {
6770
return id;
6871
}
@@ -166,5 +169,13 @@ public Long getDomainId() {
166169
public void setDomainId(Long domainId) {
167170
this.domainId = domainId;
168171
}
172+
173+
public String getNetworkType() {
174+
return networkType;
175+
}
176+
177+
public void setType(String networkType) {
178+
this.networkType = networkType;
179+
}
169180

170181
}

0 commit comments

Comments
 (0)