Skip to content

Commit da94ae2

Browse files
committed
Merge remote-tracking branch 'apache/4.20'
2 parents ef6c0c4 + 52e7b41 commit da94ae2

File tree

114 files changed

+3996
-297
lines changed

Some content is hidden

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

114 files changed

+3996
-297
lines changed

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/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: 36 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";
@@ -381,6 +382,14 @@ public class ApiConstants {
381382
public static final String PATH = "path";
382383
public static final String PAYLOAD = "payload";
383384
public static final String PAYLOAD_URL = "payloadurl";
385+
public static final String PEERS = "peers";
386+
public static final String PEER_ID = "peerid";
387+
public static final String PEER_NAME = "peername";
388+
public static final String PEER_MSID = "peermsid";
389+
public static final String PEER_RUNID = "peerrunid";
390+
public static final String PEER_SERVICE_IP = "peerserviceip";
391+
public static final String PEER_SERVICE_PORT = "peerserviceport";
392+
public static final String PEER_STATE = "peerstate";
384393
public static final String POD_ID = "podid";
385394
public static final String POD_NAME = "podname";
386395
public static final String POD_IDS = "podids";
@@ -986,6 +995,7 @@ public class ApiConstants {
986995
public static final String ACL_NAME = "aclname";
987996
public static final String NUMBER = "number";
988997
public static final String IS_DYNAMICALLY_SCALABLE = "isdynamicallyscalable";
998+
public static final String ROUTED_MODE_ENABLED = "routedmodeenabled";
989999
public static final String ROUTING = "isrouting";
9901000
public static final String ROUTING_MODE = "routingmode";
9911001
public static final String MAX_CONNECTIONS = "maxconnections";
@@ -1238,4 +1248,30 @@ public enum VMDetails {
12381248
public enum DomainDetails {
12391249
all, resource, min;
12401250
}
1251+
1252+
public enum ApiKeyAccess {
1253+
DISABLED(false),
1254+
ENABLED(true),
1255+
INHERIT(null);
1256+
1257+
Boolean apiKeyAccess;
1258+
1259+
ApiKeyAccess(Boolean keyAccess) {
1260+
apiKeyAccess = keyAccess;
1261+
}
1262+
1263+
public Boolean toBoolean() {
1264+
return apiKeyAccess;
1265+
}
1266+
1267+
public static ApiKeyAccess fromBoolean(Boolean value) {
1268+
if (value == null) {
1269+
return INHERIT;
1270+
} else if (value) {
1271+
return ENABLED;
1272+
} else {
1273+
return DISABLED;
1274+
}
1275+
}
1276+
}
12411277
}

api/src/main/java/org/apache/cloudstack/api/command/admin/account/UpdateAccountCmd.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
import javax.inject.Inject;
2323

24+
import org.apache.cloudstack.acl.RoleType;
2425
import org.apache.cloudstack.api.ApiCommandResourceType;
26+
import org.apache.cloudstack.api.command.user.UserCmd;
2527
import org.apache.cloudstack.api.response.RoleResponse;
2628

2729
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
@@ -40,8 +42,8 @@
4042
import com.cloud.user.Account;
4143

4244
@APICommand(name = "updateAccount", description = "Updates account information for the authenticated user", responseObject = AccountResponse.class, entityType = {Account.class},
43-
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
44-
public class UpdateAccountCmd extends BaseCmd {
45+
responseView = ResponseView.Restricted, requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
46+
public class UpdateAccountCmd extends BaseCmd implements UserCmd {
4547

4648
/////////////////////////////////////////////////////
4749
//////////////// API parameters /////////////////////
@@ -70,6 +72,9 @@ public class UpdateAccountCmd extends BaseCmd {
7072
@Parameter(name = ApiConstants.ACCOUNT_DETAILS, type = CommandType.MAP, description = "Details for the account used to store specific parameters")
7173
private Map details;
7274

75+
@Parameter(name = ApiConstants.API_KEY_ACCESS, type = CommandType.STRING, description = "Determines if Api key access for this user is enabled, disabled or inherits the value from its parent, the domain level setting api.key.access", since = "4.20.1.0", authorized = {RoleType.Admin})
76+
private String apiKeyAccess;
77+
7378
@Inject
7479
RegionService _regionService;
7580

@@ -109,6 +114,10 @@ public Map getDetails() {
109114
return params;
110115
}
111116

117+
public String getApiKeyAccess() {
118+
return apiKeyAccess;
119+
}
120+
112121
/////////////////////////////////////////////////////
113122
/////////////// API Implementation///////////////////
114123
/////////////////////////////////////////////////////
@@ -131,7 +140,7 @@ public long getEntityOwnerId() {
131140
public void execute() {
132141
Account result = _regionService.updateAccount(this);
133142
if (result != null){
134-
AccountResponse response = _responseGenerator.createAccountResponse(ResponseView.Full, result);
143+
AccountResponse response = _responseGenerator.createAccountResponse(getResponseView(), result);
135144
response.setResponseName(getCommandName());
136145
setResponseObject(response);
137146
} else {

api/src/main/java/org/apache/cloudstack/api/command/admin/management/ListMgmtsCmd.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.cloudstack.api.Parameter;
2424
import org.apache.cloudstack.api.response.ListResponse;
2525
import org.apache.cloudstack.api.response.ManagementServerResponse;
26+
import org.apache.commons.lang3.BooleanUtils;
2627

2728
@APICommand(name = "listManagementServers", description = "Lists management servers.", responseObject = ManagementServerResponse.class,
2829
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
@@ -39,6 +40,11 @@ public class ListMgmtsCmd extends BaseListCmd {
3940
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = "the name of the management server")
4041
private String hostName;
4142

43+
@Parameter(name = ApiConstants.PEERS, type = CommandType.BOOLEAN,
44+
description = "Whether to return the management server peers or not. By default, the management server peers will not be returned.",
45+
since = "4.20.0.0")
46+
private Boolean peers;
47+
4248
/////////////////////////////////////////////////////
4349
/////////////////// Accessors ///////////////////////
4450
/////////////////////////////////////////////////////
@@ -51,6 +57,10 @@ public String getHostName() {
5157
return hostName;
5258
}
5359

60+
public Boolean getPeers() {
61+
return BooleanUtils.toBooleanDefaultIfNull(peers, false);
62+
}
63+
5464
/////////////////////////////////////////////////////
5565
/////////////// API Implementation///////////////////
5666
/////////////////////////////////////////////////////

0 commit comments

Comments
 (0)