use of com.cloud.legacymodel.communication.command.ClusterVMMetaDataSyncCommand in project cosmic by MissionCriticalCloud.
the class NotAValidCommand method testClusterVMMetaDataSyncCommand.
@Test
public void testClusterVMMetaDataSyncCommand() {
final String uuid = "6172d8b7-ba10-4a70-93f9-ecaf41f51d53";
final Connection conn = Mockito.mock(Connection.class);
final XsHost xsHost = Mockito.mock(XsHost.class);
final Pool pool = PowerMockito.mock(Pool.class);
final Pool.Record poolr = Mockito.mock(Pool.Record.class);
final Host.Record hostr = Mockito.mock(Host.Record.class);
final Host master = Mockito.mock(Host.class);
final ClusterVMMetaDataSyncCommand vmDataSync = new ClusterVMMetaDataSyncCommand(10, 1l);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(this.citrixResourceBase.getConnection()).thenReturn(conn);
try {
when(this.citrixResourceBase.getHost()).thenReturn(xsHost);
when(this.citrixResourceBase.getHost().getUuid()).thenReturn(uuid);
when(xsHost.getPool()).thenReturn("pool");
PowerMockito.mockStatic(Pool.class);
when(Pool.getByUuid(conn, "pool")).thenReturn(pool);
PowerMockito.mockStatic(Pool.Record.class);
when(pool.getRecord(conn)).thenReturn(poolr);
poolr.master = master;
when(poolr.master.getRecord(conn)).thenReturn(hostr);
hostr.uuid = uuid;
} catch (final XenAPIException | XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(vmDataSync, this.citrixResourceBase);
verify(this.citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.ClusterVMMetaDataSyncCommand in project cosmic by MissionCriticalCloud.
the class VirtualMachineManagerImpl method processConnect.
@Override
public void processConnect(final Host agent, final StartupCommand[] startupCommands, final boolean forRebalance) throws ConnectionException {
for (final StartupCommand startupCommand : startupCommands) {
if (!(startupCommand instanceof StartupRoutingCommand)) {
return;
}
s_logger.debug("Received startup command from hypervisor host. host id: " + agent.getId());
_syncMgr.resetHostSyncState(agent.getId());
if (forRebalance) {
s_logger.debug("Not processing listener " + this + " as connect happens on rebalance process");
return;
}
final Long clusterId = agent.getClusterId();
final long agentId = agent.getId();
if (agent.getHypervisorType() == HypervisorType.XenServer) {
// only for Xen
// initiate the cron job
final ClusterVMMetaDataSyncCommand syncVMMetaDataCmd = new ClusterVMMetaDataSyncCommand(ClusterVMMetaDataSyncInterval.value(), clusterId);
try {
final long seq_no = _agentMgr.send(agentId, new Commands(syncVMMetaDataCmd), this);
s_logger.debug("Cluster VM metadata sync started with jobid " + seq_no);
} catch (final AgentUnavailableException e) {
s_logger.error("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e);
}
}
}
}
Aggregations