Package com.cloud.network

Examples of com.cloud.network.IpAddress


    }

    @Override
    public void create() throws ResourceAllocationException{
        try {
            IpAddress ip = null;

            if (!isPortable()) {
                ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()),  getZoneId(), getNetworkId());
            } else {
                ip = _networkService.allocatePortableIP(_accountService.getAccount(getEntityOwnerId()), 1, getZoneId(), getNetworkId(), getVpcId());
            }

            if (ip != null) {
                this.setEntityId(ip.getId());
                this.setEntityUuid(ip.getUuid());
            } else {
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to allocate ip address");
            }
        } catch (ConcurrentOperationException ex) {
            s_logger.warn("Exception: ", ex);
View Full Code Here


    @Override
    public void execute() throws ResourceUnavailableException, ResourceAllocationException,
                                    ConcurrentOperationException, InsufficientCapacityException {
        UserContext.current().setEventDetails("Ip Id: " + getEntityId());

        IpAddress result = null;

        if (getVpcId() != null) {
            result = _vpcService.associateIPToVpc(getEntityId(), getVpcId());
        } else if (getNetworkId() != null) {
            result = _networkService.associateIPToNetwork(getEntityId(), getNetworkId());
View Full Code Here

    }


    public Long getSourceIpAddressId() {
        if (publicIpId != null) {
            IpAddress ipAddr = _networkService.getIp(publicIpId);
            if (ipAddr == null || !ipAddr.readyToUse()) {
                throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
            }
        } else if (getEntityId() != null) {
            LoadBalancer rule = _entityMgr.findById(LoadBalancer.class, getEntityId());
            return rule.getSourceIpAddressId();
        }
View Full Code Here

        return publicIpId;
    }

    private Long getVpcId() {
        if (publicIpId != null) {
            IpAddress ipAddr = _networkService.getIp(publicIpId);
            if (ipAddr == null || !ipAddr.readyToUse()) {
                throw new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id " + ipAddr.getId());
            } else {
                return ipAddr.getVpcId();
            }
        }
        return null;
    }
View Full Code Here

                } else {
                    return defaultGuestNetwork.getId();
                }
            }
        } else {
            IpAddress ipAddr = _networkService.getIp(publicIpId);
            if (ipAddr.getAssociatedWithNetworkId() != null) {
                return ipAddr.getAssociatedWithNetworkId();
            } else {
                throw new InvalidParameterValueException("Ip address id=" + publicIpId + " is not associated with any network");
            }
        }
    }
View Full Code Here

        return s_name;
    }

    @Override
    public long getEntityOwnerId() {
        IpAddress addr = _entityMgr.findById(IpAddress.class, getPublicIpId());
        if (addr != null) {
            return addr.getAccountId();
        }

        // bad address given, parent this command to SYSTEM so ERROR events are tracked
        return Account.ACCOUNT_ID_SYSTEM;
    }
View Full Code Here

            return false;
        }

        List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
        for (StaticNat rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            // Force the nat rule into the StaticNatRuleTO, no use making a new TO object
            // we only need the source and destination ip. Unfortunately no mention if a rule
            // is new.
            StaticNatRuleTO ruleTO = new StaticNatRuleTO(1,
                    sourceIp.getAddress().addr(), 0, 65535,
                    rule.getDestIpAddress(), 0, 65535,
                    "any", rule.isForRevoke(), false);
            staticNatRules.add(ruleTO);
        }
View Full Code Here

            return false;
        }

        List<PortForwardingRuleTO> portForwardingRules = new ArrayList<PortForwardingRuleTO>();
        for (PortForwardingRule rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            Vlan vlan = _vlanDao.findById(sourceIp.getVlanId());
            PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, vlan.getVlanTag(), sourceIp.getAddress().addr());
            portForwardingRules.add(ruleTO);
        }

        ConfigurePortForwardingRulesOnLogicalRouterCommand cmd =
                new ConfigurePortForwardingRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), portForwardingRules);
View Full Code Here

        String accountIdStr = getAccountUuid(network);
        String networkUUIDStr = String.valueOf(network.getId());

        for (StaticNat rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            String sourceIpAddr = sourceIp.getAddress().addr();

            if (resources == false) {
                tenantRouter = getOrCreateGuestNetworkRouter(network);
                providerRouter = api.getRouter(_providerRouterId);
View Full Code Here

                }
            }

            for (FirewallRule rule : rulesToApply) {
                if (rule.getState() == FirewallRule.State.Revoke || rule.getState() == FirewallRule.State.Add) {
                    IpAddress dstIp = _networkModel.getIp(rule.getSourceIpAddressId());
                    FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, dstIp.getAddress().addr());

                    // Convert to string representation
                    SimpleFirewallRule fwRule = new SimpleFirewallRule(ruleTO);
                    String[] ruleStrings = fwRule.toStringArray();
View Full Code Here

TOP

Related Classes of com.cloud.network.IpAddress

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.