public static boolean isRancherAgent(Instance instance) { Map<String, Object> labels = DataAccessor.fieldMap(instance, InstanceConstants.FIELD_LABELS); return ("rancher-agent".equals(labels.get("io.rancher.container.system")) && "rancher-agent".equals(instance.getName())); }
@Override public List<Integer> getServiceInstanceUsedSuffixes(Service service, String launchConfigName) { Stack env = objectManager.findOne(Stack.class, STACK.ID, service.getStackId()); // get all existing instances to check if the name is in use by the instance of the same service List<Integer> usedSuffixes = new ArrayList<>(); List<? extends Instance> serviceInstances = exposeMapDao.listServiceManagedInstances(service, launchConfigName); for (Instance instance : serviceInstances) { if (ServiceDiscoveryUtil.isServiceGeneratedName(env, service, instance.getName())) { // legacy code - to support old data where service suffix wasn't set usedSuffixes.add(Integer.valueOf(ServiceDiscoveryUtil.getServiceSuffixFromInstanceName(instance .getName()))); } } return usedSuffixes; }
@Override public boolean matches(AllocationCandidate candidate) { if (candidate.getHost() == null) { return false; } if (op == AffinityOps.SOFT_EQ || op == AffinityOps.EQ) { List<? extends Instance> instances = instanceDao.getNonRemovedInstanceOn(candidate.getHost()); for (Instance instance : instances) { if (containerIdentifier != null && (containerIdentifier.equalsIgnoreCase(instance.getName()) || containerIdentifier.equalsIgnoreCase(instance.getUuid()))) { return true; } } return false; } else { List<? extends Instance> instances = instanceDao.getNonRemovedInstanceOn(candidate.getHost()); for (Instance instance : instances) { if (containerIdentifier != null && (containerIdentifier.equals(instance.getName()) || containerIdentifier.equals(instance.getUuid()))) { return false; } } return true; } }
service, serviceContainer.getName(), serviceContainer, launchConfigName);
Object objectDisks = DataAccessor.field(instance, InstanceConstants.FIELD_DISKS, Object.class); if (objectDisks instanceof List<?>) { String namePrefix = instance.getName(); Long svcIndexId = instance.getServiceIndexId();
@SuppressWarnings("unchecked") public void setInstanceAndHostMetadata(Instance instance, HostMetaData host, List<String> healthcheckHosts, Account account, InstanceHealthCheck healthCheck) { this.name = instance.getName(); this.uuid = instance.getUuid(); this.external_id = instance.getExternalId();
public void from(io.cattle.platform.core.model.Instance from) { setId(from.getId()); setName(from.getName()); setAccountId(from.getAccountId()); setKind(from.getKind());