Skip to content

Commit 737cd69

Browse files
committed
Support adding netris provider to CloudStack and Netris VPC Creation (#6)
* Support adding netris provider to CloudStack * revert marvin change * add license and perform session check when provider is added * add license and remove unused import * fix build failure - uunused imports * address comments * fix provider name * add Netris network element * add license * Add netris management APIs and netris service provider * add license * revert change * remove other network elements from Netris element * fix api name in doc generator * remove logs * move session alive check to CheckHealthCommand exec * Fix zone creation wizard to configure netris provider * Upgrade GSON version - from PR 8756 * Add additional parametes to the add Netris provider API * add netris as a host * add additional params to the resoponse and update UI * Rename site to site_name * Create Netris VPC (#8) * Delegate API classes creation to the SDK and simply invoke the desired API class through CloudStack (#7) * Delegate API classes creation to the SDK and simply invoke the desired API class through CloudStack * Pass default auth scheme for now * Drop for_nsx and for_tungten columns in favour of checking the provider on the ntwserviceprovider map table * Remove missing setForTungsten occurrence * Remove forNsx from VPC offerings * Create Netris VPC * Fix VPC offerings listing and remove unused dao * Create VPC fixes * Upgrade GSON version - from PR 8756 * Fix VPC creation response by using the latest SDK code * Fix unit test * Remove unused import * Fix NSX unit tests after refactoring * Add Netris key to the VLAN Details table (#10) * Add Netris key to the VLAN Details table * update for_<provider> column to be generic * Fix VPC and add IPAM allocation for the VPC CIDR (#9) * Fix VPC and add IPAM allocation for the VPC CIDR * Remove VPC logic * Use zoneId accountId and domainId on resources creation * Fix naming * Fix VR public nic issue * Fix Netris Public IP for VPC source NAT allocation * Add Netris VPC Subnets and vNets (#11) * Add Netris VPC Subnets and vNets * fix compilation errors * Add netris subnet * refactor naming convention to differentiate between VPC tiers and Isolated networks * revert marvin change * fix constructor - build failure * Add support to filter netris offerings, delete netris provider when zone is being deleted * Fix build * Fix VPC creation * Fix vnet creation * unnecesary log Authored-by: Pearl Dsilva <[email protected]>
1 parent a3dd9a1 commit 737cd69

File tree

95 files changed

+2976
-301
lines changed

Some content is hidden

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

95 files changed

+2976
-301
lines changed

api/src/main/java/com/cloud/configuration/ConfigurationService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
package com.cloud.configuration;
1818

1919
import java.util.List;
20+
import java.util.Map;
21+
import java.util.Objects;
2022

23+
import com.cloud.network.Network;
24+
import org.apache.cloudstack.api.ApiConstants;
2125
import org.apache.cloudstack.api.command.admin.config.ResetCfgCmd;
2226
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
2327
import org.apache.cloudstack.api.command.admin.network.CreateGuestNetworkIpv6PrefixCmd;
@@ -372,4 +376,16 @@ Vlan updateVlanAndPublicIpRange(UpdateVlanIpRangeCmd cmd) throws ConcurrentOpera
372376
List<? extends PortableIp> listPortableIps(long id);
373377

374378
Boolean isAccountAllowedToCreateOfferingsWithTags(IsAccountAllowedToCreateOfferingsWithTagsCmd cmd);
379+
380+
public static final Map<String, String> ProviderDetailKeyMap = Map.of(
381+
Network.Provider.Nsx.getName(), ApiConstants.NSX_DETAIL_KEY,
382+
Network.Provider.Netris.getName(), ApiConstants.NETRIS_DETAIL_KEY
383+
);
384+
385+
public static boolean IsIpRangeForProvider(Network.Provider provider) {
386+
if (Objects.isNull(provider)) {
387+
return false;
388+
}
389+
return ProviderDetailKeyMap.containsKey(provider.getName());
390+
}
375391
}

api/src/main/java/com/cloud/network/Networks.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ public <T> URI toUri(T value) {
129129
UnDecided(null, null),
130130
OpenDaylight("opendaylight", String.class),
131131
TUNGSTEN("tf", String.class),
132-
NSX("nsx", String.class);
132+
NSX("nsx", String.class),
133+
Netris("netris", String.class);
133134

134135
private final String scheme;
135136
private final Class<?> type;

api/src/main/java/com/cloud/network/netris/NetrisProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ public interface NetrisProvider extends InternalIdentity, Identity {
2525
String getHostname();
2626
String getPort();
2727
String getUsername();
28+
String getSiteName();
29+
String getTenantName();
2830
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 com.cloud.network.netris;
18+
19+
import com.cloud.network.vpc.Vpc;
20+
21+
public interface NetrisService {
22+
boolean createVpcResource(long zoneId, long accountId, long domainId, Long vpcId, String vpcName, boolean sourceNatEnabled, String cidr, boolean isVpcNetwork);
23+
boolean deleteVpcResource(long zoneId, long accountId, long domainId, Vpc vpc);
24+
boolean createVnetResource(Long zoneId, long accountId, long domainId, String vpcName, Long vpcId, String networkName, Long networkId, String cidr);
25+
}

api/src/main/java/com/cloud/network/vpc/VpcOffering.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public enum State {
5757
*/
5858
boolean isDefault();
5959

60-
boolean isForNsx();
61-
6260
NetworkOffering.NetworkMode getNetworkMode();
6361

6462
/**

api/src/main/java/com/cloud/offering/NetworkOffering.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ enum RoutingMode {
103103

104104
boolean isForVpc();
105105

106-
boolean isForTungsten();
107-
108-
boolean isForNsx();
109-
110106
NetworkMode getNetworkMode();
111107

112108
TrafficType getTrafficType();

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ public class ApiConstants {
328328
public static final String MIN_CPU_NUMBER = "mincpunumber";
329329
public static final String MIN_MEMORY = "minmemory";
330330
public static final String MIGRATION_TYPE = "migrationtype";
331+
public static final String MIGRATION_JOB_ID = "migrationjobid";
332+
public static final String MIGRATION_JOB_STATUS = "migrationjobstatus";
331333
public static final String MIGRATIONS = "migrations";
332334
public static final String MEMORY = "memory";
333335
public static final String MODE = "mode";
@@ -458,6 +460,7 @@ public class ApiConstants {
458460
public static final String SIGNATURE = "signature";
459461
public static final String SIGNATURE_VERSION = "signatureversion";
460462
public static final String SINCE = "since";
463+
public static final String SITE_NAME = "sitename";
461464
public static final String SIZE = "size";
462465
public static final String SIZEGB = "sizegb";
463466
public static final String SNAPSHOT = "snapshot";
@@ -502,6 +505,7 @@ public class ApiConstants {
502505
public static final String TIMEOUT = "timeout";
503506
public static final String TIMEZONE = "timezone";
504507
public static final String TIMEZONEOFFSET = "timezoneoffset";
508+
public static final String TENANT_NAME = "tenantname";
505509
public static final String TOTAL = "total";
506510
public static final String TOTAL_SUBNETS = "totalsubnets";
507511
public static final String TYPE = "type";
@@ -1156,6 +1160,7 @@ public class ApiConstants {
11561160
public static final String SOURCE_NAT_IP_ID = "sourcenatipaddressid";
11571161
public static final String HAS_RULES = "hasrules";
11581162
public static final String NSX_DETAIL_KEY = "forNsx";
1163+
public static final String NETRIS_DETAIL_KEY = "forNetris";
11591164
public static final String DISK_PATH = "diskpath";
11601165
public static final String IMPORT_SOURCE = "importsource";
11611166
public static final String TEMP_PATH = "temppath";

api/src/main/java/org/apache/cloudstack/api/command/admin/vlan/CreateVlanIpRangeCmd.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.vlan;
1818

19+
import com.cloud.configuration.ConfigurationService;
20+
import com.cloud.network.Network;
1921
import com.cloud.utils.net.NetUtils;
2022

2123
import org.apache.cloudstack.api.APICommand;
@@ -39,7 +41,6 @@
3941
import com.cloud.exception.ResourceUnavailableException;
4042
import com.cloud.user.Account;
4143

42-
import java.util.Objects;
4344

4445
@APICommand(name = "createVlanIpRange", description = "Creates a VLAN IP range.", responseObject = VlanIpRangeResponse.class,
4546
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -114,8 +115,8 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
114115
@Parameter(name = ApiConstants.FOR_SYSTEM_VMS, type = CommandType.BOOLEAN, description = "true if IP range is set to system vms, false if not")
115116
private Boolean forSystemVms;
116117

117-
@Parameter(name = ApiConstants.FOR_NSX, type = CommandType.BOOLEAN, description = "true if the IP range is used for NSX resource", since = "4.20.0")
118-
private boolean forNsx;
118+
@Parameter(name = ApiConstants.PROVIDER, type = CommandType.STRING, description = "Provider name for which the IP range is reserved for", since = "4.20.0")
119+
private String provider;
119120

120121
/////////////////////////////////////////////////////
121122
/////////////////// Accessors ///////////////////////
@@ -157,12 +158,12 @@ public String getStartIp() {
157158
return startIp;
158159
}
159160

160-
public boolean isForNsx() {
161-
return !Objects.isNull(forNsx) && forNsx;
161+
public Network.Provider getProvider() {
162+
return Network.Provider.getProvider(provider);
162163
}
163164

164165
public String getVlan() {
165-
if ((vlan == null || vlan.isEmpty()) && !isForNsx()) {
166+
if ((vlan == null || vlan.isEmpty()) && !ConfigurationService.IsIpRangeForProvider(getProvider())) {
166167
vlan = "untagged";
167168
}
168169
return vlan;

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ public class AsyncJobResponse extends BaseResponse {
5555
@Param(description = "the async command executed")
5656
private String cmd;
5757

58-
@SerializedName("jobstatus")
59-
@Param(description = "the current job status-should be 0 for PENDING")
60-
private Integer jobStatus;
61-
6258
@SerializedName("jobprocstatus")
6359
@Param(description = "the progress information of the PENDING job")
6460
private Integer jobProcStatus;
@@ -119,11 +115,6 @@ public void setCmd(String cmd) {
119115
this.cmd = cmd;
120116
}
121117

122-
@Override
123-
public void setJobStatus(Integer jobStatus) {
124-
this.jobStatus = jobStatus;
125-
}
126-
127118
public void setJobProcStatus(Integer jobProcStatus) {
128119
this.jobProcStatus = jobProcStatus;
129120
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public class ClusterDrsPlanMigrationResponse extends BaseResponse {
5050
@Param(description = "Destination host for VM migration")
5151
String destHostName;
5252

53-
@SerializedName(ApiConstants.JOB_ID)
53+
@SerializedName(ApiConstants.MIGRATION_JOB_ID)
5454
@Param(description = "id of VM migration async job")
55-
private Long jobId;
55+
private Long migrationJobId;
5656

57-
@SerializedName(ApiConstants.JOB_STATUS)
57+
@SerializedName(ApiConstants.MIGRATION_JOB_STATUS)
5858
@Param(description = "Job status of VM migration async job")
59-
private JobInfo.Status jobStatus;
59+
private JobInfo.Status migrationJobStatus;
6060

6161

6262
public ClusterDrsPlanMigrationResponse(String vmId, String vmName, String srcHostId, String srcHostName,
@@ -68,8 +68,8 @@ public ClusterDrsPlanMigrationResponse(String vmId, String vmName, String srcHos
6868
this.srcHostName = srcHostName;
6969
this.destHostId = destHostId;
7070
this.destHostName = destHostName;
71-
this.jobId = jobId;
72-
this.jobStatus = jobStatus;
71+
this.migrationJobId = jobId;
72+
this.migrationJobStatus = jobStatus;
7373
this.setObjectName(ApiConstants.MIGRATIONS);
7474
}
7575
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,6 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
212212
@Param(description = "Name of the VPC to which this network belongs", since = "4.15")
213213
private String vpcName;
214214

215-
@SerializedName(ApiConstants.ASSOCIATED_NETWORK_ID)
216-
@Param(description = "the ID of the Network associated with this network")
217-
private String associatedNetworkId;
218-
219-
@SerializedName(ApiConstants.ASSOCIATED_NETWORK)
220-
@Param(description = "the name of the Network associated with this network")
221-
private String associatedNetworkName;
222-
223215
@SerializedName(ApiConstants.TUNGSTEN_VIRTUAL_ROUTER_UUID)
224216
@Param(description = "Tungsten-Fabric virtual router the network belongs to")
225217
private String tungstenVirtualRouterUuid;
@@ -620,14 +612,6 @@ public void setVpcName(String vpcName) {
620612
this.vpcName = vpcName;
621613
}
622614

623-
public void setAssociatedNetworkId(String associatedNetworkId) {
624-
this.associatedNetworkId = associatedNetworkId;
625-
}
626-
627-
public void setAssociatedNetworkName(String associatedNetworkName) {
628-
this.associatedNetworkName = associatedNetworkName;
629-
}
630-
631615
@Override
632616
public void setResourceIconResponse(ResourceIconResponse icon) {
633617
this.icon = icon;

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,6 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
3838
@Param(description = "the system VM type")
3939
private String systemVmType;
4040

41-
@SerializedName("jobid")
42-
@Param(description = "the job ID associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
43-
private String jobId;
44-
45-
@SerializedName("jobstatus")
46-
@Param(description = "the job status associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
47-
private Integer jobStatus;
48-
4941
@SerializedName("zoneid")
5042
@Param(description = "the Zone ID for the system VM")
5143
private String zoneId;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public class VlanIpRangeResponse extends BaseResponse implements ControlledEntit
127127
@Param(description = "indicates whether VLAN IP range is dedicated to system vms or not")
128128
private Boolean forSystemVms;
129129

130-
@SerializedName(ApiConstants.FOR_NSX)
131-
@Param(description = "indicates whether IP range is dedicated to NSX resources or not")
132-
private Boolean forNsx;
130+
@SerializedName(ApiConstants.PROVIDER)
131+
@Param(description = "indicates whether IP range is dedicated to NSX resources or not", since = "4.20.0")
132+
private String provider;
133133

134134
public void setId(String id) {
135135
this.id = id;
@@ -249,7 +249,7 @@ public void setIp6Cidr(String ip6Cidr) {
249249
this.ip6Cidr = ip6Cidr;
250250
}
251251

252-
public void setForNsx(Boolean forNsx) {
253-
this.forNsx = forNsx;
252+
public void setProvider(String provider) {
253+
this.provider = provider;
254254
}
255255
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,15 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
145145
@Param(description = "the type of the zone - core or edge", since = "4.18.0")
146146
String type;
147147

148+
@Deprecated(since = "4.20")
148149
@SerializedName(ApiConstants.NSX_ENABLED)
149150
@Param(description = "true, if zone is NSX enabled", since = "4.20.0")
150151
private boolean nsxEnabled = false;
151152

153+
@SerializedName(ApiConstants.PROVIDER)
154+
@Param(description = "External network provider if any", since = "4.20.0")
155+
private String provider = null;
156+
152157
@SerializedName(ApiConstants.MULTI_ARCH)
153158
@Param(description = "true, if zone contains clusters and hosts from different CPU architectures", since = "4.20")
154159
private boolean multiArch;
@@ -373,6 +378,14 @@ public boolean isNsxEnabled() {
373378
return nsxEnabled;
374379
}
375380

381+
public String getProvider() {
382+
return provider;
383+
}
384+
385+
public void setProvider(String provider) {
386+
this.provider = provider;
387+
}
388+
376389
@Override
377390
public void setResourceIconResponse(ResourceIconResponse resourceIconResponse) {
378391
this.resourceIconResponse = resourceIconResponse;

client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,6 +1097,11 @@
10971097
<artifactId>cloud-plugin-network-nsx</artifactId>
10981098
<version>${project.version}</version>
10991099
</dependency>
1100+
<dependency>
1101+
<groupId>org.apache.cloudstack</groupId>
1102+
<artifactId>cloud-plugin-network-netris</artifactId>
1103+
<version>${project.version}</version>
1104+
</dependency>
11001105
<dependency>
11011106
<groupId>org.apache.cloudstack</groupId>
11021107
<artifactId>cloud-plugin-network-tungsten</artifactId>

core/src/main/java/com/cloud/agent/transport/ArrayTypeAdaptor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,17 @@ public T[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContex
7575
try {
7676
clazz = Class.forName(name);
7777
} catch (ClassNotFoundException e) {
78-
throw new CloudRuntimeException("can't find " + name);
78+
throw new JsonParseException("can't find " + name);
7979
}
8080
T cmd = (T)_gson.fromJson(entry.getValue(), clazz);
8181
cmds.add(cmd);
8282
}
83-
Class<?> type = ((Class<?>)typeOfT).getComponentType();
84-
T[] ts = (T[])Array.newInstance(type, cmds.size());
85-
return cmds.toArray(ts);
83+
try {
84+
Class<?> type = Class.forName(typeOfT.getTypeName().replace("[]", ""));
85+
T[] ts = (T[])Array.newInstance(type, cmds.size());
86+
return cmds.toArray(ts);
87+
} catch (ClassNotFoundException e) {
88+
throw new CloudRuntimeException("can't find " + typeOfT.getTypeName());
89+
}
8690
}
8791
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ NetworkOfferingVO createNetworkOffering(String name, String displayText, Traffic
227227
NetworkOffering.RoutingMode routingMode, boolean specifyAsNumber);
228228

229229
Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetworkId, boolean forVirtualNetwork, boolean forSystemVms, Long podId, String startIP, String endIP,
230-
String vlanGateway, String vlanNetmask, String vlanId, boolean bypassVlanOverlapCheck, Domain domain, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr, boolean forNsx)
230+
String vlanGateway, String vlanNetmask, String vlanId, boolean bypassVlanOverlapCheck, Domain domain, Account vlanOwner, String startIPv6, String endIPv6, String vlanIp6Gateway, String vlanIp6Cidr, Provider provider)
231231
throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
232232

233233
void createDefaultSystemNetworks(long zoneId) throws ConcurrentOperationException;

0 commit comments

Comments
 (0)