io.cattle.platform.core.model.Instance.getUuid()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中io.cattle.platform.core.model.Instance.getUuid()方法的一些代码示例,展示了Instance.getUuid()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instance.getUuid()方法的具体详情如下:
包路径:io.cattle.platform.core.model.Instance
类名称:Instance
方法名:getUuid

Instance.getUuid介绍

[英]Getter for cattle.instance.uuid.
[中]

代码示例

代码示例来源:origin: rancher/cattle

public static String getInstanceName(Instance instance) {
  if (instance != null && instance.getRemoved() == null) {
    return instance.getUuid();
  } else {
    return null;
  }
}

代码示例来源:origin: rancher/cattle

/**
   * The docker API allows for identification of a container by name or id.
   * This method will return the docker container id (which is stored in the
   * externalId field of the instance) if it is available. If it isn't
   * available, the instance uuid will be returned, since that is currently
   * used as the name for docker containers that do not have the docker id
   * set.
   * 
   * @param instance
   * @return A string suitable for identifying a container in the docker API.
   */
  public static String getDockerIdentifier(Instance instance) {
    return !StringUtils.isEmpty(instance.getExternalId()) ? instance.getExternalId() : instance.getUuid();
  }
}

代码示例来源:origin: rancher/cattle

@Override
public Map<String, Object> getOsMetadata(Instance instance, Map<String, Object> metadata) {
  Map<String, Object> data = new HashMap<>();
  data.put("availability_zone", "nova");
  data.put("files", Collections.EMPTY_LIST);
  data.put("public_keys", new HashMap<>());
  data.put("meta", new HashMap<>());
  data.put("uuid", instance.getUuid());
  String hostname = org.apache.commons.lang3.ObjectUtils.toString(metadata.get("hostname"), null);
  if (hostname != null) {
    data.put("hostname", hostname);
    data.put("name", hostname.split("[.]")[0]);
  }
  Map<String, Object> keys = CollectionUtils.toMap(metadata.get("public-keys"));
  for (Map.Entry<String, Object> entry : keys.entrySet()) {
    Map<String, Object> value = CollectionUtils.toMap(entry.getValue());
    String name = entry.getKey();
    if (name.contains("=")) {
      name = name.split("=", 2)[1];
      keys.put(name, value.get("openssh-key"));
    }
  }
  return data;
}

代码示例来源:origin: rancher/cattle

@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;
  }
}

代码示例来源:origin: rancher/cattle

protected void setSecrets(Instance instance, Map<Object, Object> data) {
  List<SecretReference> secrets = DataAccessor.fieldObjectList(instance, InstanceConstants.FIELD_SECRETS,
      SecretReference.class, jsonMapper);
  if (secrets == null || secrets.isEmpty()) {
    return;
  }
  StorageDriver driver = storageDriverDao.findSecretsDriver(instance.getAccountId());
  if (driver == null) {
    return;
  }
  String token = tokenService.generateToken(CollectionUtils.asMap("uuid", instance.getUuid()),
      new Date(System.currentTimeMillis() + 31556926000L));
  try {
    Volume vol = storageDriverDao.createSecretsVolume(instance, driver, token);
    create(vol, null);
  } catch (ProcessCancelException e) {
    // ignore
  }
}

代码示例来源:origin: rancher/cattle

uuidPart = svc.getUuid().substring(0, 7);
} else {
  uuidPart = instance.getUuid().substring(0, 7);

代码示例来源:origin: rancher/cattle

private ResourceRequest populateResourceRequestFromInstanceForPort(Instance instance, String resourceType, String poolType,
    String schedulerVersion, List<Port> newPorts) {
  PortBindingResourceRequest request = new PortBindingResourceRequest();
  if (useLegacyPortAllocation(schedulerVersion)) {
    return null;
  }
  request.setResource(resourceType);
  request.setInstanceId(instance.getId().toString());
  request.setResourceUuid(instance.getUuid());
  List<PortSpec> portReservation = new ArrayList<>();
  for (Port port : newPorts) {
    PortSpec spec = new PortSpec();
    String bindAddress = DataAccessor.fieldString(port, BIND_ADDRESS);
    if (bindAddress != null) {
      spec.setIpAddress(bindAddress);
    }
    spec.setPrivatePort(port.getPrivatePort());
    spec.setPublicPort(port.getPublicPort());
    String proto = StringUtils.isEmpty(port.getProtocol()) ? "tcp" : port.getProtocol();
    spec.setProtocol(proto);
    portReservation.add(spec);
  }
  if (portReservation.isEmpty()) {
    return null;
  }
  request.setPortRequests(portReservation);
  request.setType(poolType);
  return request;
}

代码示例来源:origin: rancher/cattle

Account account, InstanceHealthCheck healthCheck) {
this.name = instance.getName();
this.uuid = instance.getUuid();
this.external_id = instance.getExternalId();
this.system = instance.getSystem();

代码示例来源:origin: rancher/cattle

request.setResource(resourceType);
request.setInstanceId(instance.getId().toString());
request.setResourceUuid(instance.getUuid());
List<PortSpec> portReservation = new ArrayList<>();
for(Port port: objectManager.children(instance, Port.class)) {

代码示例来源:origin: rancher/cattle

setAccountId(from.getAccountId());
setKind(from.getKind());
setUuid(from.getUuid());
setDescription(from.getDescription());
setState(from.getState());

相关文章