コード例 #1
0
  @Override
  public boolean mark(long dcId, Ip ip) {
    SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
    sc.setParameters("dataCenterId", dcId);
    sc.setParameters("ipAddress", ip);

    IPAddressVO vo = createForUpdate();
    vo.setAllocatedTime(new Date());
    vo.setState(State.Allocated);

    return update(vo, sc) >= 1;
  }
コード例 #2
0
  @Override
  @DB
  public IPAddressVO markAsUnavailable(long ipAddressId) {
    SearchCriteria<IPAddressVO> sc = AllFieldsSearch.create();
    sc.setParameters("id", ipAddressId);

    IPAddressVO ip = createForUpdate();
    ip.setState(State.Releasing);
    if (update(ip, sc) != 1) {
      return null;
    }

    return findOneBy(sc);
  }
コード例 #3
0
 @Override
 public void unassignIpAddress(long ipAddressId) {
   IPAddressVO address = createForUpdate();
   address.setAllocatedToAccountId(null);
   address.setAllocatedInDomainId(null);
   address.setAllocatedTime(null);
   address.setSourceNat(false);
   address.setOneToOneNat(false);
   address.setAssociatedWithVmId(null);
   address.setState(State.Free);
   address.setAssociatedWithNetworkId(null);
   address.setVpcId(null);
   address.setSystem(false);
   address.setVmIp(null);
   address.setDisplay(true);
   update(ipAddressId, address);
 }