Package com.cloud.stack.models

Examples of com.cloud.stack.models.CloudStackIpAddress


   * @param request
   * @return
   */
  public boolean disassociateAddress( EC2DisassociateAddress request ) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackInfoResponse resp = getApi().disassociateIpAddress(cloudIp.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error( "EC2 DisassociateAddress - ", e);
View Full Code Here


//            CloudStackAccount caller = getCurrentAccount();
           
            CloudStackZone zone = findZone();
            CloudStackNetwork net = findNetwork(zone);
//      CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
            CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), null, null, net.getId());
      ec2Address.setAssociatedInstanceId(resp.getId());
      if (resp.getIpAddress() == null) {
          List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
          if (addrList != null && addrList.size() > 0) {
              for (CloudStackIpAddress addr: addrList) {
                  if (addr.getId().equalsIgnoreCase(resp.getId())) {
                      ec2Address.setIpAddress(addr.getIpAddress());
                  }
              }
          }
      } else {
          ec2Address.setIpAddress(resp.getIpAddress());
      }

      return ec2Address;
    } catch(Exception e) {
      logger.error( "EC2 AllocateAddress - ", e);
View Full Code Here

    public boolean releaseAddress(EC2ReleaseAddress request) {
        try {
            List<CloudStackIpAddress> cloudIps = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null);
            if (cloudIps == null)
                throw new EC2ServiceException(ServerError.InternalError, "Specified ipAddress doesn't exist");
            CloudStackIpAddress cloudIp = cloudIps.get(0);
            CloudStackInfoResponse resp = getApi().disassociateIpAddress(cloudIp.getId());
            if (resp != null) {
                return resp.getSuccess();
            }
        } catch(Exception e) {
            logger.error("EC2 ReleaseAddress - ", e);
View Full Code Here

    public boolean associateAddress( EC2AssociateAddress request ) {
        try {
            List<CloudStackIpAddress> cloudIps = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null);
            if (cloudIps == null)
                throw new EC2ServiceException(ServerError.InternalError, "Specified ipAddress doesn't exist");
            CloudStackIpAddress cloudIp = cloudIps.get(0);

            List<CloudStackUserVm> vmList = getApi().listVirtualMachines(null, null, true, null, null, null, null,
                    request.getInstanceId(), null, null, null, null, null, null, null, null, null);
            if (vmList == null || vmList.size() == 0) {
                throw new EC2ServiceException(ServerError.InternalError, "Specified instance-id doesn't exist");
            }
            CloudStackUserVm cloudVm = vmList.get(0);

            CloudStackInfoResponse resp = getApi().enableStaticNat(cloudIp.getId(), cloudVm.getId());
            if (resp != null) {
                return resp.getSuccess();
            }
        } catch(Exception e) {
            logger.error( "EC2 AssociateAddress - ", e);
View Full Code Here

    public boolean disassociateAddress( EC2DisassociateAddress request ) {
        try {
            List<CloudStackIpAddress> cloudIps = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null);
            if (cloudIps == null)
                throw new EC2ServiceException(ServerError.InternalError, "Specified ipAddress doesn't exist");
            CloudStackIpAddress cloudIp = cloudIps.get(0);

            CloudStackInfoResponse resp = getApi().disableStaticNat(cloudIp.getId());
            if (resp != null) {
                return resp.getSuccess();
            }
        } catch(Exception e) {
            logger.error( "EC2 DisassociateAddress - ", e);
View Full Code Here

            CloudStackAccount caller = getCurrentAccount();

            CloudStackZone zone = findZone();
            CloudStackNetwork net = findNetwork(zone);
//      CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
            CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), caller.getName(), caller.getDomainId(), net != null ? net.getId():null);
            ec2Address.setAssociatedInstanceId(resp.getId());

            if (resp.getIpAddress() == null) {
                List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
                if (addrList != null && addrList.size() > 0) {
                    for (CloudStackIpAddress addr: addrList) {
                        if (addr.getId().equalsIgnoreCase(resp.getId())) {
                            ec2Address.setIpAddress(addr.getIpAddress());
                        }
                    }
                }
            } else {
                ec2Address.setIpAddress(resp.getIpAddress());
            }

            return ec2Address;
        } catch(Exception e) {
            logger.error( "EC2 AllocateAddress - ", e);
View Full Code Here

   * @param request
   * @return
   */
  public boolean releaseAddress(EC2ReleaseAddress request) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackInfoResponse resp = getApi().disassociateIpAddress(cloudIp.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error("EC2 ReleaseAddress - ", e);
View Full Code Here

   * @param request
   * @return
   */
  public boolean associateAddress( EC2AssociateAddress request ) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
          CloudStackUserVm cloudVm = getApi().listVirtualMachines(null, null, true, null, null, null, null, request.getInstanceId(), null, null, null, null, null, null, null, null, null).get(0);

      CloudStackInfoResponse resp = getApi().enableStaticNat(cloudIp.getId(), cloudVm.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error( "EC2 AssociateAddress - ", e);
View Full Code Here

   * @param request
   * @return
   */
  public boolean disassociateAddress( EC2DisassociateAddress request ) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackInfoResponse resp = getApi().disableStaticNat(cloudIp.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error( "EC2 DisassociateAddress - ", e);
View Full Code Here

            CloudStackAccount caller = getCurrentAccount();
           
            CloudStackZone zone = findZone();
            CloudStackNetwork net = findNetwork(zone);
//      CloudStackIpAddress resp = getApi().associateIpAddress(null, null, null, "0036952d-48df-4422-9fd0-94b0885e18cb");
            CloudStackIpAddress resp = getApi().associateIpAddress(zone.getId(), caller.getName(), caller.getDomainId(), net != null ? net.getId():null);
      ec2Address.setAssociatedInstanceId(resp.getId());
     
      if (resp.getIpAddress() == null) {
          List<CloudStackIpAddress> addrList = getApi().listPublicIpAddresses(null, null, null, null, null, null, null, null, null);
          if (addrList != null && addrList.size() > 0) {
              for (CloudStackIpAddress addr: addrList) {
                  if (addr.getId().equalsIgnoreCase(resp.getId())) {
                      ec2Address.setIpAddress(addr.getIpAddress());
                  }
              }
          }
      } else {
          ec2Address.setIpAddress(resp.getIpAddress());
      }

      return ec2Address;
    } catch(Exception e) {
      logger.error( "EC2 AllocateAddress - ", e);
View Full Code Here

TOP

Related Classes of com.cloud.stack.models.CloudStackIpAddress

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.