Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
77dc299
Enhancement: create Shared networks and VPC private gateways by users
weizhouapache Nov 29, 2021
5f58791
UI bug fix: pass correct domainid in CreateSharedNetworkForm
weizhouapache Nov 29, 2021
d571e1c
Update #5730: fix test failure with test_guest_vlan_range.py
weizhouapache Nov 30, 2021
3951120
Update #5730: fix test failure with test_persistent_network.py
weizhouapache Nov 30, 2021
8e14d03
Update #5730: Add since to new API commands and API parameters
weizhouapache Nov 30, 2021
65a82df
Update #5730: Get first physical network for VPC private gateway if o…
weizhouapache Nov 30, 2021
48b4908
Update #5730: code optimization (return !offering.isSpecifyVlan())
weizhouapache Nov 30, 2021
c47b691
Update #5730: fix hard-coded network offering id in test_pvlan.py
weizhouapache Dec 1, 2021
4024c34
Update #5730: skip access check on the network owner if the owner is …
weizhouapache Dec 1, 2021
6d62fb0
Update #5730: overlap check on cidr/startip/endip
weizhouapache Dec 1, 2021
f0b5cf9
Update #5730: add methods to get accountid/domainid of shared networks
weizhouapache Dec 3, 2021
3b0fbb2
Update #5730: improve integration tests
weizhouapache Dec 3, 2021
0a12ed7
Update #5730: update as per GutoVeronezi's comments
weizhouapache Dec 7, 2021
1dbc3ca
Merge remote-tracking branch 'apache/main' into 4.17-user-shared-netw…
weizhouapache Dec 10, 2021
9dc349c
Merge remote-tracking branch 'apache/main' into 4.17-user-shared-netw…
weizhouapache Dec 15, 2021
f12b3f1
UI: fix create Isolated/L2 network form
weizhouapache Dec 15, 2021
cd5d6f4
Update #5730: fix create Shared network form
weizhouapache Dec 15, 2021
76be448
Update #5769: fix domain admin can deploy vm on L2 network of other u…
weizhouapache Dec 14, 2021
2e149c2
test: fix test_storage_policy.py
weizhouapache Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions api/src/main/java/com/cloud/network/GuestVlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@
// under the License.
package com.cloud.network;

import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

public interface GuestVlan extends InternalIdentity, Identity {
import java.util.Date;

public interface GuestVlan extends InternalIdentity {

@Override
public long getId();

public long getAccountId();
Date getTakenAt();

String getVnet();

String getReservationId();

Long getAccountId();

long getDataCenterId();

public String getGuestVlanRange();
long getPhysicalNetworkId();

public long getPhysicalNetworkId();
Long getAccountGuestVlanMapId();
}
32 changes: 32 additions & 0 deletions api/src/main/java/com/cloud/network/GuestVlanRange.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// 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.network;

import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;

public interface GuestVlanRange extends InternalIdentity, Identity {

@Override
public long getId();

public long getAccountId();

public String getGuestVlanRange();

public long getPhysicalNetworkId();
}
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/network/Network.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ public void setIp6Address(String ip6Address) {
}
}

static final String AssociatedNetworkId = "AssociatedNetworkId";

String getName();

Mode getMode();
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/network/NetworkModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ public interface NetworkModel {

void checkNetworkPermissions(Account owner, Network network);

void checkNetworkOperatePermissions(Account owner, Network network);

String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);

String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
Expand Down
9 changes: 6 additions & 3 deletions api/src/main/java/com/cloud/network/NetworkService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
import org.apache.cloudstack.api.command.admin.network.ListGuestVlansCmd;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
Expand Down Expand Up @@ -144,9 +145,9 @@ PhysicalNetworkTrafficType addTrafficTypeToPhysicalNetwork(Long physicalNetworkI

boolean deletePhysicalNetworkTrafficType(Long id);

GuestVlan dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd);
GuestVlanRange dedicateGuestVlanRange(DedicateGuestVlanRangeCmd cmd);

Pair<List<? extends GuestVlan>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd);
Pair<List<? extends GuestVlanRange>, Integer> listDedicatedGuestVlanRanges(ListDedicatedGuestVlanRangesCmd cmd);

boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId);

Expand Down Expand Up @@ -180,7 +181,7 @@ IpAddress associateIPToNetwork(long ipId, long networkId) throws InsufficientAdd
* @throws ResourceAllocationException
*/
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String broadcastUri, String startIp, String endIP, String gateway,
String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck) throws ResourceAllocationException, ConcurrentOperationException,
String netmask, long networkOwnerId, Long vpcId, Boolean sourceNat, Long networkOfferingId, Boolean bypassVlanOverlapCheck, Long associatedNetworkId) throws ResourceAllocationException, ConcurrentOperationException,
InsufficientCapacityException;

