String errMsg = this.getClass().getName() + " requires configure() be called before" + " initialize()";
s_logger.error(errMsg);
}
// Create default StartupRoutingCommand, then customise
StartupRoutingCommand defaultStartRoutCmd =
new StartupRoutingCommand(0, 0, 0, 0, null, Hypervisor.HypervisorType.Hyperv, RouterPrivateIpStrategy.HostLocal, new HashMap<String, VmState>(),
new HashMap<String, HostVmStateReportEntry>());
// Identity within the data centre is decided by CloudStack kernel,
// and passed via ServerResource.configure()
defaultStartRoutCmd.setDataCenter(_zoneId);
defaultStartRoutCmd.setPod(_podId);
defaultStartRoutCmd.setCluster(_clusterId);
defaultStartRoutCmd.setGuid(_guid);
defaultStartRoutCmd.setName(_name);
defaultStartRoutCmd.setPrivateIpAddress(_agentIp);
defaultStartRoutCmd.setStorageIpAddress(_agentIp);
defaultStartRoutCmd.setPool(_clusterGuid);
defaultStartRoutCmd.setHostVmStateReport(getHostVmStateReport());
s_logger.debug("Generated StartupRoutingCommand for _agentIp \"" + _agentIp + "\"");
defaultStartRoutCmd.setVersion(this.getClass().getPackage().getImplementationVersion());
// Specifics of the host's resource capacity and network configuration
// comes from the host itself. CloudStack sanity checks network
// configuration
// and uses capacity info for resource allocation.
Command[] startCmds = requestStartupCommand(new Command[] {defaultStartRoutCmd});
// TODO: may throw, is this okay?
StartupRoutingCommand startCmd = (StartupRoutingCommand)startCmds[0];
// Assert that host identity is consistent with existing values.
if (startCmd == null) {
String errMsg = String.format("Host %s (IP %s)" + "did not return a StartupRoutingCommand", _name, _agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getDataCenter().equals(defaultStartRoutCmd.getDataCenter())) {
String errMsg =
String.format("Host %s (IP %s) changed zone/data center. Was " + defaultStartRoutCmd.getDataCenter() + " NOW its " + startCmd.getDataCenter(), _name,
_agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getPod().equals(defaultStartRoutCmd.getPod())) {
String errMsg = String.format("Host %s (IP %s) changed pod. Was " + defaultStartRoutCmd.getPod() + " NOW its " + startCmd.getPod(), _name, _agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getCluster().equals(defaultStartRoutCmd.getCluster())) {
String errMsg =
String.format("Host %s (IP %s) changed cluster. Was " + defaultStartRoutCmd.getCluster() + " NOW its " + startCmd.getCluster(), _name, _agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getGuid().equals(defaultStartRoutCmd.getGuid())) {
String errMsg = String.format("Host %s (IP %s) changed guid. Was " + defaultStartRoutCmd.getGuid() + " NOW its " + startCmd.getGuid(), _name, _agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getPrivateIpAddress().equals(defaultStartRoutCmd.getPrivateIpAddress())) {
String errMsg =
String.format("Host %s (IP %s) IP address. Was " + defaultStartRoutCmd.getPrivateIpAddress() + " NOW its " + startCmd.getPrivateIpAddress(), _name,
_agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}
if (!startCmd.getName().equals(defaultStartRoutCmd.getName())) {
String errMsg = String.format("Host %s (IP %s) name. Was " + startCmd.getName() + " NOW its " + defaultStartRoutCmd.getName(), _name, _agentIp);
s_logger.error(errMsg);
// TODO: valid to return null, or should we throw?
return null;
}