class AdministrationAgent implements InitializingBean {

    protected void migrateVM(VMInstanceVO vm, HostVO host) {
        long vmId = vm.getId();
        long targetHostId = host.getId();
        Long sourceHostId = vm.getHostId();
        if (sourceHostId == targetHostId) {
            logger.debug(String.format("VM [id=%d] is not being migrated hence it was mapped to the host it is running.", vmId));
            return;
        }
        try {
            logger.info(String.format("VM [id=%d] is migrating from host[Id=%d] to host[Id=%d].", vmId, sourceHostId, targetHostId));
            userVmService.migrateVirtualMachine(vmId, host);
            logger.info(String.format("VM [id=%d] was migrated from host[Id=%d] to host[Id=%d].", vmId, sourceHostId, targetHostId));
        } catch (Exception e) {
            logger.debug(String.format("Could not migrate VM [id=%d] to host [id=%d, hostName=%s], from host [id=%d]", vmId, targetHostId, host.getName(), sourceHostId), e);
        }
    }

}