/**
Expand All @@ -206,4 +207,6 @@ Network createPrivateNetwork(String networkName, String displayText, long physic
AcquirePodIpCmdResponse allocatePodIp(Account account, String zoneId, String podId) throws ResourceAllocationException, ConcurrentOperationException;

boolean releasePodIp(ReleasePodIpCmdByAdmin ip) throws CloudRuntimeException;

Pair<List<? extends GuestVlan>, Integer> listGuestVlans(ListGuestVlansCmd cmd);
}
4 changes: 2 additions & 2 deletions api/src/main/java/com/cloud/network/vpc/VpcService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.Map;

import org.apache.cloudstack.api.command.user.vpc.CreatePrivateGatewayCmd;
import org.apache.cloudstack.api.command.user.vpc.ListPrivateGatewaysCmd;
import org.apache.cloudstack.api.command.user.vpc.ListStaticRoutesCmd;
import org.apache.cloudstack.api.command.user.vpc.RestartVPCCmd;
Expand Down Expand Up @@ -165,8 +166,7 @@ public Pair<List<? extends Vpc>, Integer> listVpcs(Long id, String vpcName, Stri
* @throws ConcurrentOperationException
* @throws ResourceAllocationException
*/
public PrivateGateway createVpcPrivateGateway(long vpcId, Long physicalNetworkId, String vlan, String ipAddress, String gateway, String netmask, long gatewayOwnerId,
Long networkOfferingId, Boolean isSoruceNat, Long aclId, Boolean bypassVlanOverlapCheck) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
public PrivateGateway createVpcPrivateGateway(CreatePrivateGatewayCmd command) throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;

