Skip to content

Commit 90c0ba7

Browse files
committed
resolve conflict with main
1 parent a9afbce commit 90c0ba7

File tree

147 files changed

+7014
-1004
lines changed

Some content is hidden

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

147 files changed

+7014
-1004
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ public class EventTypes {
301301
public static final String EVENT_REGISTER_CNI_CONFIG = "REGISTER.CNI.CONFIG";
302302
public static final String EVENT_DELETE_CNI_CONFIG = "DELETE.CNI.CONFIG";
303303

304-
//register for user API and secret keys
304+
//user API and secret keys
305305
public static final String EVENT_REGISTER_FOR_SECRET_API_KEY = "REGISTER.USER.KEY";
306+
public static final String EVENT_DELETE_SECRET_API_KEY = "DELETE.USER.KEY";
306307
public static final String API_KEY_ACCESS_UPDATE = "API.KEY.ACCESS.UPDATE";
307308

308309
// Template Events

api/src/main/java/com/cloud/kubernetes/cluster/KubernetesCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ enum State {
9898
s_fsm.addTransition(State.Running, Event.ScaleDownRequested, State.Scaling);
9999
s_fsm.addTransition(State.Stopped, Event.ScaleUpRequested, State.ScalingStoppedCluster);
100100
s_fsm.addTransition(State.Scaling, Event.OperationSucceeded, State.Running);
101-
s_fsm.addTransition(State.Scaling, Event.OperationFailed, State.Alert);
101+
s_fsm.addTransition(State.Scaling, Event.OperationFailed, State.Running);
102102
s_fsm.addTransition(State.ScalingStoppedCluster, Event.OperationSucceeded, State.Stopped);
103103
s_fsm.addTransition(State.ScalingStoppedCluster, Event.OperationFailed, State.Alert);
104104

api/src/main/java/com/cloud/kubernetes/cluster/KubernetesServiceHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import org.apache.cloudstack.acl.ControlledEntity;
2020

21+
import java.util.List;
2122
import java.util.Map;
2223

2324
import com.cloud.user.Account;
@@ -33,8 +34,10 @@ enum KubernetesClusterNodeType {
3334
ControlledEntity findByUuid(String uuid);
3435
ControlledEntity findByVmId(long vmId);
3536
void checkVmCanBeDestroyed(UserVm userVm);
37+
void checkVmAffinityGroupsCanBeUpdated(UserVm userVm);
3638
boolean isValidNodeType(String nodeType);
3739
Map<String, Long> getServiceOfferingNodeTypeMap(Map<String, Map<String, String>> serviceOfferingNodeTypeMap);
3840
Map<String, Long> getTemplateNodeTypeMap(Map<String, Map<String, String>> templateNodeTypeMap);
41+
Map<String, List<Long>> getAffinityGroupNodeTypeMap(Map<String, Map<String, String>> affinityGroupNodeTypeMap);
3942
void cleanupForAccount(Account account);
4043
}

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

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import com.cloud.utils.Pair;
2223
import org.apache.cloudstack.acl.ControlledEntity;
24+
import org.apache.cloudstack.acl.RolePermissionEntity;
2325
import org.apache.cloudstack.acl.RoleType;
2426
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
27+
import org.apache.cloudstack.acl.apikeypair.ApiKeyPair;
28+
import org.apache.cloudstack.acl.apikeypair.ApiKeyPairPermission;
29+
import org.apache.cloudstack.api.BaseCmd;
2530
import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd;
26-
import org.apache.cloudstack.api.command.admin.user.GetUserKeysCmd;
27-
import org.apache.cloudstack.api.command.admin.user.RegisterUserKeyCmd;
28-
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
29-
import org.apache.cloudstack.auth.UserTwoFactorAuthenticator;
30-
import org.apache.cloudstack.backup.BackupOffering;
31-
import org.apache.cloudstack.dns.DnsServer;
3231

3332
import com.cloud.dc.DataCenter;
3433
import com.cloud.domain.Domain;
@@ -37,7 +36,17 @@
3736
import com.cloud.offering.DiskOffering;
3837
import com.cloud.offering.NetworkOffering;
3938
import com.cloud.offering.ServiceOffering;
40-
import com.cloud.utils.Pair;
39+
import org.apache.cloudstack.api.command.admin.user.DeleteUserKeysCmd;
40+
import org.apache.cloudstack.api.command.admin.user.GetUserKeysCmd;
41+
import org.apache.cloudstack.api.command.admin.user.ListUserKeyRulesCmd;
42+
import org.apache.cloudstack.api.command.admin.user.ListUserKeysCmd;
43+
import org.apache.cloudstack.api.command.admin.user.RegisterUserKeysCmd;
44+
import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
45+
import org.apache.cloudstack.api.response.ApiKeyPairResponse;
46+
import org.apache.cloudstack.api.response.ListResponse;
47+
import org.apache.cloudstack.auth.UserTwoFactorAuthenticator;
48+
import org.apache.cloudstack.backup.BackupOffering;
49+
import org.apache.cloudstack.dns.DnsServer;
4150

4251
public interface AccountService {
4352

@@ -98,7 +107,7 @@ User createUser(String userName, String password, String firstName, String lastN
98107

99108
void markUserRegistered(long userId);
100109

101-
public String[] createApiKeyAndSecretKey(RegisterUserKeyCmd cmd);
110+
ApiKeyPair createApiKeyAndSecretKey(RegisterUserKeysCmd cmd);
102111

103112
public String[] createApiKeyAndSecretKey(final long userId);
104113

@@ -128,6 +137,8 @@ User createUser(String userName, String password, String firstName, String lastN
128137

129138
void validateAccountHasAccessToResource(Account account, AccessType accessType, Object resource);
130139

140+
void validateCallingUserHasAccessToDesiredUser(Long userId);
141+
131142
Long finalizeAccountId(String accountName, Long domainId, Long projectId, boolean enabledOnly);
132143

133144
/**
@@ -137,9 +148,15 @@ User createUser(String userName, String password, String firstName, String lastN
137148
*/
138149
UserAccount getUserAccountById(Long userId);
139150

140-
public Pair<Boolean, Map<String, String>> getKeys(GetUserKeysCmd cmd);
151+
Pair<Boolean, Map<String, String>> getKeys(GetUserKeysCmd cmd);
152+
153+
ListResponse<ApiKeyPairResponse> listKeys(ListUserKeysCmd cmd);
154+
155+
List<ApiKeyPairPermission> listKeyRules(ListUserKeyRulesCmd cmd);
141156

142-
public Pair<Boolean, Map<String, String>> getKeys(Long userId);
157+
void deleteApiKey(DeleteUserKeysCmd cmd);
158+
159+
void deleteApiKey(ApiKeyPair id);
143160

144161
/**
145162
* Lists user two-factor authentication provider plugins
@@ -154,4 +171,13 @@ User createUser(String userName, String password, String firstName, String lastN
154171
*/
155172
UserTwoFactorAuthenticator getUserTwoFactorAuthenticationProvider(final Long domainId);
156173

174+
ApiKeyPair getLatestUserKeyPair(Long userId);
175+
176+
ApiKeyPair getKeyPairById(Long id);
177+
178+
ApiKeyPair getKeyPairByApiKey(String apiKey);
179+
180+
String getAccessingApiKey(BaseCmd cmd);
181+
182+
List<RolePermissionEntity> getAllKeypairPermissions(String apiKey);
157183
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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.user;
18+
19+
public enum ApiKeyPairState {
20+
ENABLED, REMOVED, EXPIRED
21+
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ public enum Source {
6565

6666
public void setState(Account.State state);
6767

68-
public String getApiKey();
69-
70-
public void setApiKey(String apiKey);
71-
72-
public String getSecretKey();
73-
74-
public void setSecretKey(String secretKey);
75-
7668
public String getTimezone();
7769

7870
public void setTimezone(String timezone);

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,6 @@ public interface UserAccount extends InternalIdentity {
3939

4040
String getState();
4141

42-
String getApiKey();
43-
44-
String getSecretKey();
45-
4642
Date getCreated();
4743

4844
Date getRemoved();

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public interface VmDetailConstants {
9696
String CKS_NODE_TYPE = "node";
9797
String OFFERING = "offering";
9898
String TEMPLATE = "template";
99+
String AFFINITY_GROUP = "affinitygroup";
99100

100101
// VMware to KVM VM migrations specific
101102
String VMWARE_TO_KVM_PREFIX = "vmware-to-kvm";

api/src/main/java/org/apache/cloudstack/acl/APIChecker.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.cloud.user.Account;
2121
import com.cloud.user.User;
2222
import com.cloud.utils.component.Adapter;
23+
import org.apache.cloudstack.acl.apikeypair.ApiKeyPairPermission;
2324

2425
import java.util.List;
2526

@@ -31,8 +32,8 @@ public interface APIChecker extends Adapter {
3132
// If true, apiChecker has checked the operation
3233
// If false, apiChecker is unable to handle the operation or not implemented
3334
// On exception, checkAccess failed don't allow
34-
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException;
35-
boolean checkAccess(Account account, String apiCommandName) throws PermissionDeniedException;
35+
boolean checkAccess(User user, String apiCommandName, ApiKeyPairPermission... apiKeyPairPermissions) throws PermissionDeniedException;
36+
boolean checkAccess(Account account, String apiCommandName, ApiKeyPairPermission... apiKeyPairPermissions) throws PermissionDeniedException;
3637
/**
3738
* Verifies if the account has permission for the given list of APIs and returns only the allowed ones.
3839
*
@@ -43,4 +44,5 @@ public interface APIChecker extends Adapter {
4344
*/
4445
List<String> getApisAllowedToUser(Role role, User user, List<String> apiNames) throws PermissionDeniedException;
4546
boolean isEnabled();
47+
List<RolePermissionEntity> getImplicitRolePermissions(RoleType roleType);
4648
}

api/src/main/java/org/apache/cloudstack/acl/RolePermissionEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.apache.cloudstack.api.InternalIdentity;
2222

2323
public interface RolePermissionEntity extends InternalIdentity, Identity {
24-
public enum Permission {
24+
enum Permission {
2525
ALLOW, DENY
2626
}
2727
Rule getRule();

0 commit comments

Comments
 (0)