コード例 #1
0
 protected long getServiceNetworkId(Service service) {
   Network network = ntwkDao.getNetworkForObject(service, NetworkConstants.KIND_HOSTONLY);
   if (network == null) {
     throw new RuntimeException(
         "Unable to find a network to activate a service " + service.getId());
   }
   long networkId = network.getId();
   return networkId;
 }
コード例 #2
0
  protected List<HostInstanceIpData> getHostContainerIpData(long accountId) {
    Network hostNtwk =
        objManager.findAny(
            Network.class,
            NETWORK.ACCOUNT_ID,
            accountId,
            NETWORK.REMOVED,
            null,
            NETWORK.KIND,
            "dockerHost");
    if (hostNtwk == null) {
      return new ArrayList<HostInstanceIpData>();
    }
    MultiRecordMapper<HostInstanceIpData> mapper =
        new MultiRecordMapper<HostInstanceIpData>() {
          @Override
          protected HostInstanceIpData map(List<Object> input) {
            HostInstanceIpData data = new HostInstanceIpData();
            data.setIpAddress((IpAddress) input.get(0));
            data.setInstanceHostMap((InstanceHostMap) input.get(1));
            return data;
          }
        };

    IpAddressTable ipAddress = mapper.add(IP_ADDRESS);
    InstanceHostMapTable instanceHostMap = mapper.add(INSTANCE_HOST_MAP);
    return create()
        .select(mapper.fields())
        .from(HOST_IP_ADDRESS_MAP)
        .join(instanceHostMap)
        .on(HOST_IP_ADDRESS_MAP.HOST_ID.eq(instanceHostMap.HOST_ID))
        .join(NIC)
        .on(NIC.INSTANCE_ID.eq(instanceHostMap.INSTANCE_ID))
        .join(ipAddress)
        .on(HOST_IP_ADDRESS_MAP.IP_ADDRESS_ID.eq(ipAddress.ID))
        .where(instanceHostMap.REMOVED.isNull())
        .and(NIC.REMOVED.isNull())
        .and(HOST_IP_ADDRESS_MAP.REMOVED.isNull())
        .and(ipAddress.REMOVED.isNull())
        .and(NIC.NETWORK_ID.eq(hostNtwk.getId()))
        .fetch()
        .map(mapper);
  }