Skip to content

Commit f834504

Browse files
committed
Disk controller mappings
1 parent 398ffc3 commit f834504

File tree

30 files changed

+2102
-878
lines changed

30 files changed

+2102
-878
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.storage;
18+
19+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
20+
import org.apache.cloudstack.api.Identity;
21+
import org.apache.cloudstack.api.InternalIdentity;
22+
23+
import java.util.Date;
24+
25+
public interface DiskControllerMapping extends InternalIdentity, Identity {
26+
String getName();
27+
28+
String getControllerReference();
29+
30+
String getBusName();
31+
32+
HypervisorType getHypervisor();
33+
34+
Integer getMaxDeviceCount();
35+
36+
Integer getMaxControllerCount();
37+
38+
String getVmdkAdapterType();
39+
40+
String getMinHardwareVersion();
41+
42+
Date getRemoved();
43+
44+
Date getCreated();
45+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@
2020
package com.cloud.agent.api;
2121

2222
import com.cloud.agent.api.LogLevel.Log4jLevel;
23+
import org.apache.cloudstack.storage.DiskControllerMappingVO;
24+
25+
import java.util.List;
2326

2427
public class SecStorageVMSetupCommand extends Command {
2528
String[] allowedInternalSites = new String[0];
2629
String copyUserName;
2730
@LogLevel(Log4jLevel.Off)
2831
String copyPassword;
2932

33+
private List<DiskControllerMappingVO> supportedDiskControllers;
34+
3035
public SecStorageVMSetupCommand() {
3136
super();
3237
}
@@ -60,4 +65,11 @@ public void setCopyPassword(String copyPassword) {
6065
this.copyPassword = copyPassword;
6166
}
6267

68+
public List<DiskControllerMappingVO> getSupportedDiskControllers() {
69+
return supportedDiskControllers;
70+
}
71+
72+
public void setSupportedDiskControllers(List<DiskControllerMappingVO> supportedDiskControllers) {
73+
this.supportedDiskControllers = supportedDiskControllers;
74+
}
6375
}
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
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.storage;
18+
19+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
20+
import com.cloud.utils.db.GenericDao;
21+
import org.apache.cloudstack.util.HypervisorTypeConverter;
22+
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
23+
24+
import javax.persistence.Column;
25+
import javax.persistence.Convert;
26+
import javax.persistence.Entity;
27+
import javax.persistence.GeneratedValue;
28+
import javax.persistence.GenerationType;
29+
import javax.persistence.Id;
30+
import javax.persistence.Table;
31+
import javax.persistence.Temporal;
32+
import javax.persistence.TemporalType;
33+
import java.util.Date;
34+
import java.util.UUID;
35+
36+
@Entity
37+
@Table(name = "disk_controller_mapping")
38+
public class DiskControllerMappingVO implements DiskControllerMapping {
39+
@Id
40+
@GeneratedValue(strategy = GenerationType.IDENTITY)
41+
@Column(name = "id", nullable = false)
42+
private Long id;
43+
44+
@Column(name = "uuid", nullable = false)
45+
private String uuid = UUID.randomUUID().toString();
46+
47+
@Column(name = "name", nullable = false)
48+
private String name;
49+
50+
@Column(name = "controller_reference", nullable = false)
51+
private String controllerReference;
52+
53+
@Column(name = "bus_name", nullable = false)
54+
private String busName;
55+
56+
@Column(name = "hypervisor", nullable = false)
57+
@Convert(converter = HypervisorTypeConverter.class)
58+
private HypervisorType hypervisor;
59+
60+
@Column(name = "max_device_count")
61+
private Integer maxDeviceCount = null;
62+
63+
@Column(name = "max_controller_count")
64+
private Integer maxControllerCount = null;
65+
66+
@Column(name = "vmdk_adapter_type")
67+
private String vmdkAdapterType = null;
68+
69+
@Column(name = "min_hardware_version")
70+
private String minHardwareVersion = null;
71+
72+
@Column(name = GenericDao.CREATED_COLUMN, nullable = false)
73+
@Temporal(value = TemporalType.TIMESTAMP)
74+
private Date created;
75+
76+
@Column(name = GenericDao.REMOVED_COLUMN)
77+
@Temporal(value = TemporalType.TIMESTAMP)
78+
private Date removed = null;
79+
80+
public DiskControllerMappingVO() {
81+
}
82+
83+
@Override
84+
public String getName() {
85+
return name;
86+
}
87+
88+
@Override
89+
public String getControllerReference() {
90+
return controllerReference;
91+
}
92+
93+
@Override
94+
public String getBusName() {
95+
return busName;
96+
}
97+
98+
@Override
99+
public HypervisorType getHypervisor() {
100+
return hypervisor;
101+
}
102+
103+
@Override
104+
public Integer getMaxDeviceCount() {
105+
return maxDeviceCount;
106+
}
107+
108+
@Override
109+
public Integer getMaxControllerCount() {
110+
return maxControllerCount;
111+
}
112+
113+
@Override
114+
public String getVmdkAdapterType() {
115+
return vmdkAdapterType;
116+
}
117+
118+
@Override
119+
public String getMinHardwareVersion() {
120+
return minHardwareVersion;
121+
}
122+
123+
@Override
124+
public Date getRemoved() {
125+
return removed;
126+
}
127+
128+
@Override
129+
public Date getCreated() {
130+
return created;
131+
}
132+
133+
@Override
134+
public String getUuid() {
135+
return uuid;
136+
}
137+
138+
@Override
139+
public long getId() {
140+
return id;
141+
}
142+
143+
public void setId(Long id) {
144+
this.id = id;
145+
}
146+
147+
public void setUuid(String uuid) {
148+
this.uuid = uuid;
149+
}
150+
151+
public void setName(String name) {
152+
this.name = name;
153+
}
154+
155+
public void setControllerReference(String controllerReference) {
156+
this.controllerReference = controllerReference;
157+
}
158+
159+
public void setBusName(String busName) {
160+
this.busName = busName;
161+
}
162+
163+
public void setHypervisor(HypervisorType hypervisor) {
164+
this.hypervisor = hypervisor;
165+
}
166+
167+
public void setMaxDeviceCount(Integer maxDeviceCount) {
168+
this.maxDeviceCount = maxDeviceCount;
169+
}
170+
171+
public void setMaxControllerCount(Integer maxControllerCount) {
172+
this.maxControllerCount = maxControllerCount;
173+
}
174+
175+
public void setVmdkAdapterType(String vmdkAdapterType) {
176+
this.vmdkAdapterType = vmdkAdapterType;
177+
}
178+
179+
public void setMinHardwareVersion(String minHardwareVersion) {
180+
this.minHardwareVersion = minHardwareVersion;
181+
}
182+
183+
public void setCreated(Date created) {
184+
this.created = created;
185+
}
186+
187+
public void setRemoved(Date removed) {
188+
this.removed = removed;
189+
}
190+
191+
@Override
192+
public boolean equals(Object obj) {
193+
if (!(obj instanceof DiskControllerMappingVO)) {
194+
return false;
195+
}
196+
DiskControllerMappingVO that = (DiskControllerMappingVO) obj;
197+
return controllerReference.equals(that.getControllerReference());
198+
}
199+
200+
@Override
201+
public String toString() {
202+
return ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "name", "controllerReference",
203+
"busName", "hypervisor", "maxDeviceCount", "maxControllerCount", "vmdkAdapterType", "minHardwareVersion");
204+
}
205+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.storage.dao;
18+
19+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
20+
import org.apache.cloudstack.storage.DiskControllerMappingVO;
21+
import com.cloud.utils.db.GenericDao;
22+
23+
import java.util.List;
24+
25+
public interface DiskControllerMappingDao extends GenericDao<DiskControllerMappingVO, Long> {
26+
DiskControllerMappingVO findDiskControllerMapping(String name, String classReference, HypervisorType hypervisor);
27+
28+
List<DiskControllerMappingVO> listForHypervisor(HypervisorType hypervisor);
29+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.storage.dao;
18+
19+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
20+
import com.cloud.utils.db.GenericDaoBase;
21+
import com.cloud.utils.db.SearchBuilder;
22+
import com.cloud.utils.db.SearchCriteria;
23+
import org.apache.cloudstack.storage.DiskControllerMappingVO;
24+
import org.springframework.stereotype.Component;
25+
26+
import javax.annotation.PostConstruct;
27+
import java.util.List;
28+
29+
@Component
30+
public class DiskControllerMappingDaoImpl extends GenericDaoBase<DiskControllerMappingVO, Long> implements DiskControllerMappingDao {
31+
private SearchBuilder<DiskControllerMappingVO> diskControllerMappingSearch;
32+
33+
@PostConstruct
34+
public void init() {
35+
diskControllerMappingSearch = createSearchBuilder();
36+
diskControllerMappingSearch.and("name", diskControllerMappingSearch.entity().getName(), SearchCriteria.Op.EQ);
37+
diskControllerMappingSearch.and("controllerReference", diskControllerMappingSearch.entity().getControllerReference(), SearchCriteria.Op.EQ);
38+
diskControllerMappingSearch.and("hypervisor", diskControllerMappingSearch.entity().getHypervisor(), SearchCriteria.Op.EQ);
39+
diskControllerMappingSearch.done();
40+
}
41+
42+
@Override
43+
public DiskControllerMappingVO findDiskControllerMapping(String name, String controllerReference, HypervisorType hypervisor) {
44+
SearchCriteria<DiskControllerMappingVO> sc = diskControllerMappingSearch.create();
45+
sc.setParametersIfNotNull("name", name);
46+
sc.setParametersIfNotNull("controllerReference", controllerReference);
47+
sc.setParameters("hypervisor", hypervisor);
48+
return findOneBy(sc);
49+
}
50+
51+
@Override
52+
public List<DiskControllerMappingVO> listForHypervisor(HypervisorType hypervisor) {
53+
SearchCriteria<DiskControllerMappingVO> sc = diskControllerMappingSearch.create();
54+
sc.setParameters("hypervisor", hypervisor);
55+
return listBy(sc);
56+
}
57+
}

engine/schema/src/main/resources/META-INF/cloudstack/core/spring-engine-schema-core-daos-context.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<bean id="dataCenterJoinDaoImpl" class="com.cloud.api.query.dao.DataCenterJoinDaoImpl" />
6868
<bean id="domainVlanMapDaoImpl" class="com.cloud.dc.dao.DomainVlanMapDaoImpl" />
6969
<bean id="engineDcDetailsDaoImpl" class="org.apache.cloudstack.engine.datacenter.entity.api.db.dao.DcDetailsDaoImpl" />
70+
<bean id="diskControllerMappingDaoImpl" class="org.apache.cloudstack.storage.dao.DiskControllerMappingDaoImpl" />
7071
<bean id="diskOfferingJoinDaoImpl" class="com.cloud.api.query.dao.DiskOfferingJoinDaoImpl" />
7172
<bean id="domainDaoImpl" class="com.cloud.domain.dao.DomainDaoImpl" />
7273
<bean id="domainDetailsDaoImpl" class="com.cloud.domain.dao.DomainDetailsDaoImpl" />

0 commit comments

Comments
 (0)