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

x33g5p2x  于2022-01-16 转载在 其他  
字(3.4k)|赞(0)|评价(0)|浏览(124)

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

Account.getDefaultNetworkId介绍

[英]Getter for cattle.account.default_network_id.
[中]cattle.account.default_network_id的Getter。

代码示例

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

@Override
public Network getDefaultNetwork(Long accountId) {
  Account account = objectManager.loadResource(Account.class, accountId);
  if (account == null) {
    return null;
  }
  return objectManager.loadResource(Network.class, account.getDefaultNetworkId());
}

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

protected void setDefaultNetwork(Long accountId) {
  Account account = objectManager.loadResource(Account.class, accountId);
  if (account == null) {
    return;
  }
  Long defaultNetworkId = account.getDefaultNetworkId();
  Long newDefaultNetworkId = null;
  for (Network network : networkDao.getActiveNetworks(account.getId())) {
    if (network.getKind().startsWith(NetworkConstants.PREFIX_KIND_DOCKER) ||
        network.getKind().equals("hostOnlyNetwork")) {
      continue;
    }
    if (network.getId().equals(defaultNetworkId)) {
      newDefaultNetworkId = defaultNetworkId;
      break;
    }
    if ((CommonStatesConstants.ACTIVATING.equals(network.getState()) ||
        CommonStatesConstants.UPDATING_ACTIVE.equals(network.getState())) &&
        newDefaultNetworkId == null) {
      newDefaultNetworkId = network.getId();
    } else if (CommonStatesConstants.ACTIVE.equals(network.getState())) {
      newDefaultNetworkId = network.getId();
    }
  }
  if (!ObjectUtils.equals(defaultNetworkId, newDefaultNetworkId)) {
    objectManager.setFields(account, AccountConstants.FIELD_DEFAULT_NETWORK_ID, newDefaultNetworkId);
  }
}

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

private void fetchNetwork(final MetaHelperInfo helperInfo, final OutputStream os,
    Record5<String, String, Long, Long, Map<String, Object>> record) {
  String name = record.getValue(NETWORK.NAME);
  String uuid = record.getValue(NETWORK.UUID);
  Long accountId = record.getValue(NETWORK.ACCOUNT_ID);
  Long id = record.getValue(NETWORK.ID);
  Map<String, Object> data = record.getValue(NETWORK.DATA);
  NetworkRecord ntwk = new NetworkRecord();
  ntwk.setData(data);
  Map<String, Object> meta = DataAccessor.fieldMap(ntwk, ServiceConstants.FIELD_METADATA);
  Account account = helperInfo.getAccounts().get(accountId);
  boolean isDefault = account.getDefaultNetworkId() == null ? false : account
      .getDefaultNetworkId().equals(id);
  boolean host_ports = DataAccessor.fieldBool(ntwk, NetworkConstants.FIELD_HOST_PORTS);
  Object policy = DataAccessor.field(ntwk, NetworkConstants.FIELD_POLICY, Object.class);
  String dpa = DataAccessor.fieldString(ntwk, NetworkConstants.FIELD_DEFAULT_POLICY_ACTION);
  NetworkMetaData ntwkMeta = new NetworkMetaData(name, uuid, host_ports, isDefault, meta, dpa, policy, account);
  writeToJson(os, ntwkMeta);
}

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

/**
 * {@inheritDoc}
 */
@Override
public void from(io.cattle.platform.core.model.Account from) {
  setId(from.getId());
  setName(from.getName());
  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());
  setExternalIdType(from.getExternalIdType());
  setHealthState(from.getHealthState());
  setProjectTemplateId(from.getProjectTemplateId());
  setDefaultNetworkId(from.getDefaultNetworkId());
  setVersion(from.getVersion());
  setRevision(from.getRevision());
}

相关文章