/**
* Applies VPC private gateway on the backend, so it becomes functional
Expand Down
1 change: 1 addition & 0 deletions api/src/main/java/com/cloud/offering/NetworkOffering.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum Detail {
public final static String SystemManagementNetwork = "System-Management-Network";
public final static String SystemStorageNetwork = "System-Storage-Network";
public final static String SystemPrivateGatewayNetworkOffering = "System-Private-Gateway-Network-Offering";
public final static String SystemPrivateGatewayNetworkOfferingWithoutVlan = "System-Private-Gateway-Network-Offering-Without-Vlan";

public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService";
public final static String QuickCloudNoServices = "QuickCloudNoServices";
Expand Down
3 changes: 3 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ public class ApiConstants {
public static final String ISOLATED_PVLAN = "isolatedpvlan";
public static final String ISOLATED_PVLAN_TYPE = "isolatedpvlantype";
public static final String ISOLATION_URI = "isolationuri";
public static final String IS_DEDICATED = "isdedicated";
public static final String TAKEN = "taken";
public static final String VM_AVAILABLE = "vmavailable";
public static final String VM_LIMIT = "vmlimit";
public static final String VM_TOTAL = "vmtotal";
Expand Down Expand Up @@ -523,6 +525,7 @@ public class ApiConstants {
public static final String ISOLATION_METHOD = "isolationmethod";
public static final String ISOLATION_METHODS = "isolationmethods";
public static final String PHYSICAL_NETWORK_ID = "physicalnetworkid";
public static final String PHYSICAL_NETWORK_NAME = "physicalnetworkname";
public static final String DEST_PHYSICAL_NETWORK_ID = "destinationphysicalnetworkid";
public static final String ENABLE = "enable";
public static final String ENABLED = "enabled";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Set;

import com.cloud.server.ResourceIcon;
import org.apache.cloudstack.api.response.GuestVlanResponse;
import org.apache.cloudstack.api.response.ResourceIconResponse;
import org.apache.cloudstack.api.response.RouterHealthCheckResultResponse;
import com.cloud.resource.RollingMaintenanceManager;
Expand Down Expand Up @@ -148,6 +149,7 @@
import com.cloud.host.Host;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.network.GuestVlan;
import com.cloud.network.GuestVlanRange;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Network.Service;
Expand Down Expand Up @@ -256,7 +258,7 @@ public interface ResponseGenerator {

IPAddressResponse createIPAddressResponse(ResponseView view, IpAddress ipAddress);

GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlan result);
GuestVlanRangeResponse createDedicatedGuestVlanRangeResponse(GuestVlanRange result);

GlobalLoadBalancerResponse createGlobalLoadBalancerResponse(GlobalLoadBalancerRule globalLoadBalancerRule);

Expand Down Expand Up @@ -491,4 +493,5 @@ List<TemplateResponse> createTemplateResponses(ResponseView view, VirtualMachine

ResourceIconResponse createResourceIconResponse(ResourceIcon resourceIcon);

GuestVlanResponse createGuestVlanResponse(GuestVlan vlan);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.GuestVlan;
import com.cloud.network.GuestVlanRange;
import com.cloud.user.Account;

@APICommand(name = "dedicateGuestVlanRange", description = "Dedicates a guest vlan range to an account", responseObject = GuestVlanRangeResponse.class,
Expand Down Expand Up @@ -106,7 +106,7 @@ public long getEntityOwnerId() {

@Override
public void execute() throws ResourceUnavailableException, ResourceAllocationException {
GuestVlan result = _networkService.dedicateGuestVlanRange(this);
GuestVlanRange result = _networkService.dedicateGuestVlanRange(this);
if (result != null) {
GuestVlanRangeResponse response = _responseGenerator.createDedicatedGuestVlanRangeResponse(result);
response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;

import com.cloud.network.GuestVlan;
import com.cloud.network.GuestVlanRange;
import com.cloud.user.Account;
import com.cloud.utils.Pair;

Expand Down Expand Up @@ -124,10 +124,10 @@ public long getEntityOwnerId() {

@Override
public void execute() {
Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
Pair<List<? extends GuestVlanRange>, Integer> vlans = _networkService.listDedicatedGuestVlanRanges(this);
ListResponse<GuestVlanRangeResponse> response = new ListResponse<GuestVlanRangeResponse>();
List<GuestVlanRangeResponse> guestVlanResponses = new ArrayList<GuestVlanRangeResponse>();
for (GuestVlan vlan : vlans.first()) {
for (GuestVlanRange vlan : vlans.first()) {
GuestVlanRangeResponse guestVlanResponse = _responseGenerator.createDedicatedGuestVlanRangeResponse(vlan);
guestVlanResponse.setObjectName("dedicatedguestvlanrange");
guestVlanResponses.add(guestVlanResponse);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// 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 org.apache.cloudstack.api.command.admin.network;

import java.util.ArrayList;
import java.util.List;

import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.GuestVlanResponse;
import org.apache.cloudstack.api.response.ListResponse;

import com.cloud.network.GuestVlan;
import com.cloud.utils.Pair;

@APICommand(name = "listGuestVlans", description = "Lists all guest vlans", responseObject = GuestVlanResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
since = "4.17.0",
authorized = {RoleType.Admin})
public class ListGuestVlansCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListGuestVlansCmd.class.getName());

private static final String s_name = "listguestvlansresponse";

/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////

@Parameter(name = ApiConstants.ID, type = CommandType.LONG, required = false, description = "list guest vlan by id")
private Long id;

@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = false, description = "list guest vlan by zone")
private Long zoneId;

@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, required = false, description = "list guest vlan by physical network")
private Long physicalNetworkId;

@Parameter(name = ApiConstants.VNET, type = CommandType.STRING, required = false, description = "list guest vlan by vnet")
private String vnet;

@Parameter(name = ApiConstants.ALLOCATED_ONLY, type = CommandType.BOOLEAN, required = false, description = "limits search results to allocated guest vlan. false by default.")
private Boolean allocatedOnly;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public Long getId() {
return id;
}

public Long getZoneId() {
return zoneId;
}

public Long getPhysicalNetworkId() {
return physicalNetworkId;
}

public String getVnet() {
return vnet;
}

public Boolean getAllocatedOnly() {
return allocatedOnly;
}

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

@Override
public String getCommandName() {
return s_name;
}

@Override
public void execute() {
Pair<List<? extends GuestVlan>, Integer> vlans = _networkService.listGuestVlans(this);
ListResponse<GuestVlanResponse> response = new ListResponse<GuestVlanResponse>();
List<GuestVlanResponse> guestVlanResponses = new ArrayList<GuestVlanResponse>();
for (GuestVlan vlan : vlans.first()) {
GuestVlanResponse guestVlanResponse = _responseGenerator.createGuestVlanResponse(vlan);
guestVlanResponse.setObjectName("guestvlan");
guestVlanResponses.add(guestVlanResponse);
}

response.setResponses(guestVlanResponses, vlans.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.apache.cloudstack.api.command.admin.network;

import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.admin.AdminCmd;
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
Expand All @@ -26,4 +28,16 @@

@APICommand(name = "listNetworks", description = "Lists all available networks.", responseObject = NetworkResponse.class, responseView = ResponseView.Full, entityType = {Network.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListNetworksCmdByAdmin extends ListNetworksCmd implements AdminCmd {}
public class ListNetworksCmdByAdmin extends ListNetworksCmd implements AdminCmd {

@Parameter(name= ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the network", since = "4.17.0")
private String vlan;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////

public String getVlan() {
return vlan;
}
}
Loading