Search in sources :

Example 1 with Repository

use of com.cloud.hypervisor.ovm3.objects.Repository in project cloudstack by apache.

the class Ovm3StoragePool method createRepo.

/**
     * Create primary storage, which is a repository in OVM. Pooling is part of
     * this too and clustering should be in the future.
     *
     * @param cmd
     * @return
     * @throws XmlRpcException
     */
private boolean createRepo(StorageFilerTO cmd) throws XmlRpcException {
    String basePath = config.getAgentOvmRepoPath();
    Repository repo = new Repository(c);
    String primUuid = repo.deDash(cmd.getUuid());
    String ovsRepo = basePath + "/" + primUuid;
    /* should add port ? */
    String mountPoint = String.format("%1$s:%2$s", cmd.getHost(), cmd.getPath());
    String msg;
    if (cmd.getType() == StoragePoolType.NetworkFilesystem) {
        Boolean repoExists = false;
        /* base repo first */
        try {
            repo.mountRepoFs(mountPoint, ovsRepo);
        } catch (Ovm3ResourceException e) {
            LOGGER.debug("Unable to mount NFS repository " + mountPoint + " on " + ovsRepo + " requested for " + config.getAgentHostname() + ": " + e.getMessage());
        }
        try {
            repo.addRepo(mountPoint, ovsRepo);
            repoExists = true;
        } catch (Ovm3ResourceException e) {
            LOGGER.debug("NFS repository " + mountPoint + " on " + ovsRepo + " not found creating repo: " + e.getMessage());
        }
        if (!repoExists) {
            try {
                /*
                     * a mount of the NFS fs by the createrepo actually
                     * generates a null if it is already mounted... -sigh-
                     */
                repo.createRepo(mountPoint, ovsRepo, primUuid, "OVS Repository");
            } catch (Ovm3ResourceException e) {
                msg = "NFS repository " + mountPoint + " on " + ovsRepo + " create failed!";
                LOGGER.debug(msg);
                throw new CloudRuntimeException(msg + " " + e.getMessage(), e);
            }
        }
        /* add base pooling first */
        if (config.getAgentInOvm3Pool()) {
            try {
                msg = "Configuring " + config.getAgentHostname() + "(" + config.getAgentIp() + ") for pool";
                LOGGER.debug(msg);
                setupPool(cmd);
                msg = "Configured host for pool";
                /* add clustering after pooling */
                if (config.getAgentInOvm3Cluster()) {
                    msg = "Setup " + config.getAgentHostname() + "(" + config.getAgentIp() + ")  for cluster";
                    LOGGER.debug(msg);
                /* setup cluster */
                /*
                         * From cluster.java
                         * configure_server_for_cluster(cluster conf, fs, mount,
                         * fsuuid, poolfsbaseuuid)
                         */
                /* create_cluster(poolfsuuid,) */
                }
            } catch (Ovm3ResourceException e) {
                msg = "Unable to setup pool on  " + config.getAgentHostname() + "(" + config.getAgentIp() + ") for " + ovsRepo;
                throw new CloudRuntimeException(msg + " " + e.getMessage(), e);
            }
        } else {
            msg = "no way dude I can't stand for this";
            LOGGER.debug(msg);
        }
        /*
             * this is to create the .generic_fs_stamp else we're not allowed to
             * create any data\disks on this thing
             */
        try {
            URI uri = new URI(cmd.getType() + "://" + cmd.getHost() + ":" + +cmd.getPort() + cmd.getPath() + "/VirtualMachines");
            setupNfsStorage(uri, cmd.getUuid());
        } catch (Exception e) {
            msg = "NFS mount " + mountPoint + " on " + config.getAgentSecStoragePath() + "/" + cmd.getUuid() + " create failed!";
            throw new CloudRuntimeException(msg + " " + e.getMessage(), e);
        }
    } else {
        msg = "NFS repository " + mountPoint + " on " + ovsRepo + " create failed, was type " + cmd.getType();
        LOGGER.debug(msg);
        return false;
    }
    try {
        /* systemvm iso is imported here */
        prepareSecondaryStorageStore(ovsRepo, cmd.getUuid(), cmd.getHost());
    } catch (Exception e) {
        msg = "systemvm.iso copy failed to " + ovsRepo;
        LOGGER.debug(msg, e);
        return false;
    }
    return true;
}
Also used : Repository(com.cloud.hypervisor.ovm3.objects.Repository) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) URI(java.net.URI) ConfigurationException(javax.naming.ConfigurationException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Example 2 with Repository

use of com.cloud.hypervisor.ovm3.objects.Repository in project cloudstack by apache.

the class Ovm3StoragePool method execute.

/**
     * Download from template url into primary storage ?.. is this relevant ?
     *
     * @param cmd
     * @return
     */
public PrimaryStorageDownloadAnswer execute(final PrimaryStorageDownloadCommand cmd) {
    try {
        Repository repo = new Repository(c);
        String tmplturl = cmd.getUrl();
        String poolName = cmd.getPoolUuid();
        String image = repo.deDash(repo.newUuid()) + ".raw";
        /* url to download from, image name, and repo to copy it to */
        repo.importVirtualDisk(tmplturl, image, poolName);
        return new PrimaryStorageDownloadAnswer(image);
    } catch (Exception e) {
        LOGGER.debug("PrimaryStorageDownloadCommand failed", e);
        return new PrimaryStorageDownloadAnswer(e.getMessage());
    }
}
Also used : PrimaryStorageDownloadAnswer(com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer) Repository(com.cloud.hypervisor.ovm3.objects.Repository) ConfigurationException(javax.naming.ConfigurationException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)

Example 3 with Repository

use of com.cloud.hypervisor.ovm3.objects.Repository in project cloudstack by apache.

the class Ovm3StorageProcessor method execute.

/*
     * CopyVolumeCommand gets the storage_pool should use that for
     * bumper bowling.
     */
public CopyVolumeAnswer execute(CopyVolumeCommand cmd) {
    LOGGER.debug("execute: " + cmd.getClass());
    String volumePath = cmd.getVolumePath();
    /* is a repository */
    String secondaryStorageURL = cmd.getSecondaryStorageURL();
    int wait = cmd.getWait();
    if (wait == 0) {
        wait = 7200;
    }
    try {
        Linux host = new Linux(c);
        /* to secondary storage */
        if (cmd.toSecondaryStorage()) {
            LOGGER.debug("Copy to  secondary storage " + volumePath + " to " + secondaryStorageURL);
            host.copyFile(volumePath, secondaryStorageURL);
        /* from secondary storage */
        } else {
            LOGGER.debug("Copy from secondary storage " + secondaryStorageURL + " to " + volumePath);
            host.copyFile(secondaryStorageURL, volumePath);
        }
        /* check the truth of this */
        return new CopyVolumeAnswer(cmd, true, null, null, null);
    } catch (Ovm3ResourceException e) {
        LOGGER.debug("Copy volume failed", e);
        return new CopyVolumeAnswer(cmd, false, e.getMessage(), null, null);
    }
}
Also used : Linux(com.cloud.hypervisor.ovm3.objects.Linux) Ovm3ResourceException(com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException) CopyVolumeAnswer(com.cloud.agent.api.storage.CopyVolumeAnswer)

Aggregations

Ovm3ResourceException (com.cloud.hypervisor.ovm3.objects.Ovm3ResourceException)3 Repository (com.cloud.hypervisor.ovm3.objects.Repository)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 ConfigurationException (javax.naming.ConfigurationException)2 XmlRpcException (org.apache.xmlrpc.XmlRpcException)2 CopyVolumeAnswer (com.cloud.agent.api.storage.CopyVolumeAnswer)1 PrimaryStorageDownloadAnswer (com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer)1 Linux (com.cloud.hypervisor.ovm3.objects.Linux)1 URI (java.net.URI)1