Package com.cloud.exception

Examples of com.cloud.exception.InternalErrorException


        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


    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

        if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
          vNetId = Networks.BroadcastDomainType.getValue(nic.getBroadcastUri());
          protocol = Networks.BroadcastDomainType.getSchemeValue(nic.getBroadcastUri()).scheme();
        }
        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 && !vNetId.equalsIgnoreCase("untagged")
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

        VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);

        int ethDeviceNum = findRouterEthDeviceIndex(domrName, routerIp, ip.getVifMacAddress());
        if (ethDeviceNum < 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");
                return;
            }
        }

        String args = "";
        String snatArgs = "";

        if (ip.isAdd()) {
            args += " -A ";
            snatArgs += " -A ";
        } else {
            args += " -D ";
            snatArgs += " -D ";
        }

        args += " -l ";
        args += ip.getPublicIp();

        args += " -c ";
        args += "eth" + ethDeviceNum;

        args += " -g ";
        args += ip.getVlanGateway();

        args += " -m ";
        args += Long.toString(NetUtils.getCidrSize(ip.getVlanNetmask()));

        args += " -n ";
        args += NetUtils.getSubNet(ip.getPublicIp(), ip.getVlanNetmask());

        Pair<Boolean, String> result = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null,
                "/opt/cloud/bin/vpc_ipassoc.sh " + args);

        if (!result.first()) {
            throw new InternalErrorException("Unable to assign public IP address");
        }

        if (ip.isSourceNat()) {
            snatArgs += " -l ";
            snatArgs += ip.getPublicIp();
            snatArgs += " -c ";
            snatArgs += "eth" + ethDeviceNum;

            Pair<Boolean, String> result_gateway = SshHelper.sshExecute(routerIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null,
                    "/opt/cloud/bin/vpc_privateGateway.sh " + snatArgs);

            if (!result_gateway.first()) {
                throw new InternalErrorException("Unable to configure source NAT for public IP address.");
            }
        }
    }
View Full Code Here

        /**
         * TODO support other networks
         */
        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);
        }
        String vlanId = BroadcastDomainType.getValue(broadcastUri);

        String publicNeworkName = HypervisorHostHelper.getPublicNetworkNamePrefix(vlanId);
        Pair<Integer, VirtualDevice> publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);

        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Find public NIC index, public network name: " + publicNeworkName + ", index: " + publicNicInfo.first());
        }

        boolean addVif = false;
        boolean removeVif = false;
        if (add && publicNicInfo.first().intValue() == -1) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Plug new NIC to associate" + privateIpAddress + " to " + publicIpAddress);
            }

            addVif = true;
        } else if (!add && firstIP) {
            removeVif = true;

            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Unplug NIC " + publicNicInfo.first());
            }
        }

        if (addVif) {
            plugPublicNic(vmMo, vlanId, vifMacAddress);
            publicNicInfo = vmMo.getNicDeviceIndex(publicNeworkName);
            if (publicNicInfo.first().intValue() >= 0) {
                networkUsage(privateIpAddress, "addVif", "eth" + publicNicInfo.first());
            }
        }

        if (publicNicInfo.first().intValue() < 0) {
            String msg = "Failed to find DomR VIF to associate/disassociate IP with.";
            s_logger.error(msg);
            throw new InternalErrorException(msg);
        }

        String args = null;

        if (add) {
View Full Code Here

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

        templateFileFullPath += templateName.endsWith(ImageFormat.OVA.getFileExtension()) ? templateName : templateName + "." + ImageFormat.OVA.getFileExtension();
        String ovfFileName = getOVFFilePath(templateFileFullPath);
        if(ovfFileName == null) {
            String msg = "Unable to locate OVF file in template package directory: " + templatePath;
            s_logger.error(msg);
            throw new InternalErrorException(msg);
        }
        try {
            Document ovfDoc = null;
            ovfDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(ovfFileName));
            Element disk  = (Element) ovfDoc.getElementsByTagName("Disk").item(0);
            virtualSize = Long.parseLong(disk.getAttribute("ovf:capacity"));
            String allocationUnits = disk.getAttribute("ovf:capacityAllocationUnits");
            if ((virtualSize != 0) && (allocationUnits != null)) {
                long units = 1;
                if (allocationUnits.equalsIgnoreCase("KB") || allocationUnits.equalsIgnoreCase("KiloBytes") || allocationUnits.equalsIgnoreCase("byte * 2^10")) {
                    units = 1024;
                } else if (allocationUnits.equalsIgnoreCase("MB") || allocationUnits.equalsIgnoreCase("MegaBytes") || allocationUnits.equalsIgnoreCase("byte * 2^20")) {
                    units = 1024 * 1024;
                } else if (allocationUnits.equalsIgnoreCase("GB") || allocationUnits.equalsIgnoreCase("GigaBytes") || allocationUnits.equalsIgnoreCase("byte * 2^30")) {
                    units = 1024 * 1024 * 1024;
                }
                virtualSize = virtualSize * units;
            } else {
                throw new InternalErrorException("Failed to read capacity and capacityAllocationUnits from the OVF file: " + ovfFileName);
            }
            return virtualSize;
        } catch (Exception e) {
            String msg = "Unable to parse OVF XML document to get the virtual disk size due to"+e;
            s_logger.error(msg);
            throw new InternalErrorException(msg);
        }
    }
View Full Code Here

            strm.read(creatorApp);
            strm.skip(vhd_footer_current_size_offset - vhd_footer_creator_ver_offset);
            strm.read(currentSize);          
        } catch (Exception e) {
            s_logger.warn("Unable to read vhd file " + vhdPath, e);
            throw new InternalErrorException("Unable to read vhd file " + vhdPath + ": " + e);
        } finally {
            if (strm != null) {
                try {
                    strm.close();
                } catch (IOException e) {
View Full Code Here

        /*Only support VHD image created by citrix xenserver, and xenconverter*/
        String readableCreator = "";
        for (int j = 0; j < creatorApp.length; j++) {
          readableCreator += (char)creatorApp[j];
        }
        throw new InternalErrorException("Image creator is:" + readableCreator +", is not supported");
      }
    }
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.