Package com.cloud.exception

Examples of com.cloud.exception.InternalErrorException


        try {
            IpAddressTO[] ips = cmd.getIpAddresses();
            for (IpAddressTO ip : ips) {
                URI broadcastUri = BroadcastDomainType.fromString(ip.getBroadcastUri());
                if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
                    throw new InternalErrorException("Invalid Broadcast URI " + ip.getBroadcastUri());
                }
                int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));
                int publicNicInfo = -1;
                publicNicInfo = getVmNics(routerName, vlanId);
                if (publicNicInfo < 0) {
                    if (ip.isAdd()) {
                        throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
                        } else {
                        s_logger.debug("VIF to deassociate IP with does not exist, return success");
                        continue;
                    }
                }
View Full Code Here


    protected void assignPublicIpAddress(final String vmName, final String privateIpAddress, final String publicIpAddress, final boolean add, final boolean firstIP,
            final boolean sourceNat, final String broadcastId, final String vlanGateway, final String vlanNetmask, final String vifMacAddress) throws Exception {

        URI broadcastUri = BroadcastDomainType.fromString(broadcastId);
        if (BroadcastDomainType.getSchemeValue(broadcastUri) != BroadcastDomainType.Vlan) {
            throw new InternalErrorException("Unable to assign a public IP to a VIF on network " + broadcastId);
        }
        int vlanId = Integer.parseInt(BroadcastDomainType.getValue(broadcastUri));

        int publicNicInfo = -1;
        publicNicInfo = getVmNics(vmName, vlanId);

        boolean addVif = false;
        if (add && publicNicInfo == -1) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Plug new NIC to associate" + privateIpAddress + " to " + publicIpAddress);
            }
            addVif = true;
        } else if (!add && firstIP) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Unplug NIC " + publicNicInfo);
            }
        }

        if (addVif) {
            Pair<Integer, String> nicdevice = findRouterFreeEthDeviceIndex(privateIpAddress);
            publicNicInfo = nicdevice.first();
            if (publicNicInfo > 0) {
                modifyNicVlan(vmName, vlanId, nicdevice.second());
                // After modifying the vnic on VR, check the VR VNics config in the host and get the device position
                publicNicInfo = getVmNics(vmName, vlanId);
                // As a new nic got activated in the VR. add the entry in the NIC's table.
                networkUsage(privateIpAddress, "addVif", "eth" + publicNicInfo);
            }
            else {
                // we didn't find any eth device available in VR to configure the ip range with new VLAN
                String msg = "No Nic is available on DomR VIF to associate/disassociate IP with.";
                s_logger.error(msg);
                throw new InternalErrorException(msg);
            }
        }

        String args = null;
View Full Code Here

            s_logger.debug("vm interface update, _netActive: " + _netActive + ", _nicActive: " + _nicActive);
            delete(controller);
            return;
        }
        if (_vmModel == null) {
            throw new InternalErrorException("virtual-machine not set on VMI: " + _uuid);
        }
        if (_vnModel == null) {
            throw new InternalErrorException("virtual-network not set on VMI: " + _uuid);
        }
        ContrailManager manager = controller.getManager();
        ApiConnector api = controller.getApiAccessor();

        VirtualMachineInterface vmi = (VirtualMachineInterface)api.findById(VirtualMachineInterface.class, _uuid);
        boolean create = false;
        if (vmi == null) {
            create = true;
            vmi = new VirtualMachineInterface();
            vmi.setParent(_vmModel.getVirtualMachine());
            vmi.setName(manager.getVifNameByVmName(_vmModel.getInstanceName(), _deviceId));
            vmi.setUuid(_uuid);
            vmi.setVirtualNetwork(_vnModel.getVirtualNetwork());
        } else {
            // Do not try to update VMI to routing-instance references. These are managed by schema-transformer.
            vmi.clearRoutingInstance();
        }
        _vmi = vmi;
        if (_macAddress != null) {
            MacAddressesType mac = new MacAddressesType();
            mac.addMacAddress(_macAddress);
            vmi.setMacAddresses(mac);
        }

        if (_serviceTag != null) {
            vmi.setProperties(new VirtualMachineInterfacePropertiesType(_serviceTag, null));
        }

        if (create) {
            if (!api.create(vmi)) {
                throw new InternalErrorException("Unable to create virtual-machine-interface " + _uuid);
            }
        } else {
            if (!api.update(vmi)) {
                throw new InternalErrorException("Unable to update virtual-machine-interface " + _uuid);
            }
        }

        api.read(vmi);
View Full Code Here

            if (_ipAddress != null) {
                ip_obj.setAddress(_ipAddress);
            }
            ip_obj.setVirtualMachineInterface(vmi);
            if (!api.create(ip_obj)) {
                throw new InternalErrorException("Unable to create instance-ip " + _name);
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            if (_ipAddress == null) {
                if (!api.read(ip_obj)) {
                    throw new InternalErrorException("Unable to read instance-ip " + _name);
                }
            }
            _ipAddress = ip_obj.getAddress();
        } else {
            // Ensure that the instance-ip has the correct value and is pointing at the VMI.
            InstanceIp ip_obj = (InstanceIp)api.findById(InstanceIp.class, ipid);
            if (ip_obj == null) {
                throw new InternalErrorException("Unable to read instance-ip " + _name);
            }
            boolean update = false;
            String ipnet_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualNetwork());
            if (ipnet_id == null || !ipnet_id.equals(_vmiModel.getNetworkUuid())) {
                ip_obj.setVirtualNetwork(vnet);
                update = true;
            }

            if (_ipAddress != null && !ip_obj.getAddress().equals(_ipAddress)) {
                ip_obj.setAddress(_ipAddress);
                update = true;
            }

            String vmi_id = ObjectReference.getReferenceListUuid(ip_obj.getVirtualMachineInterface());
            if (vmi_id == null || !vmi_id.equals(_vmiModel.getUuid())) {
                if (vmi != null) {
                    ip_obj.setVirtualMachineInterface(vmi);
                    update = true;
                }
            }

            if (update && !api.update(ip_obj)) {
                throw new InternalErrorException("Unable to update instance-ip: " + ip_obj.getName());
            }
            api.read(ip_obj);
            _uuid = ip_obj.getUuid();
            _ipAddress = ip_obj.getAddress();
        }
View Full Code Here

        if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) {
            URI broadcastUri = nic.getBroadcastUri();
            vlanId = broadcastUri.getHost();
        }
        else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
            throw new InternalErrorException("Nicira NVP Logicalswitches are not supported by the BridgeVifDriver");
        }
        String trafficLabel = nic.getName();
        if (nic.getType() == Networks.TrafficType.Guest) {
            Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1)? nic.getNetworkRateMbps().intValue() * 128: 0;
            if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan
View Full Code Here

            command.add("-b", brName);
            command.add("-o", "add");
           
            final String result = command.execute();
            if (result != null) {
                throw new InternalErrorException("Failed to create vnet " + vnetId
                        + ": " + result);
            }
        }
    }
View Full Code Here

    public boolean copyVolume(String srcPath, String destPath,
            String volumeName, int timeout) throws InternalErrorException {
        _storageLayer.mkdirs(destPath);
        if (!_storageLayer.exists(srcPath)) {
            throw new InternalErrorException("volume:" + srcPath
                    + " is not exits");
        }
        String result = Script.runSimpleBashScript("cp " + srcPath + " "
                + destPath + File.separator + volumeName, timeout);
        if (result != null) {
View Full Code Here

        args += " -n ";
        args += subnet;

        String result = routerProxy("vpc_ipassoc.sh", routerIP, args);
        if (result != null) {
            throw new InternalErrorException("KVM plugin \"vpc_ipassoc\" failed:"+result);
        }
        if (sourceNat) {
            snatArgs += " -l " + pubIP;
            snatArgs += " -c " + nicname;

            result = routerProxy("vpc_privateGateway.sh", routerIP, snatArgs);
            if (result != null) {
                throw new InternalErrorException("KVM plugin \"vpc_privateGateway\" failed:"+result);
            }

        }
    }
View Full Code Here

                        diskdef = disk;
                        break;
                    }
                }
                if (diskdef == null) {
                    throw new InternalErrorException("disk: " + attachingDisk.getPath() + " is not attached before");
                }
            } else {
                diskdef = new DiskDef();
                if (attachingPool.getType() == StoragePoolType.RBD) {
                    diskdef.defNetworkBasedDisk(attachingDisk.getPath(),
View Full Code Here

        try {
            txn.start();

            if (_podDao.persist(pod) == null) {
                txn.rollback();
                throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support.");
            }

            if (startIp != null) {
                _zoneDao.addPrivateIpAddress(zoneId, pod.getId(), startIp, endIp);
            }

            String ipNums = _configDao.getValue("linkLocalIp.nums");
            int nums = Integer.parseInt(ipNums);
            if (nums > 16 || nums <= 0) {
                throw new InvalidParameterValueException("The linkLocalIp.nums: " + nums + "is wrong, should be 1~16");
            }
            /* local link ip address starts from 169.254.0.2 - 169.254.(nums) */
            String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(nums);
            if (linkLocalIpRanges == null) {
                throw new InvalidParameterValueException("The linkLocalIp.nums: " + nums + "may be wrong, should be 1~16");
            } else {
                _zoneDao.addLinkLocalIpAddress(zoneId, pod.getId(), linkLocalIpRanges[0], linkLocalIpRanges[1]);
            }

            txn.commit();

        } catch (Exception e) {
            txn.rollback();
            s_logger.error("Unable to create new pod due to " + e.getMessage(), e);
            throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support.");
        }

        return pod;
    }
View Full Code Here

TOP

Related Classes of com.cloud.exception.InternalErrorException

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.