Skip to content

Commit edb16aa

Browse files
committed
change storage allocator policy based on hypervisor
1 parent 3aef9f4 commit edb16aa

7 files changed

Lines changed: 40 additions & 20 deletions

File tree

‎api/src/com/cloud/offering/ServiceOffering.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ public interface ServiceOffering {
6767
*/
6868
boolean getUseLocalStorage();
6969

70+
public String gethypervisorType();
7071
}

‎server/src/com/cloud/hypervisor/kvm/discoverer/KvmServerDiscoverer.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,16 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId,
203203

204204
sshConnection.connect(null, 60000, 60000);
205205
if (!sshConnection.authenticateWithPassword(username, password)) {
206-
throw new Exception("Unable to authenticate");
206+
s_logger.debug("Failed to authenticate");
207+
return null;
208+
}
209+
210+
/*Is a KVM host?*/
211+
sshSession = sshConnection.openSession();
212+
sshSession.execCommand("lsmod|grep kvm >& /dev/null");
213+
if (sshSession.getExitStatus() != 0) {
214+
s_logger.debug("It's not a KVM enabled machine");
215+
return null;
207216
}
208217

209218
if (!sshExecuteCmd(sshConnection, "lsmod|grep kvm >& /dev/null", 3)) {

‎server/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long p
120120
if (conn == null) {
121121
String msg = "Unable to get a connection to " + url;
122122
s_logger.debug(msg);
123-
throw new RuntimeException(msg);
123+
return null;
124124
}
125125

126126
String pod;

‎server/src/com/cloud/migration/ServiceOffering21VO.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,7 @@ public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
124124
public NetworkOffering.GuestIpType getGuestIpType() {
125125
return guestIpType;
126126
}
127+
public String gethypervisorType() {
128+
return null;
129+
}
127130
}

‎server/src/com/cloud/server/ConfigurationServerImpl.java‎

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,17 @@ public void persistDefaultValues() throws InvalidParameterValueException, Intern
137137
}
138138

139139
// Save Direct Networking service offerings
140-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.KVM);
141-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null,Hypervisor.Type.KVM);
142-
// Save Virtual Networking service offerings
143-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Virtual Networking", 1, 512, 500, "Small Instance, Virtual Networking, $0.05 per hour", false, false, true, null, Hypervisor.Type.KVM);
144-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Virtual Networking", 1, 1024, 1000, "Medium Instance, Virtual Networking, $0.10 per hour", false, false, true, null, Hypervisor.Type.KVM);
145-
140+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "KVM, Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.KVM);
141+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "KVM, Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null,Hypervisor.Type.KVM);
142+
146143
// Save Direct Networking service offerings
147-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.XenServer);
148-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null,Hypervisor.Type.XenServer);
149-
// Save Virtual Networking service offerings
150-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Virtual Networking", 1, 512, 500, "Small Instance, Virtual Networking, $0.05 per hour", false, false, true, null, Hypervisor.Type.XenServer);
151-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Virtual Networking", 1, 1024, 1000, "Medium Instance, Virtual Networking, $0.10 per hour", false, false, true, null, Hypervisor.Type.XenServer);
152-
144+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "Xenserver, Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.XenServer);
145+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "Xenserver, Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null,Hypervisor.Type.XenServer);
146+
153147
// Save Direct Networking service offerings
154-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.VMware);
155-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null, Hypervisor.Type.VMware);
156-
// Save Virtual Networking service offerings
157-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Virtual Networking", 1, 512, 500, "Small Instance, Virtual Networking, $0.05 per hour", false, false, true, null, Hypervisor.Type.VMware);
158-
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Virtual Networking", 1, 1024, 1000, "Medium Instance, Virtual Networking, $0.10 per hour", false, false, true, null, Hypervisor.Type.VMware);
148+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Small Instance, Direct Networking", 1, 512, 500, "VMware, Small Instance, Direct Networking, $0.05 per hour", false, false, false, null, Hypervisor.Type.VMware);
149+
_configMgr.createServiceOffering(User.UID_SYSTEM, "Medium Instance, Direct Networking", 1, 1024, 1000, "VMware, Medium Instance, Direct Networking, $0.10 per hour", false, false, false, null, Hypervisor.Type.VMware);
150+
159151
// Save default disk offerings
160152
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Small", "Small Disk, 5 GB", 5, null);
161153
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Medium", "Medium Disk, 20 GB", 20, null);

‎server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import com.cloud.dc.DataCenterVO;
3232
import com.cloud.dc.HostPodVO;
3333
import com.cloud.deploy.DeployDestination;
34+
import com.cloud.dc.ClusterVO;
35+
import com.cloud.dc.dao.ClusterDao;
3436
import com.cloud.host.Host;
3537
import com.cloud.host.HostVO;
3638
import com.cloud.server.StatsCollector;
@@ -74,6 +76,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement
7476
@Inject VolumeDao _volumeDao;
7577
@Inject StoragePoolHostDao _poolHostDao;
7678
@Inject ConfigurationDao _configDao;
79+
@Inject ClusterDao _clusterDao;
7780
int _storageOverprovisioningFactor;
7881
long _extraBytesPerVolume = 0;
7982
Random _rand;
@@ -142,6 +145,12 @@ protected boolean checkPool(Set<? extends StoragePool> avoid, StoragePoolVO pool
142145
return false;
143146
}
144147

148+
/*hypervisor type is correct*/
149+
Long clusterId = pool.getClusterId();
150+
ClusterVO cluster = _clusterDao.findById(clusterId);
151+
if (!cluster.getHypervisorType().equalsIgnoreCase(offering.gethypervisorType())) {
152+
return false;
153+
}
145154
// check the used size against the total size, skip this host if it's greater than the configured
146155
// capacity check "storage.capacity.threshold"
147156
if (sc != null) {

‎setup/db/templates.xenserver.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones)
22
VALUES (1, 'routing', 'SystemVM Template', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/releases/2.2/systemvm.vhd.bz2', 'bcc7f290f4c27ab4d0fe95d1012829ea', 0, 'SystemVM Template', 'VHD', 15, 0, 1);
33
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id, featured, cross_zones)
4-
VALUES (2, 'centos53-x86_64', 'CentOS 5.3(x86_64) no GUI', 1, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(x86_64) no GUI', 'VHD', 12, 1, 1);
4+
VALUES (2, 'centos53-x86_64', 'CentOS 5.3(x86_64) no GUI(Xenserver)', 1, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2', 'b63d854a9560c013142567bbae8d98cf', 0, 'CentOS 5.3(x86_64) no GUI', 'VHD', 12, 1, 1);
5+
6+
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones)
7+
VALUES (3, 'routing', 'DomR Template(KVM)', 0, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/templates/builtin/a88232bf-6a18-38e7-aeee-c1702725079f.qcow2.bz2', 'e39c55e93ae96bd43bfd588ca6ee3269', 'DomR Template', 0, 'QCOW2', 21, 0, 1);
8+
INSERT INTO `cloud`.`vm_template` (id, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, display_text, enable_password, format, guest_os_id, featured, cross_zones)
9+
VALUES (4, 'centos55-x86_64', 'CentOS 5.5(x86_64) no GUI(KVM)', 1, now(), 'ext3', 0, 64, 1, 'http://download.cloud.com/templates/builtin/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2', '1da20ae69b54f761f3f733dce97adcc0', 'CentOS 5.5(x86_64) no GUI', 0, 'QCOW2', 9, 1, 1);
10+
511

612
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (1, 'CentOS');
713
INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (2, 'Debian');

0 commit comments

Comments
 (0)