mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Merge remote-tracking branch 'origin/4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
e559154a41
@ -29,13 +29,10 @@ import java.util.Date;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
|
||||
import com.cloud.upgrade.dao.DbUpgrade;
|
||||
import com.cloud.upgrade.dao.Upgrade217to218;
|
||||
import com.cloud.upgrade.dao.Upgrade218to22;
|
||||
@ -65,7 +62,8 @@ import com.cloud.upgrade.dao.Upgrade40to41;
|
||||
import com.cloud.upgrade.dao.Upgrade41000to41100;
|
||||
import com.cloud.upgrade.dao.Upgrade410to420;
|
||||
import com.cloud.upgrade.dao.Upgrade41100to41110;
|
||||
import com.cloud.upgrade.dao.Upgrade41110to41200;
|
||||
import com.cloud.upgrade.dao.Upgrade41110to41120;
|
||||
import com.cloud.upgrade.dao.Upgrade41120to41200;
|
||||
import com.cloud.upgrade.dao.Upgrade420to421;
|
||||
import com.cloud.upgrade.dao.Upgrade421to430;
|
||||
import com.cloud.upgrade.dao.Upgrade430to440;
|
||||
@ -101,6 +99,7 @@ import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.ScriptRunner;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
private static final Logger s_logger = Logger.getLogger(DatabaseUpgradeChecker.class);
|
||||
@ -182,7 +181,8 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
||||
.next("4.9.3.1" , new Upgrade4930to41000())
|
||||
.next("4.10.0.0", new Upgrade41000to41100())
|
||||
.next("4.11.0.0", new Upgrade41100to41110())
|
||||
.next("4.11.1.0", new Upgrade41110to41200())
|
||||
.next("4.11.1.0", new Upgrade41110to41120())
|
||||
.next("4.11.2.0", new Upgrade41120to41200())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -19,20 +19,16 @@
|
||||
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade41100to41110 implements DbUpgrade {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41000to41100.class);
|
||||
@ -65,7 +61,6 @@ public class Upgrade41100to41110 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
updateSystemVmTemplates(conn);
|
||||
markUnnecessarySecureConfigsAsUnsecure(conn);
|
||||
}
|
||||
|
||||
@ -138,174 +133,6 @@ public class Upgrade41100to41110 implements DbUpgrade {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void updateSystemVmTemplates(final Connection conn) {
|
||||
LOG.debug("Updating System Vm template IDs");
|
||||
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
|
||||
case XenServer:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
|
||||
break;
|
||||
case KVM:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
|
||||
break;
|
||||
case VMware:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
|
||||
break;
|
||||
case Hyperv:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
|
||||
break;
|
||||
case LXC:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
|
||||
break;
|
||||
case Ovm3:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting hypervisor types from clusters: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
|
||||
}
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.11.1");
|
||||
put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.11.1");
|
||||
put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.11.1");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.11.1");
|
||||
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.11.1");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.11.1");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
|
||||
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-vmware.ova");
|
||||
put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-xen.vhd.bz2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-hyperv.vhd.zip");
|
||||
put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.1-ovm.raw.bz2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "6019c2ed1a13669dcf334fe380c776b0");
|
||||
put(Hypervisor.HypervisorType.XenServer, "f2245e912c856ab610d91f88c362a1f9");
|
||||
put(Hypervisor.HypervisorType.VMware, "1dbcd051fcfcd0fd568ff6eb5294988a");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "e68ec90f0dc06821d94a2ee0e88fa646");
|
||||
put(Hypervisor.HypervisorType.LXC, "6019c2ed1a13669dcf334fe380c776b0");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "cd2ac8dcdaf6c05d75e29cb39ee9a10f");
|
||||
}
|
||||
};
|
||||
|
||||
for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
|
||||
LOG.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
|
||||
// Get 4.11.0 systemvm template id for corresponding hypervisor
|
||||
long templateId = -1;
|
||||
pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
try (ResultSet rs = pstmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
templateId = rs.getLong(1);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates: Exception caught while getting ids of templates", e);
|
||||
}
|
||||
|
||||
// change template type to SYSTEM
|
||||
if (templateId != -1) {
|
||||
try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) {
|
||||
templ_type_pstmt.setLong(1, templateId);
|
||||
templ_type_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
|
||||
}
|
||||
// update template ID of system Vms
|
||||
try (PreparedStatement update_templ_id_pstmt = conn
|
||||
.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ?");) {
|
||||
update_templ_id_pstmt.setLong(1, templateId);
|
||||
update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_id_pstmt.executeUpdate();
|
||||
} catch (final Exception e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId
|
||||
+ ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to "
|
||||
+ templateId, e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// router.template.* for the corresponding hypervisor
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to "
|
||||
+ hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting "
|
||||
+ routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// minreq.sysvmtemplate.version for the ACS version
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, "4.11.1");
|
||||
update_pstmt.setString(2, "minreq.sysvmtemplate.version");
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.1: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.1", e);
|
||||
}
|
||||
} else {
|
||||
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
|
||||
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
|
||||
} else {
|
||||
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey()
|
||||
+ " hypervisor is not used, so not failing upgrade");
|
||||
// Update the latest template URLs for corresponding
|
||||
// hypervisor
|
||||
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");) {
|
||||
update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_url_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
|
||||
}
|
||||
}
|
||||
LOG.debug("Updating System Vm Template IDs Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream[] getCleanupScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41100to41110-cleanup.sql";
|
||||
|
||||
@ -0,0 +1,247 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.upgrade.dao;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade41110to41120 implements DbUpgrade {
|
||||
final static Logger LOG = Logger.getLogger(Upgrade41110to41120.class);
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[]{"4.11.1.0", "4.11.2.0"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpgradedVersion() {
|
||||
return "4.11.2.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRollingUpgrade() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream[] getPrepareScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41110to41120.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
}
|
||||
|
||||
return new InputStream[] {script};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
updateSystemVmTemplates(conn);
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private void updateSystemVmTemplates(final Connection conn) {
|
||||
LOG.debug("Updating System Vm template IDs");
|
||||
final Set<Hypervisor.HypervisorType> hypervisorsListInUse = new HashSet<Hypervisor.HypervisorType>();
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select distinct(hypervisor_type) from `cloud`.`cluster` where removed is null"); ResultSet rs = pstmt.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
switch (Hypervisor.HypervisorType.getType(rs.getString(1))) {
|
||||
case XenServer:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.XenServer);
|
||||
break;
|
||||
case KVM:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.KVM);
|
||||
break;
|
||||
case VMware:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.VMware);
|
||||
break;
|
||||
case Hyperv:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Hyperv);
|
||||
break;
|
||||
case LXC:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.LXC);
|
||||
break;
|
||||
case Ovm3:
|
||||
hypervisorsListInUse.add(Hypervisor.HypervisorType.Ovm3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting hypervisor types from clusters: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting hypervisor types from clusters", e);
|
||||
}
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> NewTemplateNameList = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "systemvm-kvm-4.11.2");
|
||||
put(Hypervisor.HypervisorType.VMware, "systemvm-vmware-4.11.2");
|
||||
put(Hypervisor.HypervisorType.XenServer, "systemvm-xenserver-4.11.2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "systemvm-hyperv-4.11.2");
|
||||
put(Hypervisor.HypervisorType.LXC, "systemvm-lxc-4.11.2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "systemvm-ovm3-4.11.2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> routerTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
put(Hypervisor.HypervisorType.XenServer, "router.template.xenserver");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "router.template.hyperv");
|
||||
put(Hypervisor.HypervisorType.LXC, "router.template.lxc");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "router.template.ovm3");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateUrl = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.VMware, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-vmware.ova");
|
||||
put(Hypervisor.HypervisorType.XenServer, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-xen.vhd.bz2");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-hyperv.vhd.zip");
|
||||
put(Hypervisor.HypervisorType.LXC, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-kvm.qcow2.bz2");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "https://download.cloudstack.org/systemvm/4.11/systemvmtemplate-4.11.2-ovm.raw.bz2");
|
||||
}
|
||||
};
|
||||
|
||||
final Map<Hypervisor.HypervisorType, String> newTemplateChecksum = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "f44242570ae4a0b16c4c2eb2cb71fe45");
|
||||
put(Hypervisor.HypervisorType.XenServer, "afcc31ab9f7635885cd83600eafbbe7f");
|
||||
put(Hypervisor.HypervisorType.VMware, "54449e31530f14af930c80a3155a308f");
|
||||
put(Hypervisor.HypervisorType.Hyperv, "7785df30fdbbacdead5acbfc15ae2c98");
|
||||
put(Hypervisor.HypervisorType.LXC, "f44242570ae4a0b16c4c2eb2cb71fe45");
|
||||
put(Hypervisor.HypervisorType.Ovm3, "81a6cd8d07fad910824f040f73ce03e3");
|
||||
}
|
||||
};
|
||||
|
||||
for (final Map.Entry<Hypervisor.HypervisorType, String> hypervisorAndTemplateName : NewTemplateNameList.entrySet()) {
|
||||
LOG.debug("Updating " + hypervisorAndTemplateName.getKey() + " System Vms");
|
||||
try (PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`vm_template` where name = ? and removed is null order by id desc limit 1")) {
|
||||
// Get 4.11 systemvm template id for corresponding hypervisor
|
||||
long templateId = -1;
|
||||
pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
try (ResultSet rs = pstmt.executeQuery()) {
|
||||
if (rs.next()) {
|
||||
templateId = rs.getLong(1);
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates: Exception caught while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates: Exception caught while getting ids of templates", e);
|
||||
}
|
||||
|
||||
// change template type to SYSTEM
|
||||
if (templateId != -1) {
|
||||
try (PreparedStatement templ_type_pstmt = conn.prepareStatement("update `cloud`.`vm_template` set type='SYSTEM' where id = ?");) {
|
||||
templ_type_pstmt.setLong(1, templateId);
|
||||
templ_type_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system': " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating template with id " + templateId + " to be marked as 'system'", e);
|
||||
}
|
||||
// update template ID of system Vms
|
||||
try (PreparedStatement update_templ_id_pstmt = conn
|
||||
.prepareStatement("update `cloud`.`vm_instance` set vm_template_id = ? where type <> 'User' and hypervisor_type = ? and removed is NULL");) {
|
||||
update_templ_id_pstmt.setLong(1, templateId);
|
||||
update_templ_id_pstmt.setString(2, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_id_pstmt.executeUpdate();
|
||||
} catch (final Exception e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to " + templateId
|
||||
+ ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting template for " + hypervisorAndTemplateName.getKey().toString() + " to "
|
||||
+ templateId, e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// router.template.* for the corresponding hypervisor
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, hypervisorAndTemplateName.getValue());
|
||||
update_pstmt.setString(2, routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()));
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting " + routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to "
|
||||
+ hypervisorAndTemplateName.getValue() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting "
|
||||
+ routerTemplateConfigurationNames.get(hypervisorAndTemplateName.getKey()) + " to " + hypervisorAndTemplateName.getValue(), e);
|
||||
}
|
||||
|
||||
// Change value of global configuration parameter
|
||||
// minreq.sysvmtemplate.version for the ACS version
|
||||
try (PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = ?");) {
|
||||
update_pstmt.setString(1, "4.11.2");
|
||||
update_pstmt.setString(2, "minreq.sysvmtemplate.version");
|
||||
update_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.2: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while setting 'minreq.sysvmtemplate.version' to 4.11.2", e);
|
||||
}
|
||||
} else {
|
||||
if (hypervisorsListInUse.contains(hypervisorAndTemplateName.getKey())) {
|
||||
throw new CloudRuntimeException(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. Cannot upgrade system Vms");
|
||||
} else {
|
||||
LOG.warn(getUpgradedVersion() + hypervisorAndTemplateName.getKey() + " SystemVm template not found. " + hypervisorAndTemplateName.getKey()
|
||||
+ " hypervisor is not used, so not failing upgrade");
|
||||
// Update the latest template URLs for corresponding
|
||||
// hypervisor
|
||||
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");) {
|
||||
update_templ_url_pstmt.setString(1, newTemplateUrl.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(2, newTemplateChecksum.get(hypervisorAndTemplateName.getKey()));
|
||||
update_templ_url_pstmt.setString(3, hypervisorAndTemplateName.getKey().toString());
|
||||
update_templ_url_pstmt.executeUpdate();
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString() + ": " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type "
|
||||
+ hypervisorAndTemplateName.getKey().toString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final SQLException e) {
|
||||
LOG.error("updateSystemVmTemplates:Exception while getting ids of templates: " + e.getMessage());
|
||||
throw new CloudRuntimeException("updateSystemVmTemplates:Exception while getting ids of templates", e);
|
||||
}
|
||||
}
|
||||
LOG.debug("Updating System Vm Template IDs Complete");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream[] getCleanupScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41110to41120-cleanup.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
}
|
||||
|
||||
return new InputStream[] {script};
|
||||
}
|
||||
}
|
||||
@ -22,11 +22,11 @@ import java.sql.Connection;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class Upgrade41110to41200 implements DbUpgrade {
|
||||
public class Upgrade41120to41200 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public String[] getUpgradableVersionRange() {
|
||||
return new String[] {"4.11.1.0", "4.12.0.0"};
|
||||
return new String[] {"4.11.2.0", "4.12.0.0"};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +41,7 @@ public class Upgrade41110to41200 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public InputStream[] getPrepareScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41110to41200.sql";
|
||||
final String scriptFile = "META-INF/db/schema-41120to41200.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
@ -57,7 +57,7 @@ public class Upgrade41110to41200 implements DbUpgrade {
|
||||
|
||||
@Override
|
||||
public InputStream[] getCleanupScripts() {
|
||||
final String scriptFile = "META-INF/db/schema-41110to41200-cleanup.sql";
|
||||
final String scriptFile = "META-INF/db/schema-41120to41200-cleanup.sql";
|
||||
final InputStream script = Thread.currentThread().getContextClassLoader().getResourceAsStream(scriptFile);
|
||||
if (script == null) {
|
||||
throw new CloudRuntimeException("Unable to find " + scriptFile);
|
||||
@ -0,0 +1,20 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you under the Apache License, Version 2.0 (the
|
||||
-- "License"); you may not use this file except in compliance
|
||||
-- with the License. You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing,
|
||||
-- software distributed under the License is distributed on an
|
||||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
-- KIND, either express or implied. See the License for the
|
||||
-- specific language governing permissions and limitations
|
||||
-- under the License.
|
||||
|
||||
--;
|
||||
-- Schema upgrade from 4.11.1.0 to 4.11.2.0
|
||||
--;
|
||||
@ -0,0 +1,24 @@
|
||||
-- Licensed to the Apache Software Foundation (ASF) under one
|
||||
-- or more contributor license agreements. See the NOTICE file
|
||||
-- distributed with this work for additional information
|
||||
-- regarding copyright ownership. The ASF licenses this file
|
||||
-- to you under the Apache License, Version 2.0 (the
|
||||
-- "License"); you may not use this file except in compliance
|
||||
-- with the License. You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing,
|
||||
-- software distributed under the License is distributed on an
|
||||
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
-- KIND, either express or implied. See the License for the
|
||||
-- specific language governing permissions and limitations
|
||||
-- under the License.
|
||||
|
||||
--;
|
||||
-- Schema upgrade from 4.11.1.0 to 4.11.2.0
|
||||
--;
|
||||
|
||||
-- XenServer 7.5
|
||||
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, max_data_volumes_limit, storage_motion_supported) values (UUID(), 'XenServer', '7.5.0', 500, 13, 1);
|
||||
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'Xenserver', '7.5.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='7.4.0';
|
||||
@ -16,7 +16,7 @@
|
||||
-- under the License.
|
||||
|
||||
--;
|
||||
-- Schema upgrade cleanup from 4.11.1.0 to 4.12.0.0
|
||||
-- Schema upgrade cleanup from 4.11.2.0 to 4.12.0.0
|
||||
--;
|
||||
|
||||
DROP TABLE IF EXISTS `cloud`.`iam_account_policy_map`;
|
||||
@ -16,7 +16,7 @@
|
||||
-- under the License.
|
||||
|
||||
--;
|
||||
-- Schema upgrade from 4.11.1.0 to 4.12.0.0
|
||||
-- Schema upgrade from 4.11.2.0 to 4.12.0.0
|
||||
--;
|
||||
|
||||
-- [CLOUDSTACK-10314] Add reason column to ACL rule table
|
||||
@ -22,15 +22,15 @@ import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cloudstack.utils.CloudStackVersion;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.upgrade.DatabaseUpgradeChecker.NoopDbUpgrade;
|
||||
import com.cloud.upgrade.dao.DbUpgrade;
|
||||
import com.cloud.upgrade.dao.Upgrade41000to41100;
|
||||
import com.cloud.upgrade.dao.Upgrade41100to41110;
|
||||
import com.cloud.upgrade.dao.Upgrade41110to41200;
|
||||
import com.cloud.upgrade.dao.Upgrade41110to41120;
|
||||
import com.cloud.upgrade.dao.Upgrade41120to41200;
|
||||
import com.cloud.upgrade.dao.Upgrade452to453;
|
||||
import com.cloud.upgrade.dao.Upgrade453to460;
|
||||
import com.cloud.upgrade.dao.Upgrade460to461;
|
||||
@ -97,10 +97,11 @@ public class DatabaseUpgradeCheckerTest {
|
||||
assertTrue(upgrades.length >= 1);
|
||||
assertTrue(upgrades[0] instanceof Upgrade41000to41100);
|
||||
assertTrue(upgrades[1] instanceof Upgrade41100to41110);
|
||||
assertTrue(upgrades[2] instanceof Upgrade41110to41200);
|
||||
assertTrue(upgrades[2] instanceof Upgrade41110to41120);
|
||||
assertTrue(upgrades[3] instanceof Upgrade41120to41200);
|
||||
|
||||
assertTrue(Arrays.equals(new String[] {"4.11.0.0", "4.11.1.0"}, upgrades[1].getUpgradableVersionRange()));
|
||||
assertEquals(currentVersion.toString(), upgrades[2].getUpgradedVersion());
|
||||
assertEquals(currentVersion.toString(), upgrades[3].getUpgradedVersion());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -150,21 +150,6 @@ get_boot_params() {
|
||||
esac
|
||||
}
|
||||
|
||||
get_systemvm_type() {
|
||||
for str in $(cat $CMDLINE)
|
||||
do
|
||||
KEY=$(echo $str | cut -d= -f1)
|
||||
VALUE=$(echo $str | cut -d= -f2)
|
||||
case $KEY in
|
||||
type)
|
||||
export TYPE=$VALUE
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
patch() {
|
||||
local PATCH_MOUNT=/media/cdrom
|
||||
local patchfile=$PATCH_MOUNT/cloud-scripts.tgz
|
||||
@ -231,11 +216,11 @@ start() {
|
||||
|
||||
config_guest
|
||||
get_boot_params
|
||||
get_systemvm_type
|
||||
patch
|
||||
sync
|
||||
sysctl -p
|
||||
|
||||
export TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE)
|
||||
log_it "Configuring systemvm type=$TYPE"
|
||||
|
||||
if [ -f "/opt/cloud/bin/setup/$TYPE.sh" ]; then
|
||||
|
||||
@ -141,6 +141,11 @@ enable_fwding() {
|
||||
[ -f /etc/iptables/iptables.conf ] && sed -i "s/ENABLE_ROUTING=.*$/ENABLE_ROUTING=$enabled/" /etc/iptables/iptables.conf && return
|
||||
}
|
||||
|
||||
enable_passive_ftp() {
|
||||
log_it "cloud: enabling passive FTP for guest VMs"
|
||||
echo "$1" > /proc/sys/net/netfilter/nf_conntrack_helper
|
||||
}
|
||||
|
||||
disable_rpfilter() {
|
||||
log_it "cloud: disable rp_filter"
|
||||
log_it "disable rpfilter"
|
||||
@ -578,24 +583,13 @@ setup_ntp() {
|
||||
}
|
||||
|
||||
routing_svcs() {
|
||||
systemctl disable --now cloud
|
||||
systemctl disable --now nfs-common
|
||||
systemctl disable --now portmap
|
||||
systemctl enable apache2
|
||||
systemctl enable haproxy
|
||||
echo "haproxy apache2" > /var/cache/cloud/enabled_svcs
|
||||
echo "cloud nfs-common portmap" > /var/cache/cloud/disabled_svcs
|
||||
if [ "$RROUTER" -eq "1" ]
|
||||
then
|
||||
systemctl disable --now dnsmasq
|
||||
systemctl enable conntrackd
|
||||
systemctl enable keepalived
|
||||
echo "keepalived conntrackd" >> /var/cache/cloud/enabled_svcs
|
||||
echo "dnsmasq" >> /var/cache/cloud/disabled_svcs
|
||||
else
|
||||
systemctl disable --now conntrackd
|
||||
systemctl disable --now keepalived
|
||||
systemctl enable dnsmasq
|
||||
echo "dnsmasq" >> /var/cache/cloud/enabled_svcs
|
||||
echo "keepalived conntrackd " >> /var/cache/cloud/disabled_svcs
|
||||
fi
|
||||
|
||||
@ -21,48 +21,25 @@
|
||||
# Eject cdrom if any
|
||||
eject || true
|
||||
|
||||
# Setup router
|
||||
CMDLINE=/var/cache/cloud/cmdline
|
||||
for str in $(cat $CMDLINE)
|
||||
do
|
||||
KEY=$(echo $str | cut -d= -f1)
|
||||
VALUE=$(echo $str | cut -d= -f2)
|
||||
case $KEY in
|
||||
type)
|
||||
export TYPE=$VALUE
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
TYPE=$(grep -Po 'type=\K[a-zA-Z]*' $CMDLINE)
|
||||
if [ "$TYPE" == "router" ] || [ "$TYPE" == "vpcrouter" ] || [ "$TYPE" == "dhcpsrvr" ]
|
||||
then
|
||||
if [ -x /opt/cloud/bin/update_config.py ]
|
||||
then
|
||||
/opt/cloud/bin/update_config.py cmd_line.json || true
|
||||
logger -t cloud "postinit: Updated config cmd_line.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$TYPE" == "router" ]
|
||||
then
|
||||
python /opt/cloud/bin/baremetal-vr.py &
|
||||
logger -t cloud "Started baremetal-vr service"
|
||||
fi
|
||||
|
||||
[ ! -f /var/cache/cloud/enabled_svcs ] && touch /var/cache/cloud/enabled_svcs
|
||||
for svc in $(cat /var/cache/cloud/enabled_svcs)
|
||||
do
|
||||
logger -t cloud "Starting $svc"
|
||||
systemctl enable --no-block --now $svc
|
||||
systemctl enable --now --no-block $svc
|
||||
done
|
||||
|
||||
[ ! -f /var/cache/cloud/disabled_svcs ] && touch /var/cache/cloud/disabled_svcs
|
||||
for svc in $(cat /var/cache/cloud/disabled_svcs)
|
||||
do
|
||||
logger -t cloud "Stopping $svc"
|
||||
systemctl disable --no-block --now $svc
|
||||
systemctl disable --now --no-block $svc
|
||||
done
|
||||
|
||||
# Restore the persistent iptables nat, rules and filters for IPv4 and IPv6 if they exist
|
||||
@ -78,8 +55,12 @@ then
|
||||
ip6tables-restore < $ipv6
|
||||
fi
|
||||
|
||||
# Enable SSH by default
|
||||
systemctl enable --no-block --now ssh
|
||||
# Enable SSH
|
||||
systemctl enable --now --no-block ssh
|
||||
|
||||
date > /var/cache/cloud/boot_up_done
|
||||
logger -t cloud "Boot up process done"
|
||||
|
||||
if [ "$TYPE" == "router" ]
|
||||
then
|
||||
python /opt/cloud/bin/baremetal-vr.py &
|
||||
fi
|
||||
|
||||
@ -18,35 +18,46 @@
|
||||
|
||||
. /opt/cloud/bin/setup/common.sh
|
||||
|
||||
setup_router() {
|
||||
log_it "Setting up virtual router system vm"
|
||||
check_reboot_vmware() {
|
||||
if [ "$HYPERVISOR" != "vmware" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
#To save router public interface and gw ip information
|
||||
if [ -n "$MGMTNET" ]; then
|
||||
MGMT_GW=$(echo $MGMTNET | awk -F "." '{print $1"."$2"."$3".1"}')
|
||||
if ping -n -c 1 -W 3 $MGMT_GW &> /dev/null; then
|
||||
log_it "Management gateway pingable, skipping VR reboot"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
log_it "Management gateway not pingable, rebooting VR"
|
||||
sync
|
||||
reboot
|
||||
}
|
||||
|
||||
setup_router() {
|
||||
# To save router public interface and gw ip information
|
||||
touch /var/cache/cloud/ifaceGwIp
|
||||
|
||||
oldmd5=
|
||||
[ -f "/etc/udev/rules.d/70-persistent-net.rules" ] && oldmd5=$(md5sum "/etc/udev/rules.d/70-persistent-net.rules" | awk '{print $1}')
|
||||
|
||||
if [ -n "$ETH2_IP" ]
|
||||
then
|
||||
setup_common eth0 eth1 eth2
|
||||
if [ -n "$ETH2_IP" ]; then
|
||||
setup_common eth0 eth1 eth2
|
||||
|
||||
if [ -n "$EXTRA_PUBNICS" ]
|
||||
then
|
||||
for((i = 3; i < 3 + $EXTRA_PUBNICS; i++))
|
||||
do
|
||||
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
||||
done
|
||||
fi
|
||||
if [ -n "$EXTRA_PUBNICS" ]; then
|
||||
for ((i = 3; i < 3 + $EXTRA_PUBNICS; i++)); do
|
||||
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
||||
done
|
||||
fi
|
||||
else
|
||||
setup_common eth0 eth1
|
||||
if [ -n "$EXTRA_PUBNICS" ]
|
||||
then
|
||||
for((i = 2; i < 2 + $EXTRA_PUBNICS; i++))
|
||||
do
|
||||
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
||||
done
|
||||
fi
|
||||
if [ -n "$EXTRA_PUBNICS" ]; then
|
||||
for ((i = 2; i < 2 + $EXTRA_PUBNICS; i++)); do
|
||||
setup_interface "$i" "0.0.0.0" "255.255.255.255" $GW "force"
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
log_it "Checking udev NIC assignment order changes"
|
||||
@ -61,10 +72,7 @@ setup_router() {
|
||||
then
|
||||
log_it "Reloading udev for new udev NIC assignment"
|
||||
udevadm control --reload-rules && udevadm trigger
|
||||
if [ "$HYPERVISOR" == "vmware" ]; then
|
||||
sync
|
||||
reboot
|
||||
fi
|
||||
check_reboot_vmware
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -79,14 +87,15 @@ setup_router() {
|
||||
disable_rpfilter_domR
|
||||
enable_fwding 1
|
||||
enable_rpsrfs 1
|
||||
enable_passive_ftp 1
|
||||
cp /etc/iptables/iptables-router /etc/iptables/rules.v4
|
||||
setup_sshd $ETH1_IP "eth1"
|
||||
|
||||
#Only allow DNS service for current network
|
||||
# Only allow DNS service for current network
|
||||
sed -i "s/-A INPUT -i eth0 -p udp -m udp --dport 53 -j ACCEPT/-A INPUT -i eth0 -p udp -m udp --dport 53 -s $DHCP_RANGE\/$CIDR_SIZE -j ACCEPT/g" /etc/iptables/rules.v4
|
||||
sed -i "s/-A INPUT -i eth0 -p tcp -m tcp --dport 53 -j ACCEPT/-A INPUT -i eth0 -p tcp -m tcp --dport 53 -s $DHCP_RANGE\/$CIDR_SIZE -j ACCEPT/g" /etc/iptables/rules.v4
|
||||
|
||||
#setup hourly logrotate
|
||||
# Setup hourly logrotate
|
||||
mv -n /etc/cron.daily/logrotate /etc/cron.hourly 2>&1
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,7 @@ EOF
|
||||
enable_vpc_rpsrfs 1
|
||||
disable_rpfilter
|
||||
enable_fwding 1
|
||||
enable_passive_ftp 1
|
||||
cp /etc/iptables/iptables-vpcrouter /etc/iptables/rules.v4
|
||||
setup_sshd $ETH0_IP "eth0"
|
||||
cp /etc/vpcdnsmasq.conf /etc/dnsmasq.conf
|
||||
|
||||
@ -19,12 +19,12 @@
|
||||
set -e
|
||||
set -x
|
||||
|
||||
# Perform fsck check on every 2nd boot
|
||||
# Perform fsck check on every 3rd boot
|
||||
function fix_tune2fs() {
|
||||
for partition in $(blkid -o list | grep ext | awk '{print $1}')
|
||||
do
|
||||
tune2fs -m 0 $partition
|
||||
tune2fs -c 3 $partition
|
||||
tune2fs -c 4 $partition
|
||||
done
|
||||
fdisk -l
|
||||
df -h
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user