@Override protected Object getAgentResource(ProcessState state, ProcessInstance process, Object dataResource) { Stack env = (Stack)state.getResource(); if (!DockerConstants.TYPE_COMPOSE_PROJECT.equals(env.getKind())) { return null; } Long accountId = env.getAccountId(); List<Long> agentIds = agentInstanceDao.getAgentProvider(SystemLabels.LABEL_AGENT_SERVICE_COMPOSE_PROVIDER, accountId); return agentIds.size() == 0 ? null : agentIds.get(0); }
@Override protected Object getAgentResource(ProcessState state, ProcessInstance process, Object dataResource) { Stack env = (Stack)state.getResource(); if (!stackKind.equals(env.getKind())) { return null; } Long accountId = env.getAccountId(); List<Long> agentIds = agentInstanceDao.getAgentProvider(agentService, accountId); return agentIds.size() == 0 ? null : agentIds.get(0); }
protected List<Stack> getStacksToCleanup(Stack systemStack, String systemStackType) { List<Stack> all = objectManager.find(Stack.class, STACK.ACCOUNT_ID, systemStack.getAccountId(), STACK.REMOVED, null); if (all.isEmpty()) { return new ArrayList<>(); } List<Stack> toCleanup = new ArrayList<>(); List<String> stackExternalIdPrefixes = STACKS_TO_CLEANUP_EXTERNAL_ID.get(systemStackType); for (Stack stack : all) { boolean removeByExternalId = false; if (stack.getExternalId() != null && stackExternalIdPrefixes != null) { for (String prefix : stackExternalIdPrefixes) { if (stack.getExternalId().startsWith(prefix)) { toCleanup.add(stack); removeByExternalId = true; break; } } if (removeByExternalId) { continue; } if (STACKS_TO_CLEANUP_KIND.get(systemStackType) != null && STACKS_TO_CLEANUP_KIND.get(systemStackType).contains(stack.getKind())) { toCleanup.add(stack); } } } return toCleanup; }
/** * {@inheritDoc} */ @Override public void from(io.cattle.platform.core.model.Stack 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()); setExternalId(from.getExternalId()); setHealthState(from.getHealthState()); setGroup(from.getGroup()); setSystem(from.getSystem()); }