@Override public Map<String, PhysicalHost> getPhysicalHosts(long agentId) { Map<String,PhysicalHost> hosts = new HashMap<>(); List<? extends PhysicalHost> hostList = create() .select(PHYSICAL_HOST.fields()) .from(PHYSICAL_HOST) .where( PHYSICAL_HOST.AGENT_ID.eq(agentId) .and(PHYSICAL_HOST.REMOVED.isNull())) .fetchInto(PhysicalHostRecord.class); for ( PhysicalHost host : hostList ) { String uuid = host.getExternalId(); if (StringUtils.isEmpty(uuid)) { uuid = DataAccessor.fields(host).withKey(HostConstants.FIELD_REPORTED_UUID).as(String.class); } if (StringUtils.isEmpty(uuid)) { uuid = host.getUuid(); } hosts.put(uuid, host); } return hosts; }
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.PhysicalHost from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind()); setUuid(from.getUuid()); setDescription(from.getDescription()); setState(from.getState()); setCreated(from.getCreated()); setRemoved(from.getRemoved()); setRemoveTime(from.getRemoveTime()); setData(from.getData()); setAgentId(from.getAgentId()); setExternalId(from.getExternalId()); setDriver(from.getDriver()); }