use of com.cloud.agent.api.ClusterVMMetaDataSyncCommand in project cloudstack by apache.
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(citrixResourceBase.getConnection()).thenReturn(conn);
try {
when(citrixResourceBase.getHost()).thenReturn(xsHost);
when(citrixResourceBase.getHost().getUuid()).thenReturn(uuid);
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 BadServerResponse e) {
fail(e.getMessage());
} catch (final XenAPIException e) {
fail(e.getMessage());
} catch (final XmlRpcException e) {
fail(e.getMessage());
}
final Answer answer = wrapper.execute(vmDataSync, citrixResourceBase);
verify(citrixResourceBase, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.cloud.agent.api.ClusterVMMetaDataSyncCommand in project cloudstack by apache.
the class VirtualMachineManagerImpl method processConnect.
@Override
public void processConnect(final Host agent, final StartupCommand cmd, final boolean forRebalance) throws ConnectionException {
if (!(cmd instanceof StartupRoutingCommand)) {
return;
}
if (s_logger.isDebugEnabled()) {
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.fatal("The Cluster VM metadata sync process failed for cluster id " + clusterId + " with ", e);
}
}
}
Aggregations