Skip to content

Commit 6bb6fe7

Browse files
committed
Merge branch '4.19' into 4.20
2 parents d5fbd07 + a0080a0 commit 6bb6fe7

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,33 @@
216216
public class KubernetesClusterManagerImpl extends ManagerBase implements KubernetesClusterService {
217217

218218
private static final String DEFAULT_NETWORK_OFFERING_FOR_KUBERNETES_SERVICE_NAME = "DefaultNetworkOfferingforKubernetesService";
219+
private static final List<Class<?>> PROJECT_KUBERNETES_ACCOUNT_ROLE_ALLOWED_APIS = Arrays.asList(
220+
QueryAsyncJobResultCmd.class,
221+
ListVMsCmd.class,
222+
ListNetworksCmd.class,
223+
ListPublicIpAddressesCmd.class,
224+
AssociateIPAddrCmd.class,
225+
DisassociateIPAddrCmd.class,
226+
ListLoadBalancerRulesCmd.class,
227+
CreateLoadBalancerRuleCmd.class,
228+
UpdateLoadBalancerRuleCmd.class,
229+
DeleteLoadBalancerRuleCmd.class,
230+
AssignToLoadBalancerRuleCmd.class,
231+
RemoveFromLoadBalancerRuleCmd.class,
232+
ListLoadBalancerRuleInstancesCmd.class,
233+
ListFirewallRulesCmd.class,
234+
CreateFirewallRuleCmd.class,
235+
UpdateFirewallRuleCmd.class,
236+
DeleteFirewallRuleCmd.class,
237+
ListNetworkACLsCmd.class,
238+
CreateNetworkACLCmd.class,
239+
DeleteNetworkACLCmd.class,
240+
ListKubernetesClustersCmd.class,
241+
ScaleKubernetesClusterCmd.class
242+
);
243+
private static final String PROJECT_KUBERNETES_ACCOUNT_FIRST_NAME = "Kubernetes";
244+
private static final String PROJECT_KUBERNETES_ACCOUNT_LAST_NAME = "Service User";
245+
219246

220247
private static final String DEFAULT_NETWORK_OFFERING_FOR_KUBERNETES_SERVICE_DISPLAY_TEXT = "Network Offering used for CloudStack Kubernetes service";
221248
private static final String DEFAULT_NSX_NETWORK_OFFERING_FOR_KUBERNETES_SERVICE_NAME = "DefaultNSXNetworkOfferingforKubernetesService";

server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,33 @@ protected boolean shouldValidateConfigRange(String name, String value, Config co
15121512
return true;
15131513
}
15141514

1515+
protected void validateConfigurationAllowedOnlyForDefaultAdmin(String configName, String value) {
1516+
if (configKeysAllowedOnlyForDefaultAdmin.contains(configName)) {
1517+
final Long userId = CallContext.current().getCallingUserId();
1518+
if (userId != User.UID_ADMIN) {
1519+
throw new CloudRuntimeException("Only default admin is allowed to change this setting");
1520+
}
1521+
1522+
if (AccountManagerImpl.listOfRoleTypesAllowedForOperationsOfSameRoleType.key().equals(configName)) {
1523+
if (value != null && !value.isBlank()) {
1524+
List<String> validRoleTypes = Arrays.stream(RoleType.values())
1525+
.map(Enum::name)
1526+
.collect(Collectors.toList());
1527+
1528+
boolean allValid = Arrays.stream(value.split(","))
1529+
.map(String::trim)
1530+
.allMatch(validRoleTypes::contains);
1531+
1532+
if (!allValid) {
1533+
throw new CloudRuntimeException("Invalid role types provided in value");
1534+
}
1535+
} else {
1536+
throw new CloudRuntimeException("Value for role types must not be empty");
1537+
}
1538+
}
1539+
}
1540+
}
1541+
15151542
/**
15161543
* A valid value should be an integer between min and max (the values from the range).
15171544
*/

0 commit comments

Comments
 (0)