Package com.cloud.vm

Examples of com.cloud.vm.NicSecondaryIp


    public static String getResultObjectName() {
        return "addressinfo";
    }

    public Long getNetworkId() {
        NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
        if (nicSecIp != null) {
            Long networkId = nicSecIp.getNetworkId();
            return networkId;
        } else {
            return null;
        }
    }
View Full Code Here


    }

    @Override
    public void execute() throws InvalidParameterValueException {
        CallContext.current().setEventDetails("Ip Id: " + id);
        NicSecondaryIp nicSecIp = getIpEntry();

        if (nicSecIp == null) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid IP id is passed");
        }

        if (isZoneSGEnabled()) {
            //remove the security group rules for this secondary ip
            boolean success = false;
            success = _securityGroupService.securityGroupRulesForVmSecIp(nicSecIp.getNicId(), nicSecIp.getNetworkId(),nicSecIp.getIp4Address(), false);
            if (success == false) {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set security group rules for the secondary ip");
            }
        }
View Full Code Here

    @Override
    public void execute() throws ResourceUnavailableException, ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException {

        CallContext.current().setEventDetails("Nic Id: " + getNicId());
        String ip;
        NicSecondaryIp result;
        String secondaryIp = null;
        if ((ip = getIpaddress()) != null) {
            if (!NetUtils.isValidIp(ip)) {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid ip address " + ip);
            }
        }

        try {
            result = _networkService.allocateSecondaryGuestIP(getNicId(), getIpaddress());
        } catch (InsufficientAddressCapacityException e) {
            throw new InvalidParameterValueException("Allocating guest ip for nic failed : " + e.getMessage());
        }

        if (result != null) {
            secondaryIp = result.getIp4Address();
            if (isZoneSGEnabled()) {
                // add security group rules for the secondary ip addresses
                boolean success = false;
                success = _securityGroupService.securityGroupRulesForVmSecIp(getNicId(), secondaryIp, true);
                if (success == false) {
View Full Code Here

            if (vmIp != null) {
                //vm ip is passed so it can be primary or secondary ip addreess.
                if (!dstIp.equals(vmIp)) {
                    //the vm ip is secondary ip to the nic.
                    // is vmIp is secondary ip or not
                    NicSecondaryIp secondaryIp = _nicSecondaryDao.findByIp4AddressAndNicId(vmIp.toString(), guestNic.getId());
                    if (secondaryIp == null) {
                        throw new InvalidParameterValueException("IP Address is not in the VM nic's network ");
                    }
                    dstIp = vmIp;
                }
View Full Code Here

    public String getEventType() {
        return EventTypes.EVENT_NET_IP_ASSIGN;
    }

    public NicSecondaryIp getIpEntry() {
        NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
        return nicSecIp;
    }
View Full Code Here

    public static String getResultObjectName() {
        return "addressinfo";
    }

    public Long getNetworkId() {
        NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
        if (nicSecIp != null) {
            Long networkId = nicSecIp.getNetworkId();
            return networkId;
        } else {
            return null;
        }
    }
View Full Code Here

    }

    @Override
    public void execute() throws InvalidParameterValueException {
        CallContext.current().setEventDetails("Ip Id: " + id);
        NicSecondaryIp nicSecIp = getIpEntry();

        if (nicSecIp == null) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid IP id is passed");
        }

        if (isZoneSGEnabled()) {
            //remove the security group rules for this secondary ip
            boolean success = false;
            success = _securityGroupService.securityGroupRulesForVmSecIp(nicSecIp.getNicId(), nicSecIp.getIp4Address(), false);
            if (success == false) {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to set security group rules for the secondary ip");
            }
        }
View Full Code Here

    public void execute() throws ResourceUnavailableException, ResourceAllocationException,
    ConcurrentOperationException, InsufficientCapacityException {

        CallContext.current().setEventDetails("Nic Id: " + getNicId() );
        String ip;
        NicSecondaryIp result;
        String secondaryIp = null;
        if ((ip = getIpaddress()) != null) {
            if (!NetUtils.isValidIp(ip)) {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Invalid ip address " + ip);
            }
        }

        try {
            result =  _networkService.allocateSecondaryGuestIP(_accountService.getAccount(getEntityOwnerId()),  getZoneId(), getNicId(), getNetworkId(), getIpaddress());
        } catch (InsufficientAddressCapacityException e) {
            throw new InvalidParameterValueException("Allocating guest ip for nic failed");
        }

        if (result != null) {
            secondaryIp = result.getIp4Address();
            if (getNetworkType() == NetworkType.Basic) {
                // add security group rules for the secondary ip addresses
                boolean success = false;
                success = _securityGroupService.securityGroupRulesForVmSecIp(getNicId(), getNetworkId(), secondaryIp, (boolean) true);
                if (success == false) {
View Full Code Here

    public String getEventType() {
        return EventTypes.EVENT_NET_IP_ASSIGN;
    }

    public NicSecondaryIp getIpEntry() {
        NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
        return nicSecIp;
    }
View Full Code Here

    public static String getResultObjectName() {
        return "addressinfo";
    }

    public Long getNetworkId() {
        NicSecondaryIp nicSecIp = _entityMgr.findById(NicSecondaryIp.class, getIpAddressId());
        if (nicSecIp != null) {
            Long networkId = nicSecIp.getNetworkId();
            return networkId;
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of com.cloud.vm.NicSecondaryIp

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.