Skip to content

Commit 41dbce9

Browse files
committed
Merge remote-tracking branch 'upstream/main' into bnr-object-limits
2 parents a3a21b2 + 27d2de1 commit 41dbce9

File tree

189 files changed

+7032
-623
lines changed

Some content is hidden

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

189 files changed

+7032
-623
lines changed

api/src/main/java/com/cloud/agent/api/to/PortForwardingRuleTO.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import com.cloud.network.rules.FirewallRule;
2020
import com.cloud.network.rules.PortForwardingRule;
2121
import com.cloud.utils.net.NetUtils;
22+
import org.apache.commons.lang3.StringUtils;
23+
24+
import java.util.List;
2225

2326
/**
2427
* PortForwardingRuleTO specifies one port forwarding rule.
@@ -29,6 +32,8 @@ public class PortForwardingRuleTO extends FirewallRuleTO {
2932
String dstIp;
3033
int[] dstPortRange;
3134

35+
List<String> sourceCidrList;
36+
3237
protected PortForwardingRuleTO() {
3338
super();
3439
}
@@ -37,6 +42,7 @@ public PortForwardingRuleTO(PortForwardingRule rule, String srcVlanTag, String s
3742
super(rule, srcVlanTag, srcIp);
3843
this.dstIp = rule.getDestinationIpAddress().addr();
3944
this.dstPortRange = new int[] {rule.getDestinationPortStart(), rule.getDestinationPortEnd()};
45+
this.sourceCidrList = rule.getSourceCidrList();
4046
}
4147

4248
public PortForwardingRuleTO(long id, String srcIp, int srcPortStart, int srcPortEnd, String dstIp, int dstPortStart, int dstPortEnd, String protocol,
@@ -58,4 +64,11 @@ public String getStringDstPortRange() {
5864
return NetUtils.portRangeToString(dstPortRange);
5965
}
6066

67+
public String getSourceCidrListAsString() {
68+
if (sourceCidrList != null) {
69+
return StringUtils.join(sourceCidrList, ",");
70+
}
71+
return null;
72+
}
73+
6174
}

api/src/main/java/com/cloud/bgp/BGPService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.network.vpc.Vpc;
2222
import com.cloud.utils.Pair;
2323
import org.apache.cloudstack.api.command.user.bgp.ListASNumbersCmd;
24+
import org.apache.cloudstack.network.BgpPeer;
2425

2526
import java.util.List;
2627

@@ -36,4 +37,8 @@ public interface BGPService {
3637
boolean applyBgpPeers(Network network, boolean continueOnError) throws ResourceUnavailableException;
3738

3839
boolean applyBgpPeers(Vpc vpc, boolean continueOnError) throws ResourceUnavailableException;
40+
41+
List<? extends BgpPeer> getBgpPeersForNetwork(Network network);
42+
43+
List<? extends BgpPeer> getBgpPeersForVpc(Vpc vpc);
3944
}

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ public class EventTypes {
292292

293293
//register for user API and secret keys
294294
public static final String EVENT_REGISTER_FOR_SECRET_API_KEY = "REGISTER.USER.KEY";
295+
public static final String API_KEY_ACCESS_UPDATE = "API.KEY.ACCESS.UPDATE";
295296

296297
// Template Events
297298
public static final String EVENT_TEMPLATE_CREATE = "TEMPLATE.CREATE";

api/src/main/java/com/cloud/hypervisor/Hypervisor.java

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,57 @@
2020
import org.apache.commons.lang3.StringUtils;
2121

2222
import java.util.LinkedHashMap;
23+
import java.util.List;
2324
import java.util.Locale;
2425
import java.util.Map;
2526
import java.util.Objects;
27+
import java.util.Set;
28+
import java.util.EnumSet;
29+
import java.util.stream.Collectors;
30+
31+
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.DirectDownloadTemplate;
32+
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.RootDiskSizeOverride;
33+
import static com.cloud.hypervisor.Hypervisor.HypervisorType.Functionality.VmStorageMigration;
2634

2735
public class Hypervisor {
2836
public static class HypervisorType {
37+
public enum Functionality {
38+
DirectDownloadTemplate,
39+
RootDiskSizeOverride,
40+
VmStorageMigration
41+
}
42+
2943
private static final Map<String, HypervisorType> hypervisorTypeMap = new LinkedHashMap<>();
3044
public static final HypervisorType None = new HypervisorType("None"); //for storage hosts
31-
public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD);
32-
public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2);
33-
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA);
45+
public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD, EnumSet.of(RootDiskSizeOverride, VmStorageMigration));
46+
public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2, EnumSet.of(DirectDownloadTemplate, RootDiskSizeOverride, VmStorageMigration));
47+
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA, EnumSet.of(RootDiskSizeOverride, VmStorageMigration));
3448
public static final HypervisorType Hyperv = new HypervisorType("Hyperv");
3549
public static final HypervisorType VirtualBox = new HypervisorType("VirtualBox");
3650
public static final HypervisorType Parralels = new HypervisorType("Parralels");
3751
public static final HypervisorType BareMetal = new HypervisorType("BareMetal");
38-
public static final HypervisorType Simulator = new HypervisorType("Simulator");
52+
public static final HypervisorType Simulator = new HypervisorType("Simulator", null, EnumSet.of(RootDiskSizeOverride, VmStorageMigration));
3953
public static final HypervisorType Ovm = new HypervisorType("Ovm", ImageFormat.RAW);
4054
public static final HypervisorType Ovm3 = new HypervisorType("Ovm3", ImageFormat.RAW);
4155
public static final HypervisorType LXC = new HypervisorType("LXC");
42-
public static final HypervisorType Custom = new HypervisorType("Custom");
56+
public static final HypervisorType Custom = new HypervisorType("Custom", null, EnumSet.of(RootDiskSizeOverride));
4357
public static final HypervisorType Any = new HypervisorType("Any"); /*If you don't care about the hypervisor type*/
4458
private final String name;
4559
private final ImageFormat imageFormat;
60+
private final Set<Functionality> supportedFunctionalities;
4661

4762
public HypervisorType(String name) {
48-
this(name, null);
63+
this(name, null, EnumSet.noneOf(Functionality.class));
4964
}
5065

5166
public HypervisorType(String name, ImageFormat imageFormat) {
67+
this(name, imageFormat, EnumSet.noneOf(Functionality.class));
68+
}
69+
70+
public HypervisorType(String name, ImageFormat imageFormat, Set<Functionality> supportedFunctionalities) {
5271
this.name = name;
5372
this.imageFormat = imageFormat;
73+
this.supportedFunctionalities = supportedFunctionalities;
5474
if (name.equals("Parralels")){ // typo in the original code
5575
hypervisorTypeMap.put("parallels", this);
5676
} else {
@@ -81,6 +101,12 @@ public static HypervisorType valueOf(String name) {
81101
return hypervisorType;
82102
}
83103

104+
public static List<HypervisorType> getListOfHypervisorsSupportingFunctionality(Functionality functionality) {
105+
return hypervisorTypeMap.values().stream()
106+
.filter(hypervisor -> hypervisor.supportedFunctionalities.contains(functionality))
107+
.collect(Collectors.toList());
108+
}
109+
84110
/**
85111
* Returns the display name of a hypervisor type in case the custom hypervisor is used,
86112
* using the 'hypervisor.custom.display.name' setting. Otherwise, returns hypervisor name
@@ -102,6 +128,15 @@ public String name() {
102128
return name;
103129
}
104130

131+
/**
132+
* Make this method to be part of the properties of the hypervisor type itself.
133+
*
134+
* @return true if the hypervisor plugin support the specified functionality
135+
*/
136+
public boolean isFunctionalitySupported(Functionality functionality) {
137+
return supportedFunctionalities.contains(functionality);
138+
}
139+
105140
@Override
106141
public int hashCode() {
107142
return Objects.hash(name);

api/src/main/java/com/cloud/network/rules/RulesService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.cloud.user.Account;
2727
import com.cloud.utils.Pair;
2828
import com.cloud.utils.net.Ip;
29+
import org.apache.cloudstack.api.command.user.firewall.UpdatePortForwardingRuleCmd;
2930

3031
public interface RulesService {
3132
Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId,
@@ -81,6 +82,8 @@ Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long
8182

8283
boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException;
8384

84-
PortForwardingRule updatePortForwardingRule(long id, Integer privatePort, Integer privateEndPort, Long virtualMachineId, Ip vmGuestIp, String customId, Boolean forDisplay);
85+
PortForwardingRule updatePortForwardingRule(UpdatePortForwardingRuleCmd cmd);
86+
87+
void validatePortForwardingSourceCidrList(List<String> sourceCidrList);
8588

8689
}

api/src/main/java/com/cloud/server/ManagementServerHostStats.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public interface ManagementServerHostStats {
3232

3333
String getManagementServerHostUuid();
3434

35+
long getManagementServerRunId();
36+
3537
long getSessions();
3638

3739
double getCpuUtilization();

api/src/main/java/com/cloud/user/Account.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ public static Type getFromValue(Integer type){
9393

9494
boolean isDefault();
9595

96+
public void setApiKeyAccess(Boolean apiKeyAccess);
97+
98+
public Boolean getApiKeyAccess();
99+
96100
}

api/src/main/java/com/cloud/user/AccountService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.cloud.utils.Pair;
2223
import org.apache.cloudstack.acl.ControlledEntity;
2324
import org.apache.cloudstack.acl.RoleType;
2425
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -127,9 +128,9 @@ User createUser(String userName, String password, String firstName, String lastN
127128
*/
128129
UserAccount getUserAccountById(Long userId);
129130

130-
public Map<String, String> getKeys(GetUserKeysCmd cmd);
131+
public Pair<Boolean, Map<String, String>> getKeys(GetUserKeysCmd cmd);
131132

132-
public Map<String, String> getKeys(Long userId);
133+
public Pair<Boolean, Map<String, String>> getKeys(Long userId);
133134

134135
/**
135136
* Lists user two-factor authentication provider plugins

api/src/main/java/com/cloud/user/User.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,9 @@ public enum Source {
9494
public boolean isUser2faEnabled();
9595

9696
public String getKeyFor2fa();
97+
98+
public void setApiKeyAccess(Boolean apiKeyAccess);
99+
100+
public Boolean getApiKeyAccess();
101+
97102
}

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public class ApiConstants {
3535
public static final String ALLOW_USER_FORCE_STOP_VM = "allowuserforcestopvm";
3636
public static final String ANNOTATION = "annotation";
3737
public static final String API_KEY = "apikey";
38+
public static final String API_KEY_ACCESS = "apikeyaccess";
3839
public static final String ARCHIVED = "archived";
3940
public static final String ARCH = "arch";
4041
public static final String AS_NUMBER = "asnumber";
@@ -249,6 +250,7 @@ public class ApiConstants {
249250
public static final String ICMP_TYPE = "icmptype";
250251
public static final String ID = "id";
251252
public static final String IDS = "ids";
253+
public static final String IMPORT_INSTANCE_HOST_ID = "importinstancehostid";
252254
public static final String INDEX = "index";
253255
public static final String INSTANCES_DISKS_STATS_RETENTION_ENABLED = "instancesdisksstatsretentionenabled";
254256
public static final String INSTANCES_DISKS_STATS_RETENTION_TIME = "instancesdisksstatsretentiontime";
@@ -388,6 +390,14 @@ public class ApiConstants {
388390
public static final String PATH = "path";
389391
public static final String PAYLOAD = "payload";
390392
public static final String PAYLOAD_URL = "payloadurl";
393+
public static final String PEERS = "peers";
394+
public static final String PEER_ID = "peerid";
395+
public static final String PEER_NAME = "peername";
396+
public static final String PEER_MSID = "peermsid";
397+
public static final String PEER_RUNID = "peerrunid";
398+
public static final String PEER_SERVICE_IP = "peerserviceip";
399+
public static final String PEER_SERVICE_PORT = "peerserviceport";
400+
public static final String PEER_STATE = "peerstate";
391401
public static final String POD_ID = "podid";
392402
public static final String POD_NAME = "podname";
393403
public static final String POD_IDS = "podids";
@@ -463,6 +473,7 @@ public class ApiConstants {
463473
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
464474
public static final String SNAPSHOT_TYPE = "snapshottype";
465475
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
476+
public static final String SOURCE_CIDR_LIST = "sourcecidrlist";
466477
public static final String SOURCE_ZONE_ID = "sourcezoneid";
467478
public static final String SSL_VERIFICATION = "sslverification";
468479
public static final String START_ASN = "startasn";
@@ -994,6 +1005,7 @@ public class ApiConstants {
9941005
public static final String ACL_NAME = "aclname";
9951006
public static final String NUMBER = "number";
9961007
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
1008+
public static final String ROUTED_MODE_ENABLED = "routedmodeenabled";
9971009
public static final String ROUTING = "isrouting";
9981010
public static final String ROUTING_MODE = "routingmode";
9991011
public static final String MAX_CONNECTIONS = "maxconnections";
@@ -1254,4 +1266,30 @@ public enum VMDetails {
12541266
public enum DomainDetails {
12551267
all, resource, min;
12561268
}
1269+
1270+
public enum ApiKeyAccess {
1271+
DISABLED(false),
1272+
ENABLED(true),
1273+
INHERIT(null);
1274+
1275+
Boolean apiKeyAccess;
1276+
1277+
ApiKeyAccess(Boolean keyAccess) {
1278+
apiKeyAccess = keyAccess;
1279+
}
1280+
1281+
public Boolean toBoolean() {
1282+
return apiKeyAccess;
1283+
}
1284+
1285+
public static ApiKeyAccess fromBoolean(Boolean value) {
1286+
if (value == null) {
1287+
return INHERIT;
1288+
} else if (value) {
1289+
return ENABLED;
1290+
} else {
1291+
return DISABLED;
1292+
}
1293+
}
1294+
}
12571295
}

0 commit comments

Comments
 (0)