Skip to content

Commit 72f2a8a

Browse files
authored
Merge pull request #638 from jeongda-young/hostDeviceFilter
[Mold] 호스트 디바이스 할당/해제 기능 추가 및 기능개선
2 parents dad60ad + 23aff2e commit 72f2a8a

32 files changed

Lines changed: 3140 additions & 173 deletions

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
import org.apache.cloudstack.api.command.admin.guest.UpdateGuestOsMappingCmd;
3636
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
3737
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
38+
import org.apache.cloudstack.api.command.admin.outofbandmanagement.LicenseCheckCmd;
3839
import org.apache.cloudstack.api.command.admin.outofbandmanagement.ListHostDevicesCmd;
40+
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.ListHostLunDevicesCmd;
41+
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.ListHostUsbDevicesCmd;
42+
import org.apache.cloudstack.api.command.admin.outofbandmanagement.UpdateHostDevicesCmd;
43+
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.UpdateHostLunDevicesCmd;
44+
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.UpdateHostUsbDevicesCmd;
3945
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
4046
import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
4147
import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
@@ -66,10 +72,14 @@
6672
import org.apache.cloudstack.api.command.user.userdata.RegisterUserDataCmd;
6773
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
6874
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
69-
import org.apache.cloudstack.api.response.ListResponse;
7075
import org.apache.cloudstack.api.response.LicenseCheckerResponse;
71-
import org.apache.cloudstack.api.command.admin.outofbandmanagement.LicenseCheckCmd;
7276
import org.apache.cloudstack.api.response.ListHostDevicesResponse;
77+
// import org.apache.cloudstack.api.response.ListHostLunDevicesResponse;
78+
// import org.apache.cloudstack.api.response.ListHostUsbDevicesResponse;
79+
import org.apache.cloudstack.api.response.ListResponse;
80+
import org.apache.cloudstack.api.response.UpdateHostDevicesResponse;
81+
// import org.apache.cloudstack.api.response.UpdateHostLunDevicesResponse;
82+
// import org.apache.cloudstack.api.response.UpdateHostUsbDevicesResponse;
7383
import org.apache.cloudstack.config.Configuration;
7484
import org.apache.cloudstack.config.ConfigurationGroup;
7585

@@ -97,6 +107,7 @@
97107
import com.cloud.vm.VirtualMachine;
98108
import com.cloud.vm.VirtualMachine.Type;
99109

110+
100111
/**
101112
* Hopefully this is temporary.
102113
*
@@ -496,6 +507,16 @@ VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableE
496507

497508
ListResponse<ListHostDevicesResponse> listHostDevices(ListHostDevicesCmd cmd);
498509

510+
ListResponse<UpdateHostDevicesResponse> updateHostDevices(UpdateHostDevicesCmd cmd);
511+
512+
// ListResponse<ListHostUsbDevicesResponse> listHostUsbDevices(ListHostUsbDevicesCmd cmd);
513+
514+
// ListResponse<ListHostLunDevicesResponse> listHostLunDevices(ListHostLunDevicesCmd cmd);
515+
516+
// ListResponse<UpdateHostUsbDevicesResponse> updateHostUsbDevices(UpdateHostUsbDevicesCmd cmd);
517+
518+
// ListResponse<UpdateHostLunDevicesResponse> updateHostLunDevices(UpdateHostLunDevicesCmd cmd);
519+
499520
LicenseCheckerResponse checkLicense(LicenseCheckCmd cmd);
500521

501522
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,8 @@ public class ApiConstants {
13071307
public static final String LICENSE_CHECK = "licensecheck";
13081308
public static final String HAS_LICENSE = "haslicense";
13091309
public static final String ISSUED_DATE = "issueddate";
1310+
public static final String XML_CONFIG = "xmlconfig";
1311+
public static final String CURRENT_VM_ID = "currentvmid";
13101312
/**
13111313
* This enum specifies IO Drivers, each option controls specific policies on I/O.
13121314
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 org.apache.cloudstack.api.command.admin.outofbandmanagement;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiArgValidator;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.BaseCmd;
24+
import org.apache.cloudstack.api.BaseListCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.response.ListHostLunDevicesResponse;
27+
import org.apache.cloudstack.context.CallContext;
28+
// import org.apache.cloudstack.api.response.ListResponse;
29+
30+
31+
32+
@APICommand(name = "listHostLunDevices", description = "list Host LUN Devices'.", since = "4.20.0.0", responseObject = ListHostLunDevicesResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = { RoleType.Admin })
33+
public class ListHostLunDevicesCmd extends BaseListCmd {
34+
35+
private static final String LISTHOSTLUNDEVICES = "listhostusbdevices";
36+
37+
/////////////////////////////////////////////////////
38+
//////////////// API parameters /////////////////////
39+
/////////////////////////////////////////////////////
40+
41+
@Parameter(name = ApiConstants.ID, type = BaseCmd.CommandType.UUID, entityType = ListHostLunDevicesResponse.class, description = "host ID", required = true, validations = {
42+
ApiArgValidator.PositiveNumber })
43+
private Long id;
44+
45+
/////////////////////////////////////////////////////
46+
/////////////////// Accessors ///////////////////////a
47+
/////////////////////////////////////////////////////
48+
49+
public Long getId() {
50+
return id;
51+
}
52+
53+
/////////////////////////////////////////////////////
54+
/////////////// API Implementation///////////////////
55+
/////////////////////////////////////////////////////
56+
57+
public static String getResultObjectName() {
58+
return "listhostusbdevices";
59+
}
60+
61+
@Override
62+
public long getEntityOwnerId() {
63+
return CallContext.current().getCallingAccountId();
64+
}
65+
66+
@Override
67+
public void execute() {
68+
// ListResponse<ListHostLunDevicesResponse> response = _mgr.listHostLunDevices(this);
69+
// response.setResponseName(getCommandName());
70+
// response.setObjectName(getCommandName());
71+
// this.setResponseObject(response);
72+
}
73+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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 org.apache.cloudstack.api.command.admin.outofbandmanagement;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiArgValidator;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.BaseCmd;
24+
import org.apache.cloudstack.api.BaseListCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.response.ListHostUsbDevicesResponse;
27+
import org.apache.cloudstack.context.CallContext;
28+
// import org.apache.cloudstack.api.response.ListResponse;
29+
30+
31+
32+
@APICommand(name = "listHostUsbDevices", description = "list Host USB Devices'.", since = "4.20.0.0", responseObject = ListHostUsbDevicesResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = { RoleType.Admin })
33+
public class ListHostUsbDevicesCmd extends BaseListCmd {
34+
35+
private static final String LISTHOSTUSBDEVICES = "listhostusbdevices";
36+
37+
/////////////////////////////////////////////////////
38+
//////////////// API parameters /////////////////////
39+
/////////////////////////////////////////////////////
40+
41+
@Parameter(name = ApiConstants.ID, type = BaseCmd.CommandType.UUID, entityType = ListHostUsbDevicesResponse.class, description = "host ID", required = true, validations = {
42+
ApiArgValidator.PositiveNumber })
43+
private Long id;
44+
45+
/////////////////////////////////////////////////////
46+
/////////////////// Accessors ///////////////////////
47+
/////////////////////////////////////////////////////
48+
49+
public Long getId() {
50+
return id;
51+
}
52+
53+
/////////////////////////////////////////////////////
54+
/////////////// API Implementation///////////////////
55+
/////////////////////////////////////////////////////
56+
57+
public static String getResultObjectName() {
58+
return "listhostusbdevices";
59+
}
60+
61+
@Override
62+
public long getEntityOwnerId() {
63+
return CallContext.current().getCallingAccountId();
64+
}
65+
66+
@Override
67+
public void execute() {
68+
// ListResponse<ListHostUsbDevicesResponse> response = _mgr.listHostUsbDevices(this);
69+
// response.setResponseName(getCommandName());
70+
// response.setObjectName(getCommandName());
71+
// this.setResponseObject(response);
72+
}
73+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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 org.apache.cloudstack.api.command.admin.outofbandmanagement;
18+
19+
import org.apache.cloudstack.acl.RoleType;
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiArgValidator;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.BaseCmd;
24+
import org.apache.cloudstack.api.BaseListCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.response.ListResponse;
27+
import org.apache.cloudstack.api.response.UpdateHostDevicesResponse;
28+
import org.apache.cloudstack.context.CallContext;
29+
// import org.apache.cloudstack.api.response.HostResponse;
30+
31+
@APICommand(name = "updateHostDevices", description = "list Host Devices'.", since = "4.20.0.0", responseObject = UpdateHostDevicesResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {
32+
RoleType.Admin })
33+
public class UpdateHostDevicesCmd extends BaseListCmd {
34+
35+
private static final String UPDATEHOSTDEVICES = "updatehostdevices";
36+
37+
/////////////////////////////////////////////////////
38+
//////////////// API parameters /////////////////////
39+
/////////////////////////////////////////////////////
40+
41+
@Parameter(name = ApiConstants.HOST_ID, type = BaseCmd.CommandType.UUID, entityType = UpdateHostDevicesResponse.class, description = "host ID", required = true, validations = {
42+
ApiArgValidator.PositiveNumber })
43+
private Long hostId;
44+
45+
@Parameter(name = ApiConstants.HOSTDEVICES_NAME, type = CommandType.STRING, required = true,
46+
description = "Device name to allocate")
47+
private String hostDeviceName;
48+
49+
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID, type = CommandType.UUID,
50+
entityType = UpdateHostDevicesResponse.class,
51+
required = false, description = "VM ID to allocate the device to")
52+
private Long vmId;
53+
54+
@Parameter(name = ApiConstants.XML_CONFIG, type = CommandType.STRING, required = false,
55+
description = "XML configuration for device attachment")
56+
private String xmlConfig;
57+
58+
@Parameter(name = ApiConstants.CURRENT_VM_ID, type = CommandType.STRING, required = false,
59+
description = "Current VM ID")
60+
private String currentVmId;
61+
62+
/////////////////////////////////////////////////////
63+
/////////////////// Accessors ///////////////////////
64+
/////////////////////////////////////////////////////
65+
66+
public Long getHostId() {
67+
return hostId;
68+
}
69+
70+
public String getHostDeviceName() {
71+
return hostDeviceName;
72+
}
73+
74+
public Long getVirtualMachineId() {
75+
return vmId;
76+
}
77+
78+
public String getXmlConfig() {
79+
return xmlConfig;
80+
}
81+
82+
public void setXmlConfig(String xmlConfig) {
83+
this.xmlConfig = xmlConfig;
84+
}
85+
86+
public String getCurrentVmId() {
87+
return currentVmId;
88+
}
89+
90+
public void setCurrentVmId(String currentVmId) {
91+
this.currentVmId = currentVmId;
92+
}
93+
94+
95+
/////////////////////////////////////////////////////
96+
/////////////// API Implementation///////////////////
97+
/////////////////////////////////////////////////////
98+
99+
public static String getResultObjectName() {
100+
return "updatehostdevices";
101+
}
102+
103+
@Override
104+
public long getEntityOwnerId() {
105+
return CallContext.current().getCallingAccountId();
106+
}
107+
108+
@Override
109+
public void execute() {
110+
ListResponse<UpdateHostDevicesResponse> response = _mgr.updateHostDevices(this);
111+
response.setResponseName(getCommandName());
112+
response.setObjectName(getCommandName());
113+
this.setResponseObject(response);
114+
}
115+
}

0 commit comments

Comments
 (0)