Skip to content

Commit e5d6f09

Browse files
jschoiRRdhslove
authored andcommitted
Merge pull request #638 from jeongda-young/hostDeviceFilter
[Mold] 호스트 디바이스 할당/해제 기능 추가 및 기능개선
1 parent 755d743 commit e5d6f09

15 files changed

Lines changed: 518 additions & 75 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
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;
3940
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.ListHostLunDevicesCmd;
4041
// import org.apache.cloudstack.api.command.admin.outofbandmanagement.ListHostUsbDevicesCmd;
@@ -71,12 +72,11 @@
7172
import org.apache.cloudstack.api.command.user.userdata.RegisterUserDataCmd;
7273
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
7374
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
74-
import org.apache.cloudstack.api.response.ListResponse;
7575
import org.apache.cloudstack.api.response.LicenseCheckerResponse;
76-
import org.apache.cloudstack.api.command.admin.outofbandmanagement.LicenseCheckCmd;
7776
import org.apache.cloudstack.api.response.ListHostDevicesResponse;
7877
// import org.apache.cloudstack.api.response.ListHostLunDevicesResponse;
7978
// import org.apache.cloudstack.api.response.ListHostUsbDevicesResponse;
79+
import org.apache.cloudstack.api.response.ListResponse;
8080
import org.apache.cloudstack.api.response.UpdateHostDevicesResponse;
8181
// import org.apache.cloudstack.api.response.UpdateHostLunDevicesResponse;
8282
// import org.apache.cloudstack.api.response.UpdateHostUsbDevicesResponse;
@@ -107,6 +107,7 @@
107107
import com.cloud.vm.VirtualMachine;
108108
import com.cloud.vm.VirtualMachine.Type;
109109

110+
110111
/**
111112
* Hopefully this is temporary.
112113
*

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,8 @@ public class ApiConstants {
13421342
public static final String VMWARE_DC = "vmwaredc";
13431343

13441344
public static final String ISSUED_DATE = "issueddate";
1345+
public static final String XML_CONFIG = "xmlconfig";
1346+
public static final String CURRENT_VM_ID = "currentvmid";
13451347
/**
13461348
* This enum specifies IO Drivers, each option controls specific policies on I/O.
13471349
* Qemu guests support "threads" and "native" options Since 0.8.8 ; "io_uring" is supported Since 6.3.0 (QEMU 5.0).

api/src/main/java/org/apache/cloudstack/api/response/ListHostDevicesResponse.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.serializer.Param;
2222
import com.google.gson.annotations.SerializedName;
2323
import java.util.List;
24+
import java.util.Map;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.BaseResponse;
2627
import org.apache.cloudstack.api.EntityReference;
@@ -37,6 +38,10 @@ public class ListHostDevicesResponse extends BaseResponse {
3738
@Param(description = "the ID of the pod the IP address belongs to")
3839
private List<String> hostDevicesText;
3940

41+
@SerializedName("vmallocations")
42+
@Param(description = "Map of device to VM allocations")
43+
private Map<String, String> vmAllocations;
44+
4045
public ListHostDevicesResponse(List<String> hostDevicesName, List<String> hostDevicesText) {
4146
this.hostDevicesName = hostDevicesName;
4247
this.hostDevicesText = hostDevicesText;
@@ -63,4 +68,12 @@ public void setHostDevicesTexts(List<String> hostDevicesText) {
6368
this.hostDevicesText = hostDevicesText;
6469
}
6570

71+
public void setVmAllocations(Map<String, String> vmAllocations) {
72+
this.vmAllocations = vmAllocations;
73+
}
74+
75+
public Map<String, String> getVmAllocations() {
76+
return this.vmAllocations;
77+
}
78+
6679
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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.response;
19+
20+
import com.cloud.host.Host;
21+
import com.cloud.serializer.Param;
22+
import com.google.gson.annotations.SerializedName;
23+
import java.util.HashMap;
24+
import java.util.List;
25+
import java.util.Map;
26+
import org.apache.cloudstack.api.ApiConstants;
27+
import org.apache.cloudstack.api.BaseResponse;
28+
import org.apache.cloudstack.api.EntityReference;
29+
30+
@EntityReference(value = Host.class)
31+
public class ListHostLunDevicesResponse extends BaseResponse {
32+
33+
@SerializedName(ApiConstants.HOSTDEVICES_NAME)
34+
@Param(description = "Device names")
35+
private List<String> hostDevicesName;
36+
37+
@SerializedName(ApiConstants.HOSTDEVICES_TEXT)
38+
@Param(description = "Device descriptions")
39+
private List<String> hostDevicesText;
40+
41+
@SerializedName("vmallocations")
42+
@Param(description = "Map of device to VM allocations")
43+
private Map<String, String> vmAllocations;
44+
45+
@SerializedName("haspartitions")
46+
@Param(description = "Map of devices indicating whether they have partitions")
47+
private Map<String, Boolean> partitionInfo = new HashMap<>();
48+
49+
public ListHostLunDevicesResponse(List<String> hostDevicesName, List<String> hostDevicesText) {
50+
this.hostDevicesName = hostDevicesName;
51+
this.hostDevicesText = hostDevicesText;
52+
}
53+
54+
public ListHostLunDevicesResponse() {
55+
super();
56+
this.setObjectName("listhostlundevices");
57+
}
58+
59+
public List<String> getHostDevicesNames() {
60+
return hostDevicesName;
61+
}
62+
63+
public List<String> getHostDevicesTexts() {
64+
return hostDevicesText;
65+
}
66+
67+
public void setHostDevicesNames(List<String> hostDevicesName) {
68+
this.hostDevicesName = hostDevicesName;
69+
}
70+
71+
public void setHostDevicesTexts(List<String> hostDevicesText) {
72+
this.hostDevicesText = hostDevicesText;
73+
}
74+
75+
public void setVmAllocations(Map<String, String> vmAllocations) {
76+
this.vmAllocations = vmAllocations;
77+
}
78+
79+
public Map<String, String> getVmAllocations() {
80+
return this.vmAllocations;
81+
}
82+
83+
public Map<String, Boolean> getPartitionInfo() {
84+
return partitionInfo;
85+
}
86+
87+
public void setPartitionInfo(Map<String, Boolean> partitionInfo) {
88+
this.partitionInfo = partitionInfo;
89+
}
90+
91+
public void addPartitionInfo(String deviceName, boolean hasPartition) {
92+
if (this.partitionInfo == null) {
93+
this.partitionInfo = new HashMap<>();
94+
}
95+
this.partitionInfo.put(deviceName, hasPartition);
96+
}
97+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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.response;
19+
20+
import com.cloud.host.Host;
21+
import com.cloud.serializer.Param;
22+
import com.cloud.vm.VirtualMachine;
23+
import com.google.gson.annotations.SerializedName;
24+
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.BaseResponse;
27+
import org.apache.cloudstack.api.EntityReference;
28+
29+
@EntityReference(value = {Host.class, VirtualMachine.class})
30+
public class UpdateHostDevicesResponse extends BaseResponse {
31+
32+
@SerializedName(ApiConstants.HOSTDEVICES_NAME)
33+
@Param(description = "Device name")
34+
private String hostDevicesName;
35+
36+
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
37+
@Param(description = "ID of the VM the device is allocated to")
38+
private String virtualmachineid;
39+
40+
@SerializedName("allocated")
41+
@Param(description = "Whether the device is allocated")
42+
private boolean allocated;
43+
44+
public UpdateHostDevicesResponse(String hostDevicesName, String virtualmachineid, boolean allocated) {
45+
this.hostDevicesName = hostDevicesName;
46+
this.virtualmachineid = virtualmachineid;
47+
this.allocated = allocated;
48+
}
49+
50+
public UpdateHostDevicesResponse() {
51+
super();
52+
setObjectName("updatehostdevices");
53+
}
54+
55+
public String getHostDeviceName() {
56+
return hostDevicesName;
57+
}
58+
59+
public void setHostDeviceName(String deviceName) {
60+
this.hostDevicesName = deviceName;
61+
}
62+
63+
public String getVirtualMachineId() {
64+
return virtualmachineid;
65+
}
66+
67+
public void setVirtualMachineId(String virtualmachineid) {
68+
this.virtualmachineid = virtualmachineid;
69+
}
70+
71+
public boolean isAllocated() {
72+
return allocated;
73+
}
74+
75+
public void setAllocated(boolean allocated) {
76+
this.allocated = allocated;
77+
}
78+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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.response;
19+
20+
import com.cloud.host.Host;
21+
import com.cloud.serializer.Param;
22+
import com.cloud.vm.VirtualMachine;
23+
import com.google.gson.annotations.SerializedName;
24+
25+
import org.apache.cloudstack.api.ApiConstants;
26+
import org.apache.cloudstack.api.BaseResponse;
27+
import org.apache.cloudstack.api.EntityReference;
28+
29+
@EntityReference(value = {Host.class, VirtualMachine.class})
30+
public class UpdateHostLunDevicesResponse extends BaseResponse {
31+
32+
@SerializedName(ApiConstants.HOSTDEVICES_NAME)
33+
@Param(description = "Device name")
34+
private String hostDevicesName;
35+
36+
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID)
37+
@Param(description = "ID of the VM the device is allocated to")
38+
private String virtualmachineid;
39+
40+
@SerializedName("allocated")
41+
@Param(description = "Whether the device is allocated")
42+
private boolean allocated;
43+
44+
public UpdateHostLunDevicesResponse(String hostDevicesName, String virtualmachineid, boolean allocated) {
45+
this.hostDevicesName = hostDevicesName;
46+
this.virtualmachineid = virtualmachineid;
47+
this.allocated = allocated;
48+
}
49+
50+
public UpdateHostLunDevicesResponse() {
51+
super();
52+
setObjectName("updatehostdevices");
53+
}
54+
55+
public String getHostDeviceName() {
56+
return hostDevicesName;
57+
}
58+
59+
public void setHostDeviceName(String deviceName) {
60+
this.hostDevicesName = deviceName;
61+
}
62+
63+
public String getVirtualMachineId() {
64+
return virtualmachineid;
65+
}
66+
67+
public void setVirtualMachineId(String virtualmachineid) {
68+
this.virtualmachineid = virtualmachineid;
69+
}
70+
71+
public boolean isAllocated() {
72+
return allocated;
73+
}
74+
75+
public void setAllocated(boolean allocated) {
76+
this.allocated = allocated;
77+
}
78+
}

core/src/main/java/com/cloud/agent/api/ListHostDeviceAnswer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,27 @@
2424

2525
public class ListHostDeviceAnswer extends Answer {
2626
private boolean successMessage;
27+
private List<String> hostDevicesNames;
2728
private List<String> hostDevicesText;
2829

2930
public ListHostDeviceAnswer() {
3031
super();
3132
}
3233

33-
public ListHostDeviceAnswer(boolean successMessage, List<String> hostDevicesText) {
34+
public ListHostDeviceAnswer(boolean successMessage, List<String> hostDevicesNames, List<String> hostDevicesText) {
3435
super();
3536
this.successMessage = successMessage;
37+
this.hostDevicesNames = hostDevicesNames;
3638
this.hostDevicesText = hostDevicesText;
3739
}
3840

41+
public List<String> getHostDevicesNames() {
42+
if (hostDevicesText == null) {
43+
return Collections.emptyList();
44+
}
45+
return hostDevicesNames;
46+
}
47+
3948
public List<String> getHostDevicesTexts() {
4049
if (hostDevicesText == null) {
4150
return Collections.emptyList();

core/src/main/java/com/cloud/agent/api/ListHostDeviceCommand.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@ public List<String> getHostDevicesText() {
5151
public Long getId() {
5252
return id;
5353
}
54+
55+
public void setHostDevicesName(List<String> hostDevicesName) {
56+
this.hostDevicesName = hostDevicesName;
57+
}
5458
}

0 commit comments

Comments
 (0)