cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject git commit: updated refs/heads/volume-upload to 15ae33a
Date Tue, 20 Jan 2015 03:54:32 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/volume-upload f0b60c742 -> 15ae33a5b


volume upload: refactored post upload command and used it during template registration


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

Branch: refs/heads/volume-upload
Commit: 15ae33a5b6a1838ab346754545d2ebb28b5345b5
Parents: f0b60c7
Author: Rajani Karuturi <rajanikaruturi@gmail.com>
Authored: Tue Jan 20 09:23:20 2015 +0530
Committer: Rajani Karuturi <rajanikaruturi@gmail.com>
Committed: Tue Jan 20 09:24:14 2015 +0530

----------------------------------------------------------------------
 .../TemplateOrVolumePostUploadCommand.java      | 108 ++++++-------------
 ...ateOrVolumePostUploadCommandTypeAdapter.java |  52 ---------
 .../com/cloud/storage/VolumeApiServiceImpl.java |   7 +-
 .../template/HypervisorTemplateAdapter.java     |   6 +-
 .../com/cloud/template/TemplateManagerImpl.java |   7 +-
 .../resource/NfsSecondaryStorageResource.java   |   2 -
 6 files changed, 43 insertions(+), 139 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java
b/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java
index 78cfccb..8872798 100644
--- a/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java
+++ b/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommand.java
@@ -19,42 +19,56 @@
 
 package org.apache.cloudstack.storage.command;
 
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-
 public class TemplateOrVolumePostUploadCommand {
-    DataObject dataObject;
-    EndPoint endPoint;
 
     long entityId;
+
     String entityUUID;
+
     String absolutePath;
+
     String checksum;
+
     String type;
+
     String name;
-//    String installPathPrefix;
+
     String localPath;
-//    String isHvm;
+
+    boolean requiresHvm;
+
     String imageFormat;
+
     String dataTo;
+
     String dataToRole;
 
-    public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath,
String checksum, String type, String name,
-                                             String localPath, String imageFormat, String
dataTo, String dataToRole) {
+    String remoteEndPoint;
+
+    public TemplateOrVolumePostUploadCommand(long entityId, String entityUUID, String absolutePath,
String checksum, String type, String name, String imageFormat, String dataTo,
+            String dataToRole) {
         this.entityId = entityId;
         this.entityUUID = entityUUID;
         this.absolutePath = absolutePath;
         this.checksum = checksum;
         this.type = type;
         this.name = name;
-//        this.installPathPrefix = installPathPrefix;
-        this.localPath = localPath;
-//        this.isHvm = isHvm;
         this.imageFormat = imageFormat;
         this.dataTo = dataTo;
         this.dataToRole = dataToRole;
     }
 
+    public TemplateOrVolumePostUploadCommand() {
+    }
+
+    public String getRemoteEndPoint() {
+        return remoteEndPoint;
+    }
+
+    public void setRemoteEndPoint(String remoteEndPoint) {
+        this.remoteEndPoint = remoteEndPoint;
+    }
+
     public String getDataTo() {
         return dataTo;
     }
@@ -70,13 +84,6 @@ public class TemplateOrVolumePostUploadCommand {
     public void setDataToRole(String dataToRole) {
         this.dataToRole = dataToRole;
     }
-    //    public String getInstallPathPrefix() {
-//        return installPathPrefix;
-//    }
-//
-//    public void setInstallPathPrefix(String installPathPrefix) {
-//        this.installPathPrefix = installPathPrefix;
-//    }
 
     public String getLocalPath() {
         return localPath;
@@ -86,13 +93,13 @@ public class TemplateOrVolumePostUploadCommand {
         this.localPath = localPath;
     }
 
-//    public String getIsHvm() {
-//        return isHvm;
-//    }
+    public boolean getRequiresHvm() {
+        return requiresHvm;
+    }
 
-//    public void setIsHvm(String isHvm) {
-//        this.isHvm = isHvm;
-//    }
+    public void setRequiresHvm(boolean requiresHvm) {
+        this.requiresHvm = requiresHvm;
+    }
 
     public String getImageFormat() {
         return imageFormat;
@@ -149,55 +156,4 @@ public class TemplateOrVolumePostUploadCommand {
     public void setName(String name) {
         this.name = name;
     }
-
-    public TemplateOrVolumePostUploadCommand(DataObject dataObject, EndPoint endPoint) {
-        this.dataObject = dataObject;
-        this.endPoint = endPoint;
-    }
-
-    public TemplateOrVolumePostUploadCommand() {
-    }
-
-    public DataObject getDataObject() {
-        return dataObject;
-    }
-
-    public void setDataObject(DataObject dataObject) {
-        this.dataObject = dataObject;
-    }
-
-    public EndPoint getEndPoint() {
-        return endPoint;
-    }
-
-    public void setEndPoint(EndPoint endPoint) {
-        this.endPoint = endPoint;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-
-        TemplateOrVolumePostUploadCommand that = (TemplateOrVolumePostUploadCommand)o;
-
-        return dataObject.equals(that.dataObject) && endPoint.equals(that.endPoint);
-
-    }
-
-    @Override
-    public int hashCode() {
-        int result = dataObject.hashCode();
-        result = 31 * result + endPoint.hashCode();
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        return "TemplateOrVolumePostUploadCommand{" + "dataObject=" + dataObject + ", endPoint="
+ endPoint + '}';
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommandTypeAdapter.java
----------------------------------------------------------------------
diff --git a/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommandTypeAdapter.java
b/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommandTypeAdapter.java
deleted file mode 100644
index 1739917..0000000
--- a/core/src/org/apache/cloudstack/storage/command/TemplateOrVolumePostUploadCommandTypeAdapter.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.command;
-
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-
-import java.lang.reflect.Type;
-
-public class TemplateOrVolumePostUploadCommandTypeAdapter implements JsonSerializer<TemplateOrVolumePostUploadCommand>
{
-
-    @Override public JsonElement serialize(TemplateOrVolumePostUploadCommand src, Type typeOfSrc,
JsonSerializationContext context) {
-        JsonObject obj = new JsonObject();
-
-        EndPoint endPoint = src.getEndPoint();
-        JsonObject endpointJSON = new JsonObject();
-        endpointJSON.addProperty("id", endPoint.getId());
-        endpointJSON.addProperty("hostAddress", endPoint.getHostAddr());
-        endpointJSON.addProperty("publicAddr", endPoint.getPublicAddr());
-        obj.add(endPoint.getClass().getName(), endpointJSON);
-
-        DataObject dataObject = src.getDataObject();
-        JsonObject dataobjectJSON = new JsonObject();
-        dataobjectJSON.addProperty("id", dataObject.getId());
-        dataobjectJSON.addProperty("size", dataObject.getSize());
-        dataobjectJSON.addProperty("uuid", dataObject.getUuid());
-        dataobjectJSON.addProperty("type", String.valueOf(dataObject.getType()));
-        obj.add(dataObject.getClass().getName(), dataobjectJSON);
-
-        return obj;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 0512d4f..39ecf31 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -329,10 +329,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
           */
 
 
-        TemplateOrVolumePostUploadCommand command =
-            new TemplateOrVolumePostUploadCommand(vol.getId(), vol.getUuid(), volumeStore.getInstallPath(),
volumeStore.getChecksum(), vol.getType().toString(), vol.getName(),
-                                                  volumeStore.getLocalDownloadPath(), vol.getFormat().toString(),
dataObject.getDataStore().getUri(),
-                                                  dataObject.getDataStore().getRole().toString());
+        TemplateOrVolumePostUploadCommand command = new TemplateOrVolumePostUploadCommand(vol.getId(),
vol.getUuid(), volumeStore.getInstallPath(), volumeStore.getChecksum(), vol
+                .getType().toString(), vol.getName(), vol.getFormat().toString(), dataObject.getDataStore().getUri(),
dataObject.getDataStore().getRole().toString());
+        command.setLocalPath(volumeStore.getLocalDownloadPath());
         Gson gson = new GsonBuilder().create();
         String jsonPayload = gson.toJson(command);
         response.setMetadata(EncryptionUtil.encodeData(jsonPayload, key));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
index eecd84b..2f8a31d 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -256,7 +256,11 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
                 throw new CloudRuntimeException(errMsg);
             }
 
-            TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(templateOnStore,
ep);
+            TemplateOrVolumePostUploadCommand payload = new TemplateOrVolumePostUploadCommand(template.getId(),
template.getUuid(), tmpl.getInstallPath(), tmpl.getChecksum(), tmpl
+                    .getType().toString(), template.getName(), template.getFormat().toString(),
templateOnStore.getDataStore().getUri(), templateOnStore.getDataStore().getRole()
+                    .toString());
+            payload.setRemoteEndPoint(ep.getPublicAddr());
+            payload.setRequiresHvm(template.requiresHvm());
             payloads.add(payload);
         }
         _resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index aeb4b02..bf7ba11 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -39,7 +39,6 @@ import com.google.gson.GsonBuilder;
 import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd;
 import org.apache.cloudstack.api.response.GetUploadParamsResponse;
 import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand;
-import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommandTypeAdapter;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 
@@ -348,10 +347,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
              */
             TemplateOrVolumePostUploadCommand firstCommand = payload.get(0);
 
-            String url = "https://" + firstCommand.getEndPoint().getPublicAddr() + "/upload/"
+ firstCommand.getDataObject().getUuid();
+            String url = "https://" + firstCommand.getRemoteEndPoint() + "/upload/" + firstCommand.getEntityUUID();
             response.setPostURL(new URL(url));
 
-            response.setId(UUID.fromString(firstCommand.getDataObject().getUuid()));
+            response.setId(UUID.fromString(firstCommand.getEntityUUID()));
 
             /*
              * TODO: hardcoding the timeout to current + 60 min for now. This needs to goto
the database
@@ -365,7 +364,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
             /*
              * encoded metadata using the post upload config ssh key
              */
-            Gson gson = new GsonBuilder().registerTypeAdapter(TemplateOrVolumePostUploadCommand.class,
new TemplateOrVolumePostUploadCommandTypeAdapter()).create();
+            Gson gson = new GsonBuilder().create();
             String jsonPayload = gson.toJson(payload);
             response.setMetadata(EncryptionUtil.encodeData(jsonPayload, key));
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/15ae33a5/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 348dac7..cb12dc5 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -2717,8 +2717,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase
implements S
             if (httpRequest instanceof HttpEntityEnclosingRequest) {
                 entity = ((HttpEntityEnclosingRequest) httpRequest).getEntity();
             }
-            // For some reason, just putting the incoming entity into
-            // the response will not work. We have to buffer the message.
             byte[] data;
             if (entity == null) {
                 httpResponse.setEntity(new StringEntity("upload failed"));


Mime
View raw message