Package com.cloud.exception

Examples of com.cloud.exception.InternalErrorException


    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


        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

        }

        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

            if (addVif) {
                // Add a new VIF to DomR
                String vifDeviceNum = getLowestAvailableVIFDeviceNum(conn, router);

                if (vifDeviceNum == null) {
                    throw new InternalErrorException("There were no more available slots for a new VIF on router: " + router.getNameLabel(conn));
                }

                nic.setDeviceId(Integer.parseInt(vifDeviceNum));

                correctVif = createVif(conn, vmName, router, nic);
                correctVif.plug(conn);
                // Add iptables rule for network usage
                networkUsage(conn, privateIpAddress, "addVif", "eth" + correctVif.getDevice(conn));
            }

            if (correctVif == null) {
                throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
            }

            String args = "ipassoc.sh " + privateIpAddress;

            if (add) {
                args += " -A ";
            } else {
                args += " -D ";
            }

            if (sourceNat) {
                args += " -s";
            }
            if (firstIP) {
                args += " -f";
            }

            String cidrSize = Long.toString(NetUtils.getCidrSize(vlanNetmask));
            args += " -l ";
            args += publicIpAddress + "/" + cidrSize;

            args += " -c ";
            args += "eth" + correctVif.getDevice(conn);

            args += " -g ";
            args += vlanGateway;

            if (addVif) {
                //To indicate this is new interface created
                args += " -n";
            }


            String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
            if (result == null || result.isEmpty()) {
                throw new InternalErrorException("Xen plugin \"ipassoc\" failed.");
            }

            if (!add) {
                args += " -d";
                String zeroIpsRes = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
                if (zeroIpsRes == null || zeroIpsRes.isEmpty()) {
                    //There are no ip address set on the interface. So unplug the interface
                    // If it is not unplugged then the interface is not resuable.
                    removeVif = true;
                }
            }



            if (removeVif) {
                network = correctVif.getNetwork(conn);

                // Mark this vif to be removed from network usage
                networkUsage(conn, privateIpAddress, "deleteVif", "eth" + correctVif.getDevice(conn));

                // Remove the VIF from DomR
                correctVif.unplug(conn);
                correctVif.destroy(conn);

                // Disable the VLAN network if necessary
                disableVlanNetwork(conn, network);
            }

        } catch (XenAPIException e) {
            String msg = "Unable to assign public IP address due to " + e.toString();
            s_logger.warn(msg, e);
            throw new InternalErrorException(msg);
        } catch (final XmlRpcException e) {
            String msg = "Unable to assign public IP address due to " + e.getMessage();
            s_logger.warn(msg, e);
            throw new InternalErrorException(msg);
        }
    }
View Full Code Here

            VM router = getVM(conn, vmName);

            VIF correctVif = getVifByMac(conn, router, ip.getVifMacAddress());
            if (correctVif == null) {
                if (ip.isAdd()) {
                    throw new InternalErrorException("Failed to find DomR VIF to associate IP with.");
                } else {
                    s_logger.debug("VIF to deassociate IP with does not exist, return success");
                    return;
                }
            }          

            String args = "vpc_ipassoc.sh " + routerIp;
            String snatArgs = "vpc_privateGateway.sh " + routerIp;

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

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

            args += " -c ";
            args += "eth" + correctVif.getDevice(conn);

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

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


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

            String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
            if (result == null || result.isEmpty()) {
                throw new InternalErrorException("Xen plugin \"vpc_ipassoc\" failed.");
            }

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

                result = callHostPlugin(conn, "vmops", "routerProxy", "args", snatArgs);
                if (result == null || result.isEmpty()) {
                    throw new InternalErrorException("Xen plugin \"vpc_privateGateway\" failed.");
                }
            }

        } catch (Exception e) {
            String msg = "Unable to assign public IP address due to " + e.toString();
View Full Code Here

            SR primaryStoragePool = getStorageRepository(conn, poolTO.getUuid());
            String srUuid = primaryStoragePool.getUuid(conn);
            if (toSecondaryStorage) {
                // Create the volume folder
                if (!createSecondaryStorageFolder(conn, remoteVolumesMountPath, volumeFolder)) {
                    throw new InternalErrorException("Failed to create the volume folder.");
                }
                SR secondaryStorage = null;
                try {
                    // Create a SR for the volume UUID folder
                    secondaryStorage = createNfsSRbyURI(conn, new URI(secondaryStorageURL + "/volumes/" + volumeFolder), false);
View Full Code Here

    private boolean destroySnapshotOnPrimaryStorageExceptThis(Connection conn, String volumeUuid, String avoidSnapshotUuid){
        try {
            VDI volume = getVDIbyUuid(conn, volumeUuid);
            if (volume == null) {
                throw new InternalErrorException("Could not destroy snapshot on volume " + volumeUuid + " due to can not find it");
            }
            Set<VDI> snapshots = volume.getSnapshots(conn);
            for( VDI snapshot : snapshots ) {
                try {
                    if(! snapshot.getUuid(conn).equals(avoidSnapshotUuid)) {
View Full Code Here

        String snapshotBackupUuid = null;
        boolean fullbackup = true;
        try {
            SR primaryStorageSR = getSRByNameLabelandHost(conn, primaryStorageNameLabel);
            if (primaryStorageSR == null) {
                throw new InternalErrorException("Could not backup snapshot because the primary Storage SR could not be created from the name label: " + primaryStorageNameLabel);
            }
            String psUuid = primaryStorageSR.getUuid(conn);
            Boolean isISCSI = IsISCSI(primaryStorageSR.getType(conn));
            URI uri = new URI(secondaryStorageUrl);
            String secondaryStorageMountPath = uri.getHost() + ":" + uri.getPath();
View Full Code Here

            return new CreateVolumeFromSnapshotAnswer(cmd, result, details, volumeUUID);
        }
        try {
            SR primaryStorageSR = getSRByNameLabelandHost(conn, primaryStorageNameLabel);
            if (primaryStorageSR == null) {
                throw new InternalErrorException("Could not create volume from snapshot because the primary Storage SR could not be created from the name label: "
                        + primaryStorageNameLabel);
            }
            // Get the absolute path of the snapshot on the secondary storage.
            URI snapshotURI = new URI(secondaryStorageUrl + "/snapshots/" + accountId + "/" + volumeId);
            String filename = backedUpSnapshotUuid;
View Full Code Here

    protected boolean destroySnapshotOnPrimaryStorage(Connection conn, String snapshotUuid) {
        // Precondition snapshotUuid != null
        try {
            VDI snapshot = getVDIbyUuid(conn, snapshotUuid);
            if (snapshot == null) {
                throw new InternalErrorException("Could not destroy snapshot " + snapshotUuid + " because the snapshot VDI was null");
            }
            snapshot.destroy(conn);
            s_logger.debug("Successfully destroyed snapshotUuid: " + snapshotUuid + " on primary storage");
            return true;
        } catch (XenAPIException e) {
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.