예제 #1
0
 @Override
 public List<Port> getUsedPortsForHostExcludingInstance(long hostId, long instanceId) {
   return create()
       .select(PORT.fields())
       .from(PORT)
       .join(INSTANCE_HOST_MAP)
       .on(PORT.INSTANCE_ID.eq(INSTANCE_HOST_MAP.INSTANCE_ID))
       .join(INSTANCE)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .leftOuterJoin(SERVICE_EXPOSE_MAP)
       .on(SERVICE_EXPOSE_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE_HOST_MAP
               .HOST_ID
               .eq(hostId)
               .and(INSTANCE.REMOVED.isNull())
               .and(INSTANCE.ID.ne(instanceId))
               .and(
                   INSTANCE.STATE.in(
                       InstanceConstants.STATE_STARTING,
                       InstanceConstants.STATE_RESTARTING,
                       InstanceConstants.STATE_RUNNING))
               .and(INSTANCE_HOST_MAP.REMOVED.isNull())
               .and(PORT.REMOVED.isNull())
               .and(SERVICE_EXPOSE_MAP.UPGRADE.eq(false).or(SERVICE_EXPOSE_MAP.UPGRADE.isNull())))
       .fetchInto(Port.class);
 }
예제 #2
0
 @Override
 public boolean isInstanceImageKind(long instanceId, String kind) {
   return create()
           .select(STORAGE_POOL.fields())
           .from(STORAGE_POOL)
           .join(IMAGE_STORAGE_POOL_MAP)
           .on(STORAGE_POOL.ID.eq(IMAGE_STORAGE_POOL_MAP.STORAGE_POOL_ID))
           .join(IMAGE)
           .on(IMAGE.ID.eq(IMAGE_STORAGE_POOL_MAP.IMAGE_ID))
           .join(INSTANCE)
           .on(INSTANCE.IMAGE_ID.eq(IMAGE.ID))
           .where(
               INSTANCE
                   .ID
                   .eq(instanceId)
                   .and(IMAGE_STORAGE_POOL_MAP.REMOVED.isNull())
                   .and(STORAGE_POOL.KIND.eq(kind)))
           .fetch()
           .size()
       > 0;
 }
예제 #3
0
 @Override
 public List<Long> getInstancesWithVolumeMounted(long volumeId, long currentInstanceId) {
   return create()
       .select(INSTANCE.ID)
       .from(INSTANCE)
       .join(MOUNT)
       .on(MOUNT.INSTANCE_ID.eq(INSTANCE.ID).and(MOUNT.VOLUME_ID.eq(volumeId)))
       .join(INSTANCE_HOST_MAP)
       .on(INSTANCE_HOST_MAP.INSTANCE_ID.eq(INSTANCE.ID))
       .where(
           INSTANCE
               .REMOVED
               .isNull()
               .and(INSTANCE.ID.ne(currentInstanceId))
               .and(INSTANCE_HOST_MAP.STATE.notIn(IHM_STATES))
               .and(
                   (INSTANCE
                       .HEALTH_STATE
                       .isNull()
                       .or(INSTANCE.HEALTH_STATE.eq(HealthcheckConstants.HEALTH_STATE_HEALTHY)))))
       .fetchInto(Long.class);
 }