Skip to content

Commit 72e79bc

Browse files
CLOUDSTACK-9046 - Add new ACS systemVMs website
- Also change the URl in the SQL file.
1 parent 4b503b4 commit 72e79bc

2 files changed

Lines changed: 90 additions & 63 deletions

File tree

engine/schema/src/com/cloud/upgrade/dao/Upgrade452to460.java

Lines changed: 89 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -171,31 +171,39 @@ public File[] getCleanupScripts() {
171171
return new File[] { new File(script) };
172172
}
173173

174+
@SuppressWarnings("serial")
174175
private void updateSystemVmTemplates(final Connection conn) {
175176
s_logger.debug("Updating System Vm template IDs");
176-
//Get all hypervisors in use
177+
// Get all hypervisors in use
177178
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
178-
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null");
179-
ResultSet rs = pstmt.executeQuery()
180-
) {
181-
while(rs.next()){
179+
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
180+
while (rs.next()) {
182181
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
183-
case XenServer: hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
184-
break;
185-
case KVM: hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
186-
break;
187-
case VMware: hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
188-
break;
189-
case Hyperv: hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
190-
break;
191-
case LXC: hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
192-
break;
193-
default: // no action on cases Any, BareMetal, None, Ovm, Parralels, Simulator and VirtualBox:
182+
case XenServer:
183+
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
184+
break;
185+
case KVM:
186+
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
187+
break;
188+
case VMware:
189+
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
190+
break;
191+
case Hyperv:
192+
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
193+
break;
194+
case LXC:
195+
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
196+
break;
197+
case Ovm3:
198+
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
199+
break;
200+
default: // no action on cases Any, BareMetal, None, Ovm,
201+
// Parralels, Simulator and VirtualBox:
194202
break;
195203
}
196204
}
197205
} catch (final SQLException e) {
198-
s_logger.error("updateSystemVmTemplates:Exception while getting hypervisor types from clusters: "+e.getMessage());
206+
s_logger.error("updateSystemVmTemplates:Exception while getting hypervisor types from clusters: " + e.getMessage());
199207
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
200208
}
201209

@@ -206,108 +214,127 @@ private void updateSystemVmTemplates(final Connection conn) {
206214
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.6");
207215
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.6");
208216
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.6");
217+
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.6");
209218
}
210219
};
211220

212221
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
213222
{
214-
put(Hypervisor.HypervisorType.XenServer, "router.template.xen");
223+
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
215224
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
216225
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
217226
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
218227
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
228+
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
219229
}
220230
};
221231

222232
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
223233
{
224-
put(Hypervisor.HypervisorType.XenServer, "http://download.cloud.com/templates/4.6/systemvm64template-4.6-xen.vhd.bz2");
225-
put(Hypervisor.HypervisorType.VMware, "http://download.cloud.com/templates/4.6/systemvm64template-4.6-vmware.ova");
226-
put(Hypervisor.HypervisorType.KVM, "http://download.cloud.com/templates/4.6/systemvm64template-4.6-kvm.qcow2.bz2");
227-
put(Hypervisor.HypervisorType.LXC, "http://download.cloud.com/templates/4.6/systemvm64template-4.6-kvm.qcow2.bz2");
228-
put(Hypervisor.HypervisorType.Hyperv, "http://download.cloud.com/templates/4.6/systemvm64template-4.6-hyperv.vhd.zip");
234+
put(Hypervisor.HypervisorType.XenServer, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-xen.vhd.bz2");
235+
put(Hypervisor.HypervisorType.VMware, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-vmware.ova");
236+
put(Hypervisor.HypervisorType.KVM, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2");
237+
put(Hypervisor.HypervisorType.LXC, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-kvm.qcow2.bz2");
238+
put(Hypervisor.HypervisorType.Hyperv, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-hyperv.vhd.zip");
239+
put(Hypervisor.HypervisorType.Ovm3, "http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-ovm.raw.bz2");
229240
}
230241
};
231242

232243
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
233244
{
234-
put(Hypervisor.HypervisorType.XenServer, "2b15ab4401c2d655264732d3fc600241");
235-
put(Hypervisor.HypervisorType.VMware, "3106a79a4ce66cd7f6a7c50e93f2db57");
236-
put(Hypervisor.HypervisorType.KVM, "aa9f501fecd3de1daeb9e2f357f6f002");
237-
put(Hypervisor.HypervisorType.LXC, "aa9f501fecd3de1daeb9e2f357f6f002");
238-
put(Hypervisor.HypervisorType.Hyperv, "70bd30ea02ee9ed67d2c6b85c179cee9");
245+
put(Hypervisor.HypervisorType.XenServer, "8886f554a499ec5405b6f203d9d36460");
246+
put(Hypervisor.HypervisorType.VMware, "4b415224fe00b258f66cad9fce9f73fc");
247+
put(Hypervisor.HypervisorType.KVM, "c059b0d051e0cd6fbe9d5d4fc40c7e5d");
248+
put(Hypervisor.HypervisorType.LXC, "c059b0d051e0cd6fbe9d5d4fc40c7e5d");
249+
put(Hypervisor.HypervisorType.Hyperv, "53e24bddfa56ea3139ed37af4b519013");
250+
put(Hypervisor.HypervisorType.Ovm3, "c8577d27b2daafb2d9a4ed307ce2f00f");
239251
}
240252
};
241253

242254
for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
243255
s_logger.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
244-
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
245-
//Get 4.6.0 system Vm template Id for corresponding hypervisor
256+
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
257+
// Get 4.6.0 system Vm template Id for corresponding hypervisor
246258
long templateId = -1;
247259
pstmt.setString(1, hypervisorAndTemplateName.getValue());
248260
try (ResultSet rs = pstmt.executeQuery()) {
249-
if(rs.next()){
261+
if (rs.next()) {
250262
templateId = rs.getLong(1);
251263
}
252-
} catch (final SQLException e)
253-
{
254-
s_logger.error("updateSystemVmTemplates:Exception while getting ids of templates: "+e.getMessage());
264+
} catch (final SQLException e) {
265+
s_logger.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
255266
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
256267
}
257268

258269
// change template type to SYSTEM
259270
if (templateId != -1) {
260-
try(PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");)
261-
{
271+
try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) {
262272
templ_type_pstmt.setLong(1, templateId);
263273
templ_type_pstmt.executeUpdate();
264-
}
265-
catch (final SQLException e)
266-
{
267-
s_logger.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': "+e.getMessage());
274+
} catch (final SQLException e) {
275+
s_logger.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
268276
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
269277
}
270278
// update template ID of system Vms
271-
try(PreparedStatement update_templ_id_pstmt = conn.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");)
272-
{
279+
try (PreparedStatement update_templ_id_pstmt = conn
280+
.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");) {
273281
update_templ_id_pstmt.setLong(1, templateId);
274282
update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
275283
update_templ_id_pstmt.executeUpdate();
276-
}catch (final Exception e)
277-
{
278-
s_logger.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId + ": "+e.getMessage());
279-
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId, e);
284+
} catch (final Exception e) {
285+
s_logger.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId
286+
+ ": " + e.getMessage());
287+
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to "
288+
+ templateId, e);
280289
}
281-
// Change value of global configuration parameter router.template.* for the corresponding hypervisor
282-
try(PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
290+
291+
// Change value of global configuration parameter
292+
// router.template.* for the corresponding hypervisor
293+
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
283294
update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
284295
update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
285296
update_pstmt.executeUpdate();
286-
}catch (final SQLException e)
287-
{
288-
s_logger.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue() + ": "+e.getMessage());
289-
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
297+
} catch (final SQLException e) {
298+
s_logger.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to "
299+
+ hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
300+
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting "
301+
+ routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
302+
}
303+
304+
// Change value of global configuration parameter
305+
// minreq.sysvmtemplate.version for the ACS version
306+
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
307+
update_pstmt.setString(1, getUpgradedVersion());
308+
update_pstmt.setString(2, "minreq.sysvmtemplate.version");
309+
update_pstmt.executeUpdate();
310+
} catch (final SQLException e) {
311+
s_logger.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.6.0: " + e.getMessage());
312+
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.6.0", e);
290313
}
291314
} else {
292-
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())){
293-
throw new CloudRuntimeException("4.6.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
315+
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
316+
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
294317
} else {
295-
s_logger.warn("4.6.0 " + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey() + " hypervisor is not used, so not failing upgrade");
296-
// Update the latest template URLs for corresponding hypervisor
297-
try(PreparedStatement update_templ_url_pstmt = conn.prepareStatement("UPDATE `cloud`.`vm_template` SET url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order by id desc limit 1");) {
318+
s_logger.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey()
319+
+ " hypervisor is not used, so not failing upgrade");
320+
// Update the latest template URLs for corresponding
321+
// hypervisor
322+
try (PreparedStatement update_templ_url_pstmt = conn
323+
.prepareStatement("UPDATE `cloud`.`vm_template` SET url = ? , checksum = ? WHERE hypervisor_type = ? AND type = 'SYSTEM' AND removed is null order by id desc limit 1");) {
298324
update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
299325
update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
300326
update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
301327
update_templ_url_pstmt.executeUpdate();
302-
}catch (final SQLException e)
303-
{
304-
s_logger.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type " + hypervisorAndTemplateName.getKey().toString() + ": "+e.getMessage());
305-
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type " + hypervisorAndTemplateName.getKey().toString(), e);
328+
} catch (final SQLException e) {
329+
s_logger.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
330+
+ hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
331+
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
332+
+ hypervisorAndTemplateName.getKey().toString(), e);
306333
}
307334
}
308335
}
309336
} catch (final SQLException e) {
310-
s_logger.error("updateSystemVmTemplates:Exception while getting ids of templates: "+e.getMessage());
337+
s_logger.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
311338
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
312339
}
313340
}

setup/db/db/schema-452to460.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor
377377
UPDATE `cloud`.`volumes` v, `cloud`.`storage_pool` s, `cloud`.`cluster` c set v.format='RAW' where v.pool_id=s.id and s.cluster_id=c.id and c.hypervisor_type='Ovm3';
378378
UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,Ovm3,LXC' WHERE name='hypervisor.list';
379379
INSERT INTO `cloud`.`vm_template` (id, uuid, unique_name, name, public, created, type, hvm, bits, account_id, url, checksum, enable_password, display_text, format, guest_os_id,featured, cross_zones, hypervisor_type, state)
380-
VALUES (12, UUID(), 'routing-12', 'SystemVM Template (Ovm3)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://download.cloud.com/templates/4.6/systemvm64template.ovm.raw.bz2', '4425688804dbcf0abc9e9e56c53070d7', 0, 'SystemVM Template (Ovm3)', 'RAW', 183, 0, 1, 'Ovm3', 'Active' );
380+
VALUES (12, UUID(), 'routing-12', 'SystemVM Template (Ovm3)', 0, now(), 'SYSTEM', 0, 64, 1, 'http://cloudstack.apt-get.eu/systemvm/4.6/systemvm64template-4.6.0-ovm.raw.bz2', 'c8577d27b2daafb2d9a4ed307ce2f00f', 0, 'SystemVM Template (Ovm3)', 'RAW', 183, 0, 1, 'Ovm3', 'Active' );
381381

382382
INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `default_value`, `description`) VALUES ('Advanced', 'DEFAULT', 'ManagementServer', 'ovm3.heartbeat.timeout' , '180', '120', 'Timeout value to send to the checkheartbeat script for guarding the self fencing functionality on ovm3');
383383
INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `default_value`, `description`) VALUES ('Advanced', 'DEFAULT', 'ManagementServer', 'ovm3.heartbeat.interval' , '10', '1', 'Interval value the checkheartbeat script uses before triggering the timeout for ovm3');

0 commit comments

Comments
 (0)