Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
static final String RouterTemplateLxcCK = "router.template.lxc";
static final String SetServiceMonitorCK = "network.router.EnableServiceMonitoring";
static final String RouterAlertsCheckIntervalCK = "router.alerts.check.interval";
static final String RouterReprovisionOnOutOfBandMigrationCK = "router.reboot.when.migrated";

static final ConfigKey<String> RouterTemplateXen = new ConfigKey<String>(String.class, RouterTemplateXenCK, "Advanced", "SystemVM Template (XenServer)",
"Name of the default router template on Xenserver.", true, ConfigKey.Scope.Zone, null);
Expand All @@ -63,12 +64,16 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
"Name of the default router template on Hyperv.", true, ConfigKey.Scope.Zone, null);
static final ConfigKey<String> RouterTemplateLxc = new ConfigKey<String>(String.class, RouterTemplateLxcCK, "Advanced", "SystemVM Template (LXC)",
"Name of the default router template on LXC.", true, ConfigKey.Scope.Zone, null);

static final ConfigKey<String> SetServiceMonitor = new ConfigKey<String>(String.class, SetServiceMonitorCK, "Advanced", "true",
"service monitoring in router enable/disable option, default true", true, ConfigKey.Scope.Zone, null);

static final ConfigKey<Integer> RouterAlertsCheckInterval = new ConfigKey<Integer>(Integer.class, RouterAlertsCheckIntervalCK, "Advanced", "1800",
"Interval (in seconds) to check for alerts in Virtual Router.", false, ConfigKey.Scope.Global, null);
static final ConfigKey<Boolean> routerVersionCheckEnabled = new ConfigKey<Boolean>("Advanced", Boolean.class, "router.version.check", "true",
"If true, router minimum required version is checked before sending command", false);
static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
"Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);
static final ConfigKey<Boolean> RouterReprovisionOnOutOfBandMigration = new ConfigKey<Boolean>(Boolean.class, RouterReprovisionOnOutOfBandMigrationCK, "Advanced", "false",
"Reboot routers when they are migrated out of band in order to reprovision", true, ConfigKey.Scope.Zone, null);

public static final int DEFAULT_ROUTER_VM_RAMSIZE = 256; // 256M
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,6 @@ public VirtualRouter rebootRouter(final long routerId, final boolean reprogramNe
}
}

static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
"Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);

static final ConfigKey<Boolean> routerVersionCheckEnabled = new ConfigKey<Boolean>("Advanced", Boolean.class, "router.version.check", "true",
"If true, router minimum required version is checked before sending command", false);


@Override
public boolean configure(final String name, final Map<String, Object> params) throws ConfigurationException {

Expand Down Expand Up @@ -4394,7 +4387,7 @@ public String getConfigComponentName() {

@Override
public ConfigKey<?>[] getConfigKeys() {
return new ConfigKey<?>[] {UseExternalDnsServers, routerVersionCheckEnabled, SetServiceMonitor, RouterAlertsCheckInterval};
return new ConfigKey<?>[] {UseExternalDnsServers, routerVersionCheckEnabled, SetServiceMonitor, RouterAlertsCheckInterval, RouterReprovisionOnOutOfBandMigration};
}

@Override
Expand All @@ -4404,25 +4397,34 @@ public boolean preStateTransitionEvent(State oldState, VirtualMachine.Event even

@Override
public boolean postStateTransitionEvent(State oldState, VirtualMachine.Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
if (event == VirtualMachine.Event.FollowAgentPowerOnReport && newState == State.Running) {
if (vo.getType() == VirtualMachine.Type.DomainRouter) {
if (opaque != null && opaque instanceof Pair<?, ?>) {
Pair<?, ?> pair = (Pair<?, ?>)opaque;
Object first = pair.first();
Object second = pair.second();
if (first != null && second != null && first instanceof Long && second instanceof Long) {
Long hostId = (Long)first;
Long powerHostId = (Long)second;
// If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
if (hostId.longValue() != powerHostId.longValue()) {
s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules");
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
}
}
// if (vm is a router) and ((vm was stopped before) or (reprovision on out of band migration is true)) and (vm is running)
boolean reprovision_out_of_band = RouterReprovisionOnOutOfBandMigration.value();
if (
(vo.getType() == VirtualMachine.Type.DomainRouter) &&
((oldState == State.Stopped) || (reprovision_out_of_band && isOutOfBandMigrated(opaque))) &&
(event == VirtualMachine.Event.FollowAgentPowerOnReport) &&
(newState == State.Running)) {
s_logger.info("Schedule a router reboot task as router " + vo.getId() + " is powered-on out-of-band. we need to reboot to refresh network rules");
_executor.schedule(new RebootTask(vo.getId()), 1000, TimeUnit.MICROSECONDS);
}
return true;
}

private boolean isOutOfBandMigrated(Object opaque) {
if (opaque != null && opaque instanceof Pair<?, ?>) {
Pair<?, ?> pair = (Pair<?, ?>)opaque;
Object first = pair.first();
Object second = pair.second();
if (first != null && second != null && first instanceof Long && second instanceof Long) {
Long hostId = (Long)first;
Long powerHostId = (Long)second;
// If VM host known to CS is different from 'PowerOn' report host, then it is out-of-band movement
if (hostId.longValue() != powerHostId.longValue()) {
return true;
}
}
}
return true;
return false;
}

protected class RebootTask extends ManagedContextRunnable {
Expand Down