Skip to content

Commit 3b6ce97

Browse files
infra: edge zones (#6840)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com> Co-authored-by: dahn <daan@onecht.net>
1 parent 26eaae7 commit 3b6ce97

File tree

50 files changed

+1227
-377
lines changed

Some content is hidden

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

50 files changed

+1227
-377
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public enum NetworkType {
3232
Basic, Advanced,
3333
}
3434

35+
public enum Type {
36+
Core, Edge,
37+
}
38+
3539
String getDns1();
3640

3741
String getDns2();
@@ -83,4 +87,6 @@ public enum NetworkType {
8387
boolean isLocalStorageEnabled();
8488

8589
int getSortKey();
90+
91+
Type getType();
8692
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public class ApiConstants {
243243
public static final String IP_TOTAL = "iptotal";
244244
public static final String IS_CLEANUP_REQUIRED = "iscleanuprequired";
245245
public static final String IS_DYNAMIC = "isdynamic";
246+
public static final String IS_EDGE = "isedge";
246247
public static final String IS_EXTRACTABLE = "isextractable";
247248
public static final String IS_FEATURED = "isfeatured";
248249
public static final String IS_PORTABLE = "isportable";

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ public class CreatePodCmd extends BaseCmd {
5050
description = "the Zone ID in which the Pod will be created")
5151
private Long zoneId;
5252

53-
@Parameter(name = ApiConstants.START_IP, type = CommandType.STRING, required = true, description = "the starting IP address for the Pod")
53+
@Parameter(name = ApiConstants.START_IP, type = CommandType.STRING, description = "the starting IP address for the Pod")
5454
private String startIp;
5555

5656
@Parameter(name = ApiConstants.END_IP, type = CommandType.STRING, description = "the ending IP address for the Pod")
5757
private String endIp;
5858

59-
@Parameter(name = ApiConstants.NETMASK, type = CommandType.STRING, required = true, description = "the netmask for the Pod")
59+
@Parameter(name = ApiConstants.NETMASK, type = CommandType.STRING, description = "the netmask for the Pod")
6060
private String netmask;
6161

62-
@Parameter(name = ApiConstants.GATEWAY, type = CommandType.STRING, required = true, description = "the gateway for the Pod")
62+
@Parameter(name = ApiConstants.GATEWAY, type = CommandType.STRING, description = "the gateway for the Pod")
6363
private String gateway;
6464

6565
@Parameter(name = ApiConstants.ALLOCATION_STATE, type = CommandType.STRING, description = "Allocation state of this Pod for allocation of new resources")

api/src/main/java/org/apache/cloudstack/api/command/admin/zone/CreateZoneCmd.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ public class CreateZoneCmd extends BaseCmd {
8787
@Parameter(name = ApiConstants.LOCAL_STORAGE_ENABLED, type = CommandType.BOOLEAN, description = "true if local storage offering enabled, false otherwise")
8888
private Boolean localStorageEnabled;
8989

90+
@Parameter(name = ApiConstants.IS_EDGE, type = CommandType.BOOLEAN, description = "true if the zone is an edge zone, false otherwise", since = "4.18.0")
91+
private Boolean isEdge;
92+
93+
9094
/////////////////////////////////////////////////////
9195
/////////////////// Accessors ///////////////////////
9296
/////////////////////////////////////////////////////
@@ -153,6 +157,13 @@ public Boolean getLocalStorageEnabled() {
153157
return localStorageEnabled;
154158
}
155159

160+
public boolean isEdge() {
161+
if (isEdge == null) {
162+
return false;
163+
}
164+
return isEdge;
165+
}
166+
156167
/////////////////////////////////////////////////////
157168
/////////////// API Implementation///////////////////
158169
@Override

api/src/main/java/org/apache/cloudstack/api/response/ZoneResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
141141
@Param(description = "The maximum value the MTU can have on the VR's public interfaces", since = "4.18.0")
142142
private Integer routerPublicInterfaceMaxMtu;
143143

144+
@SerializedName(ApiConstants.TYPE)
145+
@Param(description = "the type of the zone - core or edge", since = "4.18.0")
146+
String type;
147+
144148
public ZoneResponse() {
145149
tags = new LinkedHashSet<ResourceTagResponse>();
146150
}
@@ -352,4 +356,12 @@ public void setRouterPrivateInterfaceMaxMtu(Integer routerPrivateInterfaceMaxMtu
352356
public void setRouterPublicInterfaceMaxMtu(Integer routerPublicInterfaceMaxMtu) {
353357
this.routerPublicInterfaceMaxMtu = routerPublicInterfaceMaxMtu;
354358
}
359+
360+
public void setType(String type) {
361+
this.type = type;
362+
}
363+
364+
public String getType() {
365+
return type;
366+
}
355367
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.admin.zone;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
import org.springframework.test.util.ReflectionTestUtils;
22+
23+
public class CreateZoneCmdTest {
24+
25+
@Test
26+
public void isEdge() {
27+
CreateZoneCmd createZoneCmd = new CreateZoneCmd();
28+
ReflectionTestUtils.setField(createZoneCmd, "isEdge", null);
29+
Assert.assertFalse("Null or no isedge param value for API should return false", createZoneCmd.isEdge());
30+
ReflectionTestUtils.setField(createZoneCmd, "isEdge", false);
31+
Assert.assertFalse("false value for isedge param value for API should return false", createZoneCmd.isEdge());
32+
ReflectionTestUtils.setField(createZoneCmd, "isEdge", true);
33+
Assert.assertTrue("true value for isedge param value for API should return true", createZoneCmd.isEdge());
34+
}
35+
}

engine/components-api/src/main/java/com/cloud/configuration/ConfigurationManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public interface ConfigurationManager {
127127
*
128128
* @param userId
129129
* @param podName
130-
* @param zoneId
130+
* @param zone
131131
* @param gateway
132132
* @param cidr
133133
* @param startIp
@@ -137,7 +137,7 @@ public interface ConfigurationManager {
137137
* (true if it is ok to not validate that gateway IP address overlap with Start/End IP of the POD)
138138
* @return Pod
139139
*/
140-
HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp, String allocationState,
140+
HostPodVO createPod(long userId, String podName, DataCenter zone, String gateway, String cidr, String startIp, String endIp, String allocationState,
141141
boolean skipGatewayOverlapCheck);
142142

143143
/**
@@ -164,7 +164,7 @@ HostPodVO createPod(long userId, String podName, long zoneId, String gateway, St
164164
*/
165165
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String guestCidr, String domain,
166166
Long domainId, NetworkType zoneType, String allocationState, String networkDomain, boolean isSecurityGroupEnabled, boolean isLocalStorageEnabled, String ip6Dns1,
167-
String ip6Dns2);
167+
String ip6Dns2, boolean isEdge);
168168

169169
/**
170170
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated

engine/orchestration/src/main/java/org/apache/cloudstack/engine/datacenter/entity/api/db/EngineDataCenterVO.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
3838
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
3939

40+
import com.cloud.dc.DataCenter;
4041
import com.cloud.network.Network.Provider;
4142
import com.cloud.org.Grouping;
4243
import com.cloud.utils.NumbersUtil;
@@ -156,6 +157,10 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
156157
@Temporal(value = TemporalType.TIMESTAMP)
157158
protected Date lastUpdated;
158159

160+
@Column(name = "type")
161+
@Enumerated(value = EnumType.STRING)
162+
private DataCenter.Type type;
163+
159164
/**
160165
* Note that state is intentionally missing the setter. Any updates to
161166
* the state machine needs to go through the DAO object because someone
@@ -513,4 +518,9 @@ public void setIp6Dns2(String ip6Dns2) {
513518
public PartitionType partitionType() {
514519
return PartitionType.Zone;
515520
}
521+
522+
@Override
523+
public DataCenter.Type getType() {
524+
return type;
525+
}
516526
}

engine/schema/src/main/java/com/cloud/dc/DataCenterVO.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ public class DataCenterVO implements DataCenter {
138138
@Column(name = "sort_key")
139139
int sortKey;
140140

141+
@Column(name = "type")
142+
@Enumerated(value = EnumType.STRING)
143+
private DataCenter.Type type;
144+
141145
@Override
142146
public String getDnsProvider() {
143147
return dnsProvider;
@@ -472,6 +476,15 @@ public PartitionType partitionType() {
472476
return PartitionType.Zone;
473477
}
474478

479+
@Override
480+
public DataCenter.Type getType() {
481+
return type;
482+
}
483+
484+
public void setType(Type type) {
485+
this.type = type;
486+
}
487+
475488
@Override
476489
public String toString() {
477490
return String.format("Zone {\"id\": \"%s\", \"name\": \"%s\", \"uuid\": \"%s\"}", id, name, uuid);

engine/schema/src/main/java/com/cloud/dc/dao/DataCenterDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public Integer getVlan() {
104104

105105
List<DataCenterVO> listEnabledZones();
106106

107+
List<Long> listEnabledNonEdgeZoneIds();
108+
107109
DataCenterVO findByToken(String zoneToken);
108110

109111
DataCenterVO findByTokenOrIdOrName(String tokenIdOrName);

0 commit comments

Comments
 (0)