cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/4.4-forward to 9340560
Date Tue, 29 Apr 2014 05:54:28 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/4.4-forward de114f554 -> 934056097


CLOUDSTACK-6170 Needed to add logic for XS 6.2 + XS62ESP1 + XS62ESP1004


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93405609
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93405609
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93405609

Branch: refs/heads/4.4-forward
Commit: 934056097a638c1563f067b4236ad4c37211e9db
Parents: de114f5
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Sun Apr 27 10:49:36 2014 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Mon Apr 28 23:31:08 2014 -0600

----------------------------------------------------------------------
 .../resource/Xenserver625StorageProcessor.java  | 131 ++++++++++++++-----
 1 file changed, 100 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93405609/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java
b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java
index 29cbac6..9df18c0 100644
--- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java
+++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/Xenserver625StorageProcessor.java
@@ -40,6 +40,7 @@ import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
+import com.cloud.agent.api.to.DiskTO;
 import com.cloud.agent.api.to.NfsTO;
 import com.cloud.agent.api.to.S3TO;
 import com.cloud.agent.api.to.SwiftTO;
@@ -142,6 +143,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor
{
         Connection conn = hypervisorResource.getConnection();
         SR srcSr = null;
         Task task = null;
+
         try {
             if ((srcStore instanceof NfsTO) && (srcData.getObjectType() == DataObjectType.TEMPLATE))
{
                 NfsTO srcImageStore = (NfsTO)srcStore;
@@ -149,81 +151,148 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor
{
                 String storeUrl = srcImageStore.getUrl();
                 URI uri = new URI(storeUrl);
                 String volumePath = srcData.getPath();
+
                 volumePath = StringUtils.stripEnd(volumePath, "/");
+
                 String[] splits = volumePath.split("/");
                 String volumeDirectory = volumePath;
+
                 if (splits.length > 4) {
                     //"template/tmpl/dcid/templateId/templatename"
                     int index = volumePath.lastIndexOf("/");
+
                     volumeDirectory = volumePath.substring(0, index);
                 }
+
                 srcSr = createFileSr(conn, uri.getHost() + ":" + uri.getPath(), volumeDirectory);
-                Set<VDI> vdis = srcSr.getVDIs(conn);
-                if (vdis.size() != 1) {
+
+                Set<VDI> setVdis = srcSr.getVDIs(conn);
+
+                if (setVdis.size() != 1) {
                     return new CopyCmdAnswer("Can't find template VDI under: " + uri.getHost()
+ ":" + uri.getPath() + "/" + volumeDirectory);
                 }
 
-                VDI srcVdi = vdis.iterator().next();
+                VDI srcVdi = setVdis.iterator().next();
+
+                boolean managed = false;
+                String storageHost = null;
+                String managedStoragePoolName = null;
+                String managedStoragePoolRootVolumeName = null;
+                String managedStoragePoolRootVolumeSize = null;
+                String chapInitiatorUsername = null;
+                String chapInitiatorSecret = null;
 
                 PrimaryDataStoreTO destStore = (PrimaryDataStoreTO)destData.getDataStore();
-                String poolName = destStore.getUuid();
 
+                Map<String, String> details = destStore.getDetails();
 
-                SR poolsr = null;
-                Set<SR> srs = SR.getByNameLabel(conn, poolName);
-                if (srs.size() != 1) {
-                    String msg = "There are " + srs.size() + " SRs with same name: " + poolName;
-                    s_logger.warn(msg);
-                    return new CopyCmdAnswer(msg);
-                } else {
-                    poolsr = srs.iterator().next();
+                if (details != null) {
+                    managed = Boolean.parseBoolean(details.get(PrimaryDataStoreTO.MANAGED));
+
+                    if (managed) {
+                        storageHost = details.get(PrimaryDataStoreTO.STORAGE_HOST);
+                        managedStoragePoolName = details.get(PrimaryDataStoreTO.MANAGED_STORE_TARGET);
+                        managedStoragePoolRootVolumeName = details.get(PrimaryDataStoreTO.MANAGED_STORE_TARGET_ROOT_VOLUME);
+                        managedStoragePoolRootVolumeSize = details.get(PrimaryDataStoreTO.VOLUME_SIZE);
+                        chapInitiatorUsername = details.get(PrimaryDataStoreTO.CHAP_INITIATOR_USERNAME);
+                        chapInitiatorSecret = details.get(PrimaryDataStoreTO.CHAP_INITIATOR_SECRET);
+                    }
+                }
+
+                final SR destSr;
+
+                if (managed) {
+                    details = new HashMap<String, String>();
+
+                    details.put(DiskTO.STORAGE_HOST, storageHost);
+                    details.put(DiskTO.IQN, managedStoragePoolName);
+                    details.put(DiskTO.VOLUME_SIZE, managedStoragePoolRootVolumeSize);
+                    details.put(DiskTO.CHAP_INITIATOR_USERNAME, chapInitiatorUsername);
+                    details.put(DiskTO.CHAP_INITIATOR_SECRET, chapInitiatorSecret);
+
+                    destSr = hypervisorResource.prepareManagedSr(conn, details);
+                }
+                else {
+                    String srName = destStore.getUuid();
+                    Set<SR> srs = SR.getByNameLabel(conn, srName);
+
+                    if (srs.size() != 1) {
+                        String msg = "There are " + srs.size() + " SRs with same name: "
+ srName;
+
+                        s_logger.warn(msg);
+
+                        return new CopyCmdAnswer(msg);
+                    } else {
+                        destSr = srs.iterator().next();
+                    }
                 }
-                String pUuid = poolsr.getUuid(conn);
-                boolean isISCSI = IsISCSI(poolsr.getType(conn));
-                task = srcVdi.copyAsync2(conn, poolsr, null, null);
+
+                task = srcVdi.copyAsync2(conn, destSr, null, null);
+
                 // poll every 1 seconds ,
                 hypervisorResource.waitForTask(conn, task, 1000, wait * 1000);
                 hypervisorResource.checkForSuccess(conn, task);
-                VDI tmpl = Types.toVDI(task, conn);
-                VDI snapshotvdi = tmpl.snapshot(conn, new HashMap<String, String>());
-                snapshotvdi.setNameLabel(conn, "Template " + srcTemplate.getName());
-                tmpl.destroy(conn);
-                poolsr.scan(conn);
+
+                VDI tmplVdi = Types.toVDI(task, conn);
+
+                final String uuidToReturn;
+
+                if (managed) {
+                    uuidToReturn = tmplVdi.getUuid(conn);
+
+                    tmplVdi.setNameLabel(conn, managedStoragePoolRootVolumeName);
+                } else {
+                    VDI snapshotVdi = tmplVdi.snapshot(conn, new HashMap<String, String>());
+
+                    uuidToReturn = snapshotVdi.getUuid(conn);
+
+                    snapshotVdi.setNameLabel(conn, "Template " + srcTemplate.getName());
+
+                    tmplVdi.destroy(conn);
+                }
+
+                destSr.scan(conn);
+
                 try{
                     Thread.sleep(5000);
                 } catch (Exception e) {
                 }
 
                 TemplateObjectTO newVol = new TemplateObjectTO();
-                newVol.setUuid(snapshotvdi.getUuid(conn));
-                newVol.setPath(newVol.getUuid());
+
+                newVol.setUuid(uuidToReturn);
+                newVol.setPath(uuidToReturn);
                 newVol.setFormat(Storage.ImageFormat.VHD);
+
                 return new CopyCmdAnswer(newVol);
             }
-        }catch (Exception e) {
-            String msg = "Catch Exception " + e.getClass().getName() + " for template + "
+ " due to " + e.toString();
+        } catch (Exception e) {
+            String msg = "Catch Exception " + e.getClass().getName() + " for template due
to " + e.toString();
+
             s_logger.warn(msg, e);
+
             return new CopyCmdAnswer(msg);
         } finally {
-            if ( task != null ) {
+            if (task != null) {
                 try {
                     task.destroy(conn);
                 } catch (Exception e) {
-                    s_logger.debug("unable to destroy task(" + task.toWireString() + ") due
to " + e.toString());
+                    s_logger.debug("unable to destroy task (" + task.toWireString() + ")
due to " + e.toString());
                 }
             }
+
             if (srcSr != null) {
                 hypervisorResource.removeSR(conn, srcSr);
             }
         }
+
         return new CopyCmdAnswer("not implemented yet");
     }
 
     protected String backupSnapshot(Connection conn, String primaryStorageSRUuid, String
localMountPoint, String path, String secondaryStorageMountPath, String snapshotUuid, String
prevBackupUuid, String prevSnapshotUuid, Boolean isISCSI, int wait) {
-        String errMsg = null;
-        boolean mounted = false;
         boolean filesrcreated = false;
-        boolean copied = false;
+        // boolean copied = false;
+
         if (prevBackupUuid == null) {
             prevBackupUuid = "";
         }
@@ -250,7 +319,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor
{
                 hypervisorResource.waitForTask(conn, task, 1000, wait * 1000);
                 hypervisorResource.checkForSuccess(conn, task);
                 dvdi = Types.toVDI(task, conn);
-                copied = true;
+                // copied = true;
             } finally {
                 if (task != null) {
                     try {
@@ -328,7 +397,7 @@ public class Xenserver625StorageProcessor extends XenServerStorageProcessor
{
             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);
+            // String psUuid = primaryStorageSR.getUuid(conn);
             Boolean isISCSI = IsISCSI(primaryStorageSR.getType(conn));
 
             VDI snapshotVdi = getVDIbyUuid(conn, snapshotUuid);


Mime
View raw message