Skip to content

Commit 18effeb

Browse files
committed
wip: initial skeleton
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent f07b7d8 commit 18effeb

48 files changed

Lines changed: 3499 additions & 11 deletions

File tree

Some content is hidden

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

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ public class EventTypes {
176176
public static final String EVENT_NET_RULE_ADD = "NET.RULEADD";
177177
public static final String EVENT_NET_RULE_DELETE = "NET.RULEDELETE";
178178
public static final String EVENT_NET_RULE_MODIFY = "NET.RULEMODIFY";
179+
public static final String EVENT_INSTANCE_BOOT_GROUP_CREATE = "INSTANCE.BOOT.GROUP.CREATE";
180+
public static final String EVENT_INSTANCE_BOOT_GROUP_DELETE = "INSTANCE.BOOT.GROUP.DELETE";
181+
public static final String EVENT_INSTANCE_BOOT_GROUP_UPDATE = "INSTANCE.BOOT.GROUP.UPDATE";
182+
public static final String EVENT_INSTANCE_BOOT_GROUP_START = "INSTANCE.BOOT.GROUP.START";
183+
public static final String EVENT_INSTANCE_BOOT_GROUP_STOP = "INSTANCE.BOOT.GROUP.STOP";
184+
public static final String EVENT_INSTANCE_BOOT_GROUP_REBOOT = "INSTANCE.BOOT.GROUP.REBOOT";
185+
public static final String EVENT_INSTANCE_BOOT_GROUP_MEMBER_ADD = "INSTANCE.BOOT.GROUP.MEMBER.ADD";
186+
public static final String EVENT_INSTANCE_BOOT_GROUP_MEMBER_REMOVE = "INSTANCE.BOOT.GROUP.MEMBER.REMOVE";
187+
public static final String EVENT_INSTANCE_BOOT_GROUP_MEMBER_REORDER = "INSTANCE.BOOT.GROUP.MEMBER.REODER";
188+
179189
public static final String EVENT_NETWORK_CREATE = "NETWORK.CREATE";
180190
public static final String EVENT_NETWORK_DELETE = "NETWORK.DELETE";
181191
public static final String EVENT_NETWORK_UPDATE = "NETWORK.UPDATE";

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ public enum ApiCommandResourceType {
9191
Extension(org.apache.cloudstack.extension.Extension.class),
9292
ExtensionCustomAction(org.apache.cloudstack.extension.ExtensionCustomAction.class),
9393
KmsKey(org.apache.cloudstack.kms.KMSKey.class),
94-
HsmProfile(org.apache.cloudstack.kms.HSMProfile.class);
94+
HsmProfile(org.apache.cloudstack.kms.HSMProfile.class),
95+
InstanceBootGroup(org.apache.cloudstack.vm.bootgroup.InstanceBootGroup.class);
9596

9697
private final Class<?> clazz;
9798

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public class ApiConstants {
9292
public static final String CAPACITY = "capacity";
9393
public static final String CATEGORY = "category";
9494
public static final String CAN_REVERT = "canrevert";
95+
public static final String BOOT_GROUP_ID = "bootgroupid";
96+
public static final String BOOT_ORDER = "order";
97+
public static final String MEMBER_TYPE = "membertype";
98+
public static final String MEMBER_ID = "memberid";
99+
public static final String MEMBER_NAME = "membername";
100+
public static final String MEMBER_STATE = "memberstate";
95101
public static final String CA_CERTIFICATES = "cacertificates";
96102
public static final String CERTIFICATE = "certificate";
97103
public static final String CERTIFICATE_CHAIN = "certchain";
@@ -320,6 +326,7 @@ public class ApiConstants {
320326
public static final String INTERNAL_DNS2 = "internaldns2";
321327
public static final String INTERNET_PROTOCOL = "internetprotocol";
322328
public static final String INTERVAL_TYPE = "intervaltype";
329+
public static final String INSTANCE_GROUP_ID = "instancegroupid";
323330
public static final String INSTANCE_LEASE_DURATION = "leaseduration";
324331
public static final String INSTANCE_LEASE_ENABLED = "instanceleaseenabled";
325332
public static final String INSTANCE_LEASE_EXPIRY_ACTION = "leaseexpiryaction";
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
18+
package org.apache.cloudstack.api.command.user.bootgroup;
19+
20+
import javax.inject.Inject;
21+
22+
import org.apache.cloudstack.acl.RoleType;
23+
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.ApiErrorCode;
27+
import org.apache.cloudstack.api.BaseCmd;
28+
import org.apache.cloudstack.api.Parameter;
29+
import org.apache.cloudstack.api.ServerApiException;
30+
import org.apache.cloudstack.api.command.user.UserCmd;
31+
import org.apache.cloudstack.api.response.InstanceBootGroupMemberResponse;
32+
import org.apache.cloudstack.api.response.InstanceBootGroupResponse;
33+
import org.apache.cloudstack.api.response.InstanceGroupResponse;
34+
import org.apache.cloudstack.api.response.UserVmResponse;
35+
import org.apache.cloudstack.context.CallContext;
36+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupMember;
37+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupService;
38+
39+
@APICommand(name = "addMemberToInstanceBootGroup",
40+
description = "Adds a VM or instance group to an instance boot group. Exactly one of virtualmachineid or instancegroupid must be specified.",
41+
responseObject = InstanceBootGroupMemberResponse.class,
42+
entityType = {InstanceBootGroupMember.class},
43+
requestHasSensitiveInfo = false,
44+
responseHasSensitiveInfo = false,
45+
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
46+
public class AddMemberToInstanceBootGroupCmd extends BaseCmd implements UserCmd {
47+
48+
@Inject
49+
InstanceBootGroupService instanceBootGroupService;
50+
51+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = InstanceBootGroupResponse.class, required = true, description = "The ID of the instance boot group")
52+
private Long id;
53+
54+
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID, entityType = UserVmResponse.class, description = "The ID of the VM to add (exclusive with instancegroupid)")
55+
private Long virtualMachineId;
56+
57+
@Parameter(name = ApiConstants.INSTANCE_GROUP_ID, type = CommandType.UUID, entityType = InstanceGroupResponse.class, description = "The ID of the instance group to add (exclusive with virtualmachineid)")
58+
private Long instanceGroupId;
59+
60+
@Parameter(name = ApiConstants.BOOT_ORDER, type = CommandType.INTEGER, required = true, description = "The boot order value for this member (0 or greater; non-contiguous values are allowed)")
61+
private int order;
62+
63+
public Long getId() {
64+
return id;
65+
}
66+
67+
public Long getVirtualMachineId() {
68+
return virtualMachineId;
69+
}
70+
71+
public Long getInstanceGroupId() {
72+
return instanceGroupId;
73+
}
74+
75+
public int getOrder() {
76+
return order;
77+
}
78+
79+
@Override
80+
public long getEntityOwnerId() {
81+
return CallContext.current().getCallingAccount().getId();
82+
}
83+
84+
@Override
85+
public Long getApiResourceId() {
86+
return id;
87+
}
88+
89+
@Override
90+
public ApiCommandResourceType getApiResourceType() {
91+
return ApiCommandResourceType.InstanceBootGroup;
92+
}
93+
94+
@Override
95+
public void execute() {
96+
InstanceBootGroupMember result = instanceBootGroupService.addMemberToInstanceBootGroup(this);
97+
if (result == null) {
98+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add member to instance boot group");
99+
}
100+
InstanceBootGroupMemberResponse response = instanceBootGroupService.createInstanceBootGroupMemberResponse(result);
101+
response.setResponseName(getCommandName());
102+
setResponseObject(response);
103+
}
104+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
18+
package org.apache.cloudstack.api.command.user.bootgroup;
19+
20+
import javax.inject.Inject;
21+
22+
import org.apache.cloudstack.acl.RoleType;
23+
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.ApiErrorCode;
27+
import org.apache.cloudstack.api.BaseCmd;
28+
import org.apache.cloudstack.api.Parameter;
29+
import org.apache.cloudstack.api.ServerApiException;
30+
import org.apache.cloudstack.api.command.user.UserCmd;
31+
import org.apache.cloudstack.api.response.DomainResponse;
32+
import org.apache.cloudstack.api.response.InstanceBootGroupResponse;
33+
import org.apache.cloudstack.api.response.ProjectResponse;
34+
import org.apache.cloudstack.context.CallContext;
35+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroup;
36+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupService;
37+
38+
@APICommand(name = "createInstanceBootGroup",
39+
description = "Creates an instance boot group",
40+
responseObject = InstanceBootGroupResponse.class,
41+
entityType = {InstanceBootGroup.class},
42+
requestHasSensitiveInfo = false,
43+
responseHasSensitiveInfo = false,
44+
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
45+
public class CreateInstanceBootGroupCmd extends BaseCmd implements UserCmd {
46+
47+
@Inject
48+
InstanceBootGroupService instanceBootGroupService;
49+
50+
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "The name of the instance boot group")
51+
private String name;
52+
53+
@Parameter(name = ApiConstants.DESCRIPTION, type = CommandType.STRING, description = "The description of the instance boot group")
54+
private String description;
55+
56+
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "The account of the instance boot group. Must be used with domainId.")
57+
private String accountName;
58+
59+
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "The domain ID of the account owning the instance boot group")
60+
private Long domainId;
61+
62+
@Parameter(name = ApiConstants.PROJECT_ID, type = CommandType.UUID, entityType = ProjectResponse.class, description = "The project of the instance boot group")
63+
private Long projectId;
64+
65+
public String getName() {
66+
return name;
67+
}
68+
69+
public String getDescription() {
70+
return description;
71+
}
72+
73+
public String getAccountName() {
74+
return accountName;
75+
}
76+
77+
public Long getDomainId() {
78+
return domainId;
79+
}
80+
81+
public Long getProjectId() {
82+
return projectId;
83+
}
84+
85+
@Override
86+
public long getEntityOwnerId() {
87+
Long accountId = _accountService.finalizeAccountId(accountName, domainId, projectId, true);
88+
if (accountId == null) {
89+
return CallContext.current().getCallingAccount().getId();
90+
}
91+
return accountId;
92+
}
93+
94+
@Override
95+
public ApiCommandResourceType getApiResourceType() {
96+
return ApiCommandResourceType.InstanceBootGroup;
97+
}
98+
99+
@Override
100+
public void execute() {
101+
InstanceBootGroup result = instanceBootGroupService.createInstanceBootGroup(this);
102+
if (result == null) {
103+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create instance boot group");
104+
}
105+
InstanceBootGroupResponse response = instanceBootGroupService.createInstanceBootGroupResponse(result.getId());
106+
response.setResponseName(getCommandName());
107+
setResponseObject(response);
108+
}
109+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
18+
package org.apache.cloudstack.api.command.user.bootgroup;
19+
20+
import javax.inject.Inject;
21+
22+
import org.apache.cloudstack.acl.RoleType;
23+
import org.apache.cloudstack.api.APICommand;
24+
import org.apache.cloudstack.api.ApiCommandResourceType;
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.ApiErrorCode;
27+
import org.apache.cloudstack.api.BaseCmd;
28+
import org.apache.cloudstack.api.Parameter;
29+
import org.apache.cloudstack.api.ServerApiException;
30+
import org.apache.cloudstack.api.command.user.UserCmd;
31+
import org.apache.cloudstack.api.response.InstanceBootGroupResponse;
32+
import org.apache.cloudstack.api.response.SuccessResponse;
33+
import org.apache.cloudstack.context.CallContext;
34+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroup;
35+
import org.apache.cloudstack.vm.bootgroup.InstanceBootGroupService;
36+
37+
@APICommand(name = "deleteInstanceBootGroup",
38+
description = "Deletes an instance boot group",
39+
responseObject = SuccessResponse.class,
40+
entityType = {InstanceBootGroup.class},
41+
requestHasSensitiveInfo = false,
42+
responseHasSensitiveInfo = false,
43+
authorized = {RoleType.Admin, RoleType.ResourceAdmin, RoleType.DomainAdmin, RoleType.User})
44+
public class DeleteInstanceBootGroupCmd extends BaseCmd implements UserCmd {
45+
46+
@Inject
47+
InstanceBootGroupService instanceBootGroupService;
48+
49+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = InstanceBootGroupResponse.class, required = true, description = "The ID of the instance boot group")
50+
private Long id;
51+
52+
public Long getId() {
53+
return id;
54+
}
55+
56+
@Override
57+
public long getEntityOwnerId() {
58+
return CallContext.current().getCallingAccount().getId();
59+
}
60+
61+
@Override
62+
public Long getApiResourceId() {
63+
return id;
64+
}
65+
66+
@Override
67+
public ApiCommandResourceType getApiResourceType() {
68+
return ApiCommandResourceType.InstanceBootGroup;
69+
}
70+
71+
@Override
72+
public void execute() {
73+
boolean result = instanceBootGroupService.deleteInstanceBootGroup(this);
74+
if (!result) {
75+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete instance boot group");
76+
}
77+
SuccessResponse response = new SuccessResponse(getCommandName());
78+
setResponseObject(response);
79+
}
80+
}

0 commit comments

Comments
 (0)