You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2013/05/03 08:22:17 UTC
[2/2] git commit: updated refs/heads/object_store to c60c373
Modify DownloadCommand to pass DataTO.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/c60c373a
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/c60c373a
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/c60c373a
Branch: refs/heads/object_store
Commit: c60c373a388d97692a9880766451005f052c8d39
Parents: 87fafb7
Author: Min Chen <mi...@citrix.com>
Authored: Thu May 2 23:05:19 2013 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Thu May 2 23:05:19 2013 -0700
----------------------------------------------------------------------
.../cloud/agent/api/storage/DownloadCommand.java | 242 ---------------
.../agent/api/storage/DownloadProgressCommand.java | 48 ---
.../api/storage/DownloadSystemTemplateCommand.java | 167 ----------
.../com/cloud/agent/api/storage/PasswordAuth.java | 39 +++
api/src/com/cloud/agent/api/storage/Proxy.java | 72 +++++
.../com/cloud/agent/api/storage/UploadCommand.java | 1 -
.../resource/CifsSecondaryStorageResource.java | 4 +-
.../resource/LocalNfsSecondaryStorageResource.java | 2 +-
.../resource/LocalSecondaryStorageResource.java | 4 +-
.../resource/NfsSecondaryStorageResource.java | 6 +-
.../cloud/storage/template/DownloadManager.java | 7 +-
.../storage/template/DownloadManagerImpl.java | 33 +--
.../storage/template/HttpTemplateDownloader.java | 58 ++--
.../storage/template/S3TemplateDownloader.java | 4 +-
.../cloud/storage/template/TemplateLocation.java | 2 +-
.../com/cloud/agent/transport/RequestTest.java | 8 +-
.../engine/subsystem/api/storage/DataObject.java | 4 +-
.../engine/subsystem/api/storage/TemplateInfo.java | 4 +-
.../engine/subsystem/api/storage/VolumeInfo.java | 1 +
.../storage/command/DownloadCommand.java | 182 +++++++++++
.../storage/command/DownloadProgressCommand.java | 49 +++
.../command/DownloadSystemTemplateCommand.java | 153 +++++++++
.../cloudstack/storage/to/TemplateObjectTO.java | 82 +++++-
.../cloudstack/storage/to/VolumeObjectTO.java | 35 ++-
.../storage/image/TemplateServiceImpl.java | 16 +-
.../storage/image/store/TemplateObject.java | 128 ++++++++-
.../storage/snapshot/SnapshotObject.java | 15 +-
.../cloudstack/storage/LocalHostEndpoint.java | 2 +-
.../cloudstack/storage/volume/VolumeObject.java | 22 +-
.../storage/volume/VolumeServiceImpl.java | 16 +-
.../cloud/agent/manager/MockStorageManager.java | 5 +-
.../agent/manager/MockStorageManagerImpl.java | 5 +-
.../cloud/agent/manager/SimulatorManagerImpl.java | 3 +
.../driver/CloudStackImageStoreDriverImpl.java | 13 +-
.../datastore/driver/S3ImageStoreDriverImpl.java | 14 +-
.../driver/SwiftImageStoreDriverImpl.java | 14 +-
.../storage/download/DownloadAbandonedState.java | 3 +-
.../storage/download/DownloadActiveState.java | 2 +-
.../storage/download/DownloadCompleteState.java | 3 +-
.../cloud/storage/download/DownloadErrorState.java | 2 +-
.../cloud/storage/download/DownloadListener.java | 8 +-
.../cloud/storage/download/DownloadMonitor.java | 6 +-
.../storage/download/DownloadMonitorImpl.java | 51 ++--
.../cloud/storage/download/NotDownloadedState.java | 3 +-
.../resource/DummySecondaryStorageResource.java | 4 +-
45 files changed, 861 insertions(+), 681 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/DownloadCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/DownloadCommand.java b/api/src/com/cloud/agent/api/storage/DownloadCommand.java
deleted file mode 100644
index 8abc29a..0000000
--- a/api/src/com/cloud/agent/api/storage/DownloadCommand.java
+++ /dev/null
@@ -1,242 +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 com.cloud.agent.api.storage;
-
-import java.net.URI;
-
-import org.apache.cloudstack.api.InternalIdentity;
-
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.agent.api.to.NfsTO;
-import com.cloud.storage.Storage.ImageFormat;
-import com.cloud.storage.Volume;
-import com.cloud.template.VirtualMachineTemplate;
-
-
-public class DownloadCommand extends AbstractDownloadCommand implements InternalIdentity {
- public static class PasswordAuth {
- String userName;
- String password;
- public PasswordAuth() {
-
- }
- public PasswordAuth(String user, String password) {
- this.userName = user;
- this.password = password;
- }
- public String getUserName() {
- return userName;
- }
- public String getPassword() {
- return password;
- }
- }
-
- public static enum ResourceType {
- VOLUME, TEMPLATE
- }
-
- public static class Proxy {
- private String _host;
- private int _port;
- private String _userName;
- private String _password;
-
- public Proxy() {
-
- }
-
- public Proxy(String host, int port, String userName, String password) {
- this._host = host;
- this._port = port;
- this._userName = userName;
- this._password = password;
- }
-
- public Proxy(URI uri) {
- this._host = uri.getHost();
- this._port = uri.getPort() == -1 ? 3128 : uri.getPort();
- String userInfo = uri.getUserInfo();
- if (userInfo != null) {
- String[] tokens = userInfo.split(":");
- if (tokens.length == 1) {
- this._userName = userInfo;
- this._password = "";
- } else if (tokens.length == 2) {
- this._userName = tokens[0];
- this._password = tokens[1];
- }
- }
- }
-
- public String getHost() {
- return _host;
- }
-
- public int getPort() {
- return _port;
- }
-
- public String getUserName() {
- return _userName;
- }
-
- public String getPassword() {
- return _password;
- }
- }
- private boolean hvm;
- private String description;
- private String checksum;
- private PasswordAuth auth;
- private Proxy _proxy;
- private Long maxDownloadSizeInBytes = null;
- private long id;
- private ResourceType resourceType = ResourceType.TEMPLATE;
- private DataStoreTO _store;
-
- protected DownloadCommand() {
- }
-
-
- public DownloadCommand(DownloadCommand that) {
- super(that);
- this.hvm = that.hvm;
- this.checksum = that.checksum;
- this.id = that.id;
- this.description = that.description;
- this.auth = that.getAuth();
- this.setSecUrl(that.getSecUrl());
- this.maxDownloadSizeInBytes = that.getMaxDownloadSizeInBytes();
- this.resourceType = that.resourceType;
- }
-
- public DownloadCommand(DataStoreTO store, VirtualMachineTemplate template, Long maxDownloadSizeInBytes) {
- super(template.getUniqueName(), template.getUrl(), template.getFormat(), template.getAccountId());
- this._store = store;
- this.hvm = template.isRequiresHvm();
- this.checksum = template.getChecksum();
- this.id = template.getId();
- this.description = template.getDisplayText();
- if (store instanceof NfsTO) {
- this.setSecUrl(((NfsTO) store).getUrl());
- }
- this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
- }
-
- public DownloadCommand(DataStoreTO store, Volume volume, Long maxDownloadSizeInBytes, String checkSum, String url, ImageFormat format) {
- super(volume.getName(), url, format, volume.getAccountId());
- //this.hvm = volume.isRequiresHvm();
- this.checksum = checkSum;
- this.id = volume.getId();
- this._store = store;
- this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
- this.resourceType = ResourceType.VOLUME;
- }
-
- public DownloadCommand(DataStoreTO store, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) {
- super(template.getUniqueName(), url, template.getFormat(), template.getAccountId());
- this._store = store;
- this.hvm = template.isRequiresHvm();
- this.checksum = template.getChecksum();
- this.id = template.getId();
- this.description = template.getDisplayText();
- if (store instanceof NfsTO) {
- this.setSecUrl(((NfsTO) store).getUrl());
- }
- this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
- auth = new PasswordAuth(user, passwd);
- }
-
- public long getId() {
- return id;
- }
-
- public void setHvm(boolean hvm) {
- this.hvm = hvm;
- }
-
- public boolean isHvm() {
- return hvm;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getChecksum() {
- return checksum;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setChecksum(String checksum) {
- this.checksum = checksum;
- }
-
- @Override
- public boolean executeInSequence() {
- return false;
- }
-
-
- public PasswordAuth getAuth() {
- return auth;
- }
-
- public void setCreds(String userName, String passwd) {
- auth = new PasswordAuth(userName, passwd);
- }
-
- public Proxy getProxy() {
- return _proxy;
- }
-
- public void setProxy(Proxy proxy) {
- _proxy = proxy;
- }
-
- public Long getMaxDownloadSizeInBytes() {
- return maxDownloadSizeInBytes;
- }
-
-
- public ResourceType getResourceType() {
- return resourceType;
- }
-
-
- public void setResourceType(ResourceType resourceType) {
- this.resourceType = resourceType;
- }
-
-
- public DataStoreTO getDataStore() {
- return _store;
- }
-
-
- public void setDataStore(DataStoreTO _store) {
- this._store = _store;
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/DownloadProgressCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/DownloadProgressCommand.java b/api/src/com/cloud/agent/api/storage/DownloadProgressCommand.java
deleted file mode 100644
index 835847b..0000000
--- a/api/src/com/cloud/agent/api/storage/DownloadProgressCommand.java
+++ /dev/null
@@ -1,48 +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 com.cloud.agent.api.storage;
-
-
-
-public class DownloadProgressCommand extends DownloadCommand {
- public static enum RequestType {GET_STATUS, ABORT, RESTART, PURGE, GET_OR_RESTART}
- private String jobId;
- private RequestType request;
-
- protected DownloadProgressCommand() {
- super();
- }
-
- public DownloadProgressCommand(DownloadCommand cmd, String jobId, RequestType req) {
- super(cmd);
-
- this.jobId = jobId;
- this.setRequest(req);
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setRequest(RequestType request) {
- this.request = request;
- }
-
- public RequestType getRequest() {
- return request;
- }
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/DownloadSystemTemplateCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/DownloadSystemTemplateCommand.java b/api/src/com/cloud/agent/api/storage/DownloadSystemTemplateCommand.java
deleted file mode 100644
index 13678e7..0000000
--- a/api/src/com/cloud/agent/api/storage/DownloadSystemTemplateCommand.java
+++ /dev/null
@@ -1,167 +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 com.cloud.agent.api.storage;
-
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.storage.DownloadCommand.Proxy;
-import com.cloud.agent.api.to.DataStoreTO;
-import com.cloud.template.VirtualMachineTemplate;
-
-
-public class DownloadSystemTemplateCommand extends Command {
- public static class PasswordAuth {
- String userName;
- String password;
- public PasswordAuth() {
-
- }
- public PasswordAuth(String user, String password) {
- this.userName = user;
- this.password = password;
- }
- public String getUserName() {
- return userName;
- }
- public String getPassword() {
- return password;
- }
- }
-
-
- private PasswordAuth auth;
- private Proxy _proxy;
- private DataStoreTO _store;
- private Long resourceId;
- private Long accountId;
- private String url;
- private Long maxDownloadSizeInBytes;
- private String name;
-
- protected DownloadSystemTemplateCommand() {
- }
-
-
-
- public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, VirtualMachineTemplate template, Long maxDownloadSizeInBytes) {
- this._store = store;
- this.accountId = template.getAccountId();
- this.url = secUrl;
- this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
- this.resourceId = template.getId();
- this.name = template.getUniqueName();
- }
-
-
- public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) {
- this._store = store;
- this.accountId = template.getAccountId();
- this.url = secUrl;
- this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
- this.resourceId = template.getId();
- auth = new PasswordAuth(user, passwd);
- this.name = template.getUniqueName();
- }
-
-
-
-
- public PasswordAuth getAuth() {
- return auth;
- }
-
- public void setCreds(String userName, String passwd) {
- auth = new PasswordAuth(userName, passwd);
- }
-
- public Proxy getProxy() {
- return _proxy;
- }
-
- public void setProxy(Proxy proxy) {
- _proxy = proxy;
- }
-
- public Long getMaxDownloadSizeInBytes() {
- return maxDownloadSizeInBytes;
- }
-
-
- public DataStoreTO getDataStore() {
- return _store;
- }
-
-
- public void setDataStore(DataStoreTO _store) {
- this._store = _store;
- }
-
-
- public Long getResourceId() {
- return resourceId;
- }
-
-
- public void setResourceId(Long resourceId) {
- this.resourceId = resourceId;
- }
-
-
-
- public Long getAccountId() {
- return accountId;
- }
-
-
-
- public void setAccountId(Long accountId) {
- this.accountId = accountId;
- }
-
-
-
- public String getUrl() {
- return url;
- }
-
-
-
- public void setUrl(String url) {
- this.url = url;
- }
-
-
-
- public String getName() {
- return name;
- }
-
-
-
- public void setName(String name) {
- this.name = name;
- }
-
-
-
- @Override
- public boolean executeInSequence() {
- // TODO Auto-generated method stub
- return false;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/PasswordAuth.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/PasswordAuth.java b/api/src/com/cloud/agent/api/storage/PasswordAuth.java
new file mode 100644
index 0000000..f03c584
--- /dev/null
+++ b/api/src/com/cloud/agent/api/storage/PasswordAuth.java
@@ -0,0 +1,39 @@
+// 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 com.cloud.agent.api.storage;
+
+/**
+ * Password authentication
+ */
+public class PasswordAuth {
+
+ String userName;
+ String password;
+ public PasswordAuth() {
+
+ }
+ public PasswordAuth(String user, String password) {
+ this.userName = user;
+ this.password = password;
+ }
+ public String getUserName() {
+ return userName;
+ }
+ public String getPassword() {
+ return password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/Proxy.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/Proxy.java b/api/src/com/cloud/agent/api/storage/Proxy.java
new file mode 100644
index 0000000..5adc114
--- /dev/null
+++ b/api/src/com/cloud/agent/api/storage/Proxy.java
@@ -0,0 +1,72 @@
+// 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 com.cloud.agent.api.storage;
+
+import java.net.URI;
+
+/**
+ * Download Proxy
+ */
+public class Proxy {
+ private String _host;
+ private int _port;
+ private String _userName;
+ private String _password;
+
+ public Proxy() {
+
+ }
+
+ public Proxy(String host, int port, String userName, String password) {
+ this._host = host;
+ this._port = port;
+ this._userName = userName;
+ this._password = password;
+ }
+
+ public Proxy(URI uri) {
+ this._host = uri.getHost();
+ this._port = uri.getPort() == -1 ? 3128 : uri.getPort();
+ String userInfo = uri.getUserInfo();
+ if (userInfo != null) {
+ String[] tokens = userInfo.split(":");
+ if (tokens.length == 1) {
+ this._userName = userInfo;
+ this._password = "";
+ } else if (tokens.length == 2) {
+ this._userName = tokens[0];
+ this._password = tokens[1];
+ }
+ }
+ }
+
+ public String getHost() {
+ return _host;
+ }
+
+ public int getPort() {
+ return _port;
+ }
+
+ public String getUserName() {
+ return _userName;
+ }
+
+ public String getPassword() {
+ return _password;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/api/src/com/cloud/agent/api/storage/UploadCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/storage/UploadCommand.java b/api/src/com/cloud/agent/api/storage/UploadCommand.java
index 473bd5b..9b893e2 100644
--- a/api/src/com/cloud/agent/api/storage/UploadCommand.java
+++ b/api/src/com/cloud/agent/api/storage/UploadCommand.java
@@ -18,7 +18,6 @@ package com.cloud.agent.api.storage;
import org.apache.cloudstack.api.InternalIdentity;
-import com.cloud.agent.api.storage.DownloadCommand.PasswordAuth;
import com.cloud.agent.api.to.TemplateTO;
import com.cloud.storage.Upload.Type;
import com.cloud.template.VirtualMachineTemplate;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/resource/CifsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/resource/CifsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/CifsSecondaryStorageResource.java
index 435e0f7..8ecdc35 100755
--- a/core/src/com/cloud/storage/resource/CifsSecondaryStorageResource.java
+++ b/core/src/com/cloud/storage/resource/CifsSecondaryStorageResource.java
@@ -27,6 +27,8 @@ import java.util.Random;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
@@ -48,8 +50,6 @@ import com.cloud.agent.api.StartupStorageCommand;
import com.cloud.agent.api.storage.CreateEntityDownloadURLCommand;
import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.UploadCommand;
import com.cloud.agent.api.storage.ssCommand;
import com.cloud.host.Host;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java
index 3b55e09..06933cc 100644
--- a/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java
+++ b/core/src/com/cloud/storage/resource/LocalNfsSecondaryStorageResource.java
@@ -11,13 +11,13 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
+import org.apache.cloudstack.storage.command.DownloadSystemTemplateCommand;
import org.springframework.stereotype.Component;
import com.amazonaws.services.s3.model.S3ObjectSummary;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadSystemTemplateCommand;
import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.NfsTO;
import com.cloud.agent.api.to.S3TO;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/resource/LocalSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/resource/LocalSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/LocalSecondaryStorageResource.java
index 5e97c15..7c1a81b 100644
--- a/core/src/com/cloud/storage/resource/LocalSecondaryStorageResource.java
+++ b/core/src/com/cloud/storage/resource/LocalSecondaryStorageResource.java
@@ -21,6 +21,8 @@ import java.util.Map;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
@@ -35,8 +37,6 @@ import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.SecStorageSetupCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupStorageCommand;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.ListTemplateAnswer;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.ssCommand;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
index efbfaf0..47d5ce7 100755
--- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
+++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
@@ -50,6 +50,9 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@@ -87,15 +90,12 @@ import com.cloud.agent.api.storage.DeleteEntityDownloadURLCommand;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.agent.api.storage.DeleteVolumeCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.ListTemplateAnswer;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.ListVolumeAnswer;
import com.cloud.agent.api.storage.ListVolumeCommand;
import com.cloud.agent.api.storage.UploadCommand;
import com.cloud.agent.api.storage.ssCommand;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.NfsTO;
import com.cloud.agent.api.to.S3TO;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/template/DownloadManager.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/DownloadManager.java b/core/src/com/cloud/storage/template/DownloadManager.java
index ec424ae..1897afd 100644
--- a/core/src/com/cloud/storage/template/DownloadManager.java
+++ b/core/src/com/cloud/storage/template/DownloadManager.java
@@ -18,10 +18,11 @@ package com.cloud.storage.template;
import java.util.Map;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
+
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadCommand.Proxy;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
+import com.cloud.agent.api.storage.Proxy;
import com.cloud.agent.api.to.S3TO;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.Storage.ImageFormat;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/template/DownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/DownloadManagerImpl.java b/core/src/com/cloud/storage/template/DownloadManagerImpl.java
index c1391a5..02a6256 100755
--- a/core/src/com/cloud/storage/template/DownloadManagerImpl.java
+++ b/core/src/com/cloud/storage/template/DownloadManagerImpl.java
@@ -47,6 +47,10 @@ import java.util.concurrent.Executors;
import javax.ejb.Local;
import javax.naming.ConfigurationException;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand.RequestType;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
@@ -56,11 +60,7 @@ import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadCommand.Proxy;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand.RequestType;
+import com.cloud.agent.api.storage.Proxy;
import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.S3TO;
import com.cloud.exception.InternalErrorException;
@@ -649,29 +649,8 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
return new DownloadAnswer("Invalid Name", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
}
- String installPathPrefix = null;
+ String installPathPrefix = cmd.getInstallPath();
DataStoreTO dstore = cmd.getDataStore();
- if (dstore instanceof S3TO) {
- if (resourceType == ResourceType.TEMPLATE) {
- // convention is no / in the end for install path based on
- // S3Utils implementation.
- // template key is
- // TEMPLATE_ROOT_DIR/account_id/template_id/template_name, by
- // adding template_name in the key, I can avoid generating a
- // template.properties file
- // for listTemplateCommand.
- installPathPrefix = join(asList(_templateDir, cmd.getAccountId(), cmd.getId(), cmd.getName()), S3Utils.SEPARATOR);
- } else {
- installPathPrefix = join(asList(_volumeDir, cmd.getAccountId(), cmd.getId()), S3Utils.SEPARATOR);
- }
- } else {
- if (ResourceType.TEMPLATE == resourceType) {
- installPathPrefix = resource.getRootDir(cmd) + File.separator + _templateDir;
- } else {
- installPathPrefix = resource.getRootDir(cmd) + File.separator + _volumeDir;
- }
- }
-
String user = null;
String password = null;
if (cmd.getAuth() != null) {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/HttpTemplateDownloader.java b/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
index 628ad64..56da8c0 100644
--- a/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
+++ b/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
@@ -29,6 +29,7 @@ import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.Date;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
@@ -45,8 +46,7 @@ import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.log4j.Logger;
-import com.cloud.agent.api.storage.DownloadCommand.Proxy;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
+import com.cloud.agent.api.storage.Proxy;
import com.cloud.storage.StorageLayer;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.Pair;
@@ -79,7 +79,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
private ResourceType resourceType = ResourceType.TEMPLATE;
private final HttpMethodRetryHandler myretryhandler;
-
+
public HttpTemplateDownloader (StorageLayer storageLayer, String downloadUrl, String toDir, DownloadCompleteCallback callback, long maxTemplateSizeInBytes, String user, String password, Proxy proxy, ResourceType resourceType) {
this._storage = storageLayer;
@@ -88,7 +88,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
this.status = TemplateDownloader.Status.NOT_STARTED;
this.resourceType = resourceType;
this.MAX_TEMPLATE_SIZE_IN_BYTES = maxTemplateSizeInBytes;
-
+
this.totalBytes = 0;
this.client = new HttpClient(s_httpClientManager);
@@ -114,7 +114,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
return false;
}
};
-
+
try {
this.request = new GetMethod(downloadUrl);
this.request.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, myretryhandler);
@@ -122,14 +122,14 @@ public class HttpTemplateDownloader implements TemplateDownloader {
//this.request.setFollowRedirects(false);
File f = File.createTempFile("dnld", "tmp_", new File(toDir));
-
+
if (_storage != null) {
_storage.setWorldReadableAndWriteable(f);
}
-
+
toFile = f.getAbsolutePath();
Pair<String, Integer> hostAndPort = validateUrl(downloadUrl);
-
+
if (proxy != null) {
client.getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort());
if (proxy.getUserName() != null) {
@@ -144,7 +144,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
s_logger.info("Added username=" + user + ", password=" + password + "for host " + hostAndPort.first() + ":" + hostAndPort.second());
} else {
s_logger.info("No credentials configured for host=" + hostAndPort.first() + ":" + hostAndPort.second());
- }
+ }
} catch (IllegalArgumentException iae) {
errorString = iae.getMessage();
status = TemplateDownloader.Status.UNRECOVERABLE_ERROR;
@@ -157,7 +157,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
s_logger.warn("throwable caught ", th);
}
}
-
+
private Pair<String, Integer> validateUrl(String url) throws IllegalArgumentException {
try {
@@ -169,13 +169,13 @@ public class HttpTemplateDownloader implements TemplateDownloader {
if (!(port == 80 || port == 443 || port == -1)) {
throw new IllegalArgumentException("Only ports 80 and 443 are allowed");
}
-
+
if (port == -1 && uri.getScheme().equalsIgnoreCase("https")) {
port = 443;
} else if (port == -1 && uri.getScheme().equalsIgnoreCase("http")) {
port = 80;
}
-
+
String host = uri.getHost();
try {
InetAddress hostAddr = InetAddress.getByName(host);
@@ -197,7 +197,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
throw new IllegalArgumentException(use.getMessage());
}
}
-
+
@Override
public long download(boolean resume, DownloadCompleteCallback callback) {
switch (status) {
@@ -211,17 +211,17 @@ public class HttpTemplateDownloader implements TemplateDownloader {
int bytes=0;
File file = new File(toFile);
try {
-
+
long localFileSize = 0;
if (file.exists() && resume) {
localFileSize = file.length();
s_logger.info("Resuming download to file (current size)=" + localFileSize);
}
-
+
Date start = new Date();
int responseCode=0;
-
+
if (localFileSize > 0 ) {
// require partial content support for resume
request.addRequestHeader("Range", "bytes=" + localFileSize + "-");
@@ -235,7 +235,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
errorString = " HTTP Server returned " + responseCode + " (expected 200 OK) ";
return 0; //FIXME: retry?
}
-
+
Header contentLengthHeader = request.getResponseHeader("Content-Length");
boolean chunked = false;
long remoteSize2 = 0;
@@ -255,26 +255,26 @@ public class HttpTemplateDownloader implements TemplateDownloader {
if (remoteSize == 0) {
remoteSize = remoteSize2;
}
-
+
if (remoteSize > MAX_TEMPLATE_SIZE_IN_BYTES) {
s_logger.info("Remote size is too large: " + remoteSize + " , max=" + MAX_TEMPLATE_SIZE_IN_BYTES);
status = Status.UNRECOVERABLE_ERROR;
errorString = "Download file size is too large";
return 0;
}
-
+
if (remoteSize == 0) {
remoteSize = MAX_TEMPLATE_SIZE_IN_BYTES;
}
-
+
InputStream in = !chunked?new BufferedInputStream(request.getResponseBodyAsStream())
: new ChunkedInputStream(request.getResponseBodyAsStream());
-
+
RandomAccessFile out = new RandomAccessFile(file, "rwd");
out.seek(localFileSize);
s_logger.info("Starting download from " + getDownloadUrl() + " to " + toFile + " remoteSize=" + remoteSize + " , max size=" + MAX_TEMPLATE_SIZE_IN_BYTES);
-
+
byte[] block = new byte[CHUNK_SIZE];
long offset=0;
boolean done=false;
@@ -298,7 +298,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
errorString = "Downloaded " + totalBytes + " bytes " + downloaded;
downloadTime += finish.getTime() - start.getTime();
out.close();
-
+
return totalBytes;
}catch (HttpException hte) {
status = TemplateDownloader.Status.UNRECOVERABLE_ERROR;
@@ -336,8 +336,8 @@ public class HttpTemplateDownloader implements TemplateDownloader {
public long getDownloadTime() {
return downloadTime;
}
-
-
+
+
public long getDownloadedBytes() {
return totalBytes;
}
@@ -375,7 +375,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
if (remoteSize == 0) {
return 0;
}
-
+
return (int)(100.0*totalBytes/remoteSize);
}
@@ -388,7 +388,7 @@ public class HttpTemplateDownloader implements TemplateDownloader {
errorString = "Failed to install: " + t.getMessage();
status = TemplateDownloader.Status.UNRECOVERABLE_ERROR;
}
-
+
}
@Override
@@ -424,10 +424,10 @@ public class HttpTemplateDownloader implements TemplateDownloader {
return toDir;
}
- public long getMaxTemplateSizeInBytes() {
+ public long getMaxTemplateSizeInBytes() {
return this.MAX_TEMPLATE_SIZE_IN_BYTES;
}
-
+
public static void main(String[] args) {
String url ="http:// dev.mysql.com/get/Downloads/MySQL-5.0/mysql-noinstall-5.0.77-win32.zip/from/http://mirror.services.wisc.edu/mysql/";
try {
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/template/S3TemplateDownloader.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/S3TemplateDownloader.java b/core/src/com/cloud/storage/template/S3TemplateDownloader.java
index 23f11ab..84b2b10 100644
--- a/core/src/com/cloud/storage/template/S3TemplateDownloader.java
+++ b/core/src/com/cloud/storage/template/S3TemplateDownloader.java
@@ -32,6 +32,7 @@ import java.net.URL;
import java.net.UnknownHostException;
import java.util.Date;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.commons.httpclient.ChunkedInputStream;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.Header;
@@ -52,8 +53,7 @@ import com.amazonaws.services.s3.model.ProgressEvent;
import com.amazonaws.services.s3.model.ProgressListener;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.StorageClass;
-import com.cloud.agent.api.storage.DownloadCommand.Proxy;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
+import com.cloud.agent.api.storage.Proxy;
import com.cloud.agent.api.to.S3TO;
import com.cloud.utils.Pair;
import com.cloud.utils.S3Utils;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/src/com/cloud/storage/template/TemplateLocation.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/TemplateLocation.java b/core/src/com/cloud/storage/template/TemplateLocation.java
index 515b1f2..eb7a6ec 100644
--- a/core/src/com/cloud/storage/template/TemplateLocation.java
+++ b/core/src/com/cloud/storage/template/TemplateLocation.java
@@ -24,9 +24,9 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
+import org.apache.cloudstack.storage.command.DownloadCommand.ResourceType;
import org.apache.log4j.Logger;
-import com.cloud.agent.api.storage.DownloadCommand.ResourceType;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.StorageLayer;
import com.cloud.storage.template.Processor.FormatInfo;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/core/test/com/cloud/agent/transport/RequestTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/transport/RequestTest.java b/core/test/com/cloud/agent/transport/RequestTest.java
index 50ea160..141beb8 100644
--- a/core/test/com/cloud/agent/transport/RequestTest.java
+++ b/core/test/com/cloud/agent/transport/RequestTest.java
@@ -20,6 +20,8 @@ import java.nio.ByteBuffer;
import junit.framework.TestCase;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
@@ -30,7 +32,6 @@ import com.cloud.agent.api.GetHostStatsCommand;
import com.cloud.agent.api.SecStorageFirewallCfgCommand;
import com.cloud.agent.api.UpdateHostPasswordCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.agent.api.to.NfsTO;
import com.cloud.exception.UnsupportedVersionException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -132,7 +133,10 @@ public class RequestTest extends TestCase {
s_logger.info("Testing Download answer");
VMTemplateVO template = new VMTemplateVO(1, "templatename", ImageFormat.QCOW2, true, true, true, TemplateType.USER, "url", true, 32, 1, "chksum", "displayText", true, 30, true,
HypervisorType.KVM, null);
- DownloadCommand cmd = new DownloadCommand(new NfsTO("secUrl", DataStoreRole.Image), template, 30000000l);
+ NfsTO nfs = new NfsTO("secUrl", DataStoreRole.Image);
+ TemplateObjectTO to = new TemplateObjectTO(template);
+ to.setImageDataStore(nfs);
+ DownloadCommand cmd = new DownloadCommand(to, 30000000l);
Request req = new Request(1, 1, cmd, true);
req.logD("Debug for Download");
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
index 9bb14c7..8ffed6a 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataObject.java
@@ -18,8 +18,6 @@
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
-
import com.cloud.agent.api.Answer;
public interface DataObject {
@@ -29,7 +27,7 @@ public interface DataObject {
public DataStore getDataStore();
public Long getSize();
public DataObjectType getType();
- public DiskFormat getFormat();
+ //public DiskFormat getFormat();
public String getUuid();
public void processEvent(ObjectInDataStoreStateMachine.Event event);
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
index 2b7eadc..3ee1d2f 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/TemplateInfo.java
@@ -18,7 +18,9 @@
*/
package org.apache.cloudstack.engine.subsystem.api.storage;
-public interface TemplateInfo extends DataObject {
+import com.cloud.template.VirtualMachineTemplate;
+
+public interface TemplateInfo extends DataObject, VirtualMachineTemplate {
public String getUniqueName();
public String getInstallPath();
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
index 7165f37..b02eaf1 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/VolumeInfo.java
@@ -28,4 +28,5 @@ public interface VolumeInfo extends DataObject, Volume {
public HypervisorType getHypervisorType();
public Long getLastPoolId();
public String getAttachedVmName();
+ public String getInstallPath();
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/storage/command/DownloadCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DownloadCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/DownloadCommand.java
new file mode 100644
index 0000000..d70c786
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/storage/command/DownloadCommand.java
@@ -0,0 +1,182 @@
+// 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 org.apache.cloudstack.api.InternalIdentity;
+import org.apache.cloudstack.storage.to.TemplateObjectTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+
+import com.cloud.agent.api.storage.AbstractDownloadCommand;
+import com.cloud.agent.api.storage.PasswordAuth;
+import com.cloud.agent.api.storage.Proxy;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.NfsTO;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.Volume;
+
+
+public class DownloadCommand extends AbstractDownloadCommand implements InternalIdentity {
+
+ public static enum ResourceType {
+ VOLUME, TEMPLATE
+ }
+
+ private boolean hvm;
+ private String description;
+ private String checksum;
+ private PasswordAuth auth;
+ private Proxy _proxy;
+ private Long maxDownloadSizeInBytes = null;
+ private long id;
+ private ResourceType resourceType = ResourceType.TEMPLATE;
+ private String installPath;
+ private DataStoreTO _store;
+
+ protected DownloadCommand() {
+ }
+
+
+ public DownloadCommand(DownloadCommand that) {
+ super(that);
+ this.hvm = that.hvm;
+ this.checksum = that.checksum;
+ this.id = that.id;
+ this.description = that.description;
+ this.auth = that.getAuth();
+ this.setSecUrl(that.getSecUrl());
+ this.maxDownloadSizeInBytes = that.getMaxDownloadSizeInBytes();
+ this.resourceType = that.resourceType;
+ this.installPath = that.installPath;
+ this._store = that._store;
+ }
+
+ public DownloadCommand(TemplateObjectTO template, Long maxDownloadSizeInBytes) {
+ super(template.getName(), template.getOrigUrl(), template.getFormat(), template.getAccountId());
+ this._store = template.getDataStore();
+ this.installPath = template.getPath();
+ this.hvm = template.isRequiresHvm();
+ this.checksum = template.getChecksum();
+ this.id = template.getId();
+ this.description = template.getDescription();
+ if (_store instanceof NfsTO) {
+ this.setSecUrl(((NfsTO) _store).getUrl());
+ }
+ this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
+ }
+
+ public DownloadCommand(TemplateObjectTO template, String user, String passwd, Long maxDownloadSizeInBytes) {
+ this(template, maxDownloadSizeInBytes);
+ auth = new PasswordAuth(user, passwd);
+ }
+
+ public DownloadCommand(VolumeObjectTO volume, Long maxDownloadSizeInBytes, String checkSum, String url, ImageFormat format) {
+ super(volume.getName(), url, format, volume.getAccountId());
+ this.checksum = checkSum;
+ this.id = volume.getVolumeId();
+ this._store = volume.getDataStore();
+ this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
+ this.resourceType = ResourceType.VOLUME;
+ }
+ @Override
+ public long getId() {
+ return id;
+ }
+
+ public void setHvm(boolean hvm) {
+ this.hvm = hvm;
+ }
+
+ public boolean isHvm() {
+ return hvm;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getChecksum() {
+ return checksum;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+
+ @Override
+ public boolean executeInSequence() {
+ return false;
+ }
+
+
+ public PasswordAuth getAuth() {
+ return auth;
+ }
+
+ public void setCreds(String userName, String passwd) {
+ auth = new PasswordAuth(userName, passwd);
+ }
+
+ public Proxy getProxy() {
+ return _proxy;
+ }
+
+ public void setProxy(Proxy proxy) {
+ _proxy = proxy;
+ }
+
+ public Long getMaxDownloadSizeInBytes() {
+ return maxDownloadSizeInBytes;
+ }
+
+
+ public ResourceType getResourceType() {
+ return resourceType;
+ }
+
+
+ public void setResourceType(ResourceType resourceType) {
+ this.resourceType = resourceType;
+ }
+
+
+ public DataStoreTO getDataStore() {
+ return _store;
+ }
+
+
+ public void setDataStore(DataStoreTO _store) {
+ this._store = _store;
+ }
+
+
+ public String getInstallPath() {
+ return installPath;
+ }
+
+
+ public void setInstallPath(String installPath) {
+ this.installPath = installPath;
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/storage/command/DownloadProgressCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DownloadProgressCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/DownloadProgressCommand.java
new file mode 100644
index 0000000..72ca901
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/storage/command/DownloadProgressCommand.java
@@ -0,0 +1,49 @@
+// 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;
+
+
+
+
+public class DownloadProgressCommand extends DownloadCommand {
+ public static enum RequestType {GET_STATUS, ABORT, RESTART, PURGE, GET_OR_RESTART}
+ private String jobId;
+ private RequestType request;
+
+ protected DownloadProgressCommand() {
+ super();
+ }
+
+ public DownloadProgressCommand(DownloadCommand cmd, String jobId, RequestType req) {
+ super(cmd);
+
+ this.jobId = jobId;
+ this.setRequest(req);
+ }
+
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setRequest(RequestType request) {
+ this.request = request;
+ }
+
+ public RequestType getRequest() {
+ return request;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/storage/command/DownloadSystemTemplateCommand.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/command/DownloadSystemTemplateCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/DownloadSystemTemplateCommand.java
new file mode 100644
index 0000000..864f5b6
--- /dev/null
+++ b/engine/api/src/org/apache/cloudstack/storage/command/DownloadSystemTemplateCommand.java
@@ -0,0 +1,153 @@
+// 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.cloud.agent.api.Command;
+import com.cloud.agent.api.storage.PasswordAuth;
+import com.cloud.agent.api.storage.Proxy;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.template.VirtualMachineTemplate;
+
+
+public class DownloadSystemTemplateCommand extends Command {
+
+
+ private PasswordAuth auth;
+ private Proxy _proxy;
+ private DataStoreTO _store;
+ private Long resourceId;
+ private Long accountId;
+ private String url;
+ private Long maxDownloadSizeInBytes;
+ private String name;
+
+ protected DownloadSystemTemplateCommand() {
+ }
+
+
+
+ public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, VirtualMachineTemplate template, Long maxDownloadSizeInBytes) {
+ this._store = store;
+ this.accountId = template.getAccountId();
+ this.url = secUrl;
+ this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
+ this.resourceId = template.getId();
+ this.name = template.getUniqueName();
+ }
+
+
+ public DownloadSystemTemplateCommand(DataStoreTO store, String secUrl, String url, VirtualMachineTemplate template, String user, String passwd, Long maxDownloadSizeInBytes) {
+ this._store = store;
+ this.accountId = template.getAccountId();
+ this.url = secUrl;
+ this.maxDownloadSizeInBytes = maxDownloadSizeInBytes;
+ this.resourceId = template.getId();
+ auth = new PasswordAuth(user, passwd);
+ this.name = template.getUniqueName();
+ }
+
+
+
+
+ public PasswordAuth getAuth() {
+ return auth;
+ }
+
+ public void setCreds(String userName, String passwd) {
+ auth = new PasswordAuth(userName, passwd);
+ }
+
+ public Proxy getProxy() {
+ return _proxy;
+ }
+
+ public void setProxy(Proxy proxy) {
+ _proxy = proxy;
+ }
+
+ public Long getMaxDownloadSizeInBytes() {
+ return maxDownloadSizeInBytes;
+ }
+
+
+ public DataStoreTO getDataStore() {
+ return _store;
+ }
+
+
+ public void setDataStore(DataStoreTO _store) {
+ this._store = _store;
+ }
+
+
+ public Long getResourceId() {
+ return resourceId;
+ }
+
+
+ public void setResourceId(Long resourceId) {
+ this.resourceId = resourceId;
+ }
+
+
+
+ public Long getAccountId() {
+ return accountId;
+ }
+
+
+
+ public void setAccountId(Long accountId) {
+ this.accountId = accountId;
+ }
+
+
+
+ public String getUrl() {
+ return url;
+ }
+
+
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+
+
+ public String getName() {
+ return name;
+ }
+
+
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+
+ @Override
+ public boolean executeInSequence() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
index 986a4fc..aad5d71 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/TemplateObjectTO.java
@@ -23,40 +23,86 @@ import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.template.VirtualMachineTemplate;
public class TemplateObjectTO implements DataTO {
private String path;
private String origUrl;
private String uuid;
- private DiskFormat diskType;
+ private long id;
+ private ImageFormat format;
+ private long accountId;
+ private String checksum;
+ private boolean hvm;
+ private String displayText;
private DataStoreTO imageDataStore;
private String name;
public TemplateObjectTO() {
-
+
}
+
+ public TemplateObjectTO(VirtualMachineTemplate template){
+ this.uuid = template.getUuid();
+ this.id = template.getId();
+ this.origUrl = template.getUrl();
+ this.displayText = template.getDisplayText();
+ this.checksum = template.getChecksum();
+ this.hvm = template.isRequiresHvm();
+ this.accountId = template.getAccountId();
+ this.name = template.getUniqueName();
+ this.format = template.getFormat();
+ }
+
public TemplateObjectTO(TemplateInfo template) {
this.path = template.getInstallPath();
this.uuid = template.getUuid();
- this.origUrl = template.getUri();
- //this.diskType = template.getDiskType();
- this.imageDataStore = template.getDataStore().getTO();
+ this.id = template.getId();
+ this.origUrl = template.getUrl();
+ this.displayText = template.getDisplayText();
+ this.checksum = template.getChecksum();
+ this.hvm = template.isRequiresHvm();
+ this.accountId = template.getAccountId();
this.name = template.getUniqueName();
+ this.format = template.getFormat();
+ this.imageDataStore = template.getDataStore().getTO();
}
-
+
@Override
public String getPath() {
return this.path;
}
-
+
public String getUuid() {
return this.uuid;
}
-
- public DiskFormat getDiskType() {
- return this.diskType;
+
+ public long getId() {
+ return id;
+ }
+ public ImageFormat getFormat() {
+ return format;
+ }
+ public long getAccountId() {
+ return accountId;
+ }
+ public String getChecksum() {
+ return checksum;
+ }
+ public boolean isRequiresHvm() {
+ return hvm;
+ }
+ public void setRequiresHvm(boolean hvm){
+ this.hvm = hvm;
+ }
+ public String getDescription() {
+ return displayText;
+ }
+
+ public void setDescription(String desc){
+ this.displayText = desc;
}
-
public DataStoreTO getImageDataStore() {
return this.imageDataStore;
}
@@ -92,4 +138,18 @@ public class TemplateObjectTO implements DataTO {
public void setOrigUrl(String origUrl) {
this.origUrl = origUrl;
}
+ public void setFormat(ImageFormat format) {
+ this.format = format;
+ }
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+ public void setChecksum(String checksum) {
+ this.checksum = checksum;
+ }
+ public void setImageDataStore(DataStoreTO imageDataStore) {
+ this.imageDataStore = imageDataStore;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
index 4ca1f9b..0b88469 100644
--- a/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
+++ b/engine/api/src/org/apache/cloudstack/storage/to/VolumeObjectTO.java
@@ -33,16 +33,16 @@ public class VolumeObjectTO implements DataTO {
private long size;
private String path;
private Long volumeId;
-
+ private long accountId;
+
public VolumeObjectTO() {
}
-
+
public VolumeObjectTO(VolumeInfo volume) {
this.uuid = volume.getUuid();
this.path = volume.getUri();
- //this.volumeType = volume.getType();
- //this.diskType = volume.getDiskType();
+ this.accountId = volume.getAccountId();
if (volume.getDataStore() != null) {
this.dataStore = volume.getDataStore().getTO();
} else {
@@ -52,39 +52,39 @@ public class VolumeObjectTO implements DataTO {
this.size = volume.getSize();
this.setVolumeId(volume.getId());
}
-
+
public String getUuid() {
return this.uuid;
}
-
+
public String getPath() {
return this.path;
}
-
+
public VolumeType getVolumeType() {
return this.volumeType;
}
-
+
public DiskFormat getDiskType() {
return this.diskType;
}
-
+
public DataStoreTO getDataStore() {
return this.dataStore;
}
-
+
public void setDataStore(PrimaryDataStoreTO dataStore) {
this.dataStore = dataStore;
}
-
+
public String getName() {
return this.name;
}
-
+
public long getSize() {
return this.size;
}
-
+
public DataObjectType getObjectType() {
return DataObjectType.VOLUME;
}
@@ -113,4 +113,13 @@ public class VolumeObjectTO implements DataTO {
this.volumeId = volumeId;
}
+ public long getAccountId() {
+ return accountId;
+ }
+
+ public void setAccountId(long accountId) {
+ this.accountId = accountId;
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index 79555d4..60b3f53 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -187,13 +187,13 @@ public class TemplateServiceImpl implements TemplateService {
@Override
public void handleSysTemplateDownload(HypervisorType hostHyper, Long dcId) {
Set<VMTemplateVO> toBeDownloaded = new HashSet<VMTemplateVO>();
- List<DataStore> ssHosts = this._storeMgr.getImageStoresByScope(new ZoneScope(dcId));
- if (ssHosts == null || ssHosts.isEmpty()){
+ List<DataStore> stores = this._storeMgr.getImageStoresByScope(new ZoneScope(dcId));
+ if (stores == null || stores.isEmpty()){
return;
}
/*Download all the templates in zone with the same hypervisortype*/
- for ( DataStore ssHost : ssHosts) {
+ for ( DataStore store : stores) {
List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
List<VMTemplateVO> defaultBuiltin = _templateDao.listDefaultBuiltinTemplates();
@@ -211,10 +211,10 @@ public class TemplateServiceImpl implements TemplateService {
}
for (VMTemplateVO template: toBeDownloaded) {
- TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(ssHost.getId(), template.getId());
+ TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(store.getId(), template.getId());
if (tmpltHost == null || tmpltHost.getState() != ObjectInDataStoreStateMachine.State.Ready) {
- DataObject tmpl = this._templateFactory.getTemplate(template.getId(), ssHost);
- _dlMonitor.downloadTemplateToStorage(tmpl, ssHost, null);
+ TemplateInfo tmplt = this._templateFactory.getTemplate(template.getId());
+ this.createTemplateAsync(tmplt, store, null);
}
}
}
@@ -370,8 +370,8 @@ public class TemplateServiceImpl implements TemplateService {
}
s_logger.debug("Template " + tmplt.getName() + " needs to be downloaded to " + store.getName());
//TODO: we should pass a callback here
- DataObject tmpl = this._templateFactory.getTemplate(tmplt.getId(), store);
- _dlMonitor.downloadTemplateToStorage(tmpl, store, null);
+ TemplateInfo tmpl = this._templateFactory.getTemplate(tmplt.getId());
+ this.createTemplateAsync(tmpl, store, null);
}
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index e31b459..7ff0cc3 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -18,6 +18,9 @@
*/
package org.apache.cloudstack.storage.image.store;
+import java.util.Date;
+import java.util.Map;
+
import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
@@ -28,7 +31,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
@@ -38,7 +40,10 @@ import org.apache.cloudstack.storage.to.TemplateObjectTO;
import org.apache.log4j.Logger;
import com.cloud.agent.api.Answer;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
@@ -108,9 +113,9 @@ public class TemplateObject implements TemplateInfo {
@Override
public String getUri() {
VMTemplateVO image = imageDao.findById(this.imageVO.getId());
-
+
return image.getUrl();
-
+
}
@Override
@@ -153,8 +158,8 @@ public class TemplateObject implements TemplateInfo {
}
@Override
- public DiskFormat getFormat() {
- return DiskFormat.valueOf(this.imageVO.getFormat().toString());
+ public ImageFormat getFormat() {
+ return this.imageVO.getFormat();
}
public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
@@ -188,7 +193,7 @@ public class TemplateObject implements TemplateInfo {
templatePoolRef.setInstallPath(newTemplate.getPath());
templatePoolDao.update(templatePoolRef.getId(), templatePoolRef);
}
- } else if (this.getDataStore().getRole() == DataStoreRole.Image ||
+ } else if (this.getDataStore().getRole() == DataStoreRole.Image ||
this.getDataStore().getRole() == DataStoreRole.ImageCache) {
if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
@@ -221,4 +226,115 @@ public class TemplateObject implements TemplateInfo {
DataObjectInStore obj = ojbectInStoreMgr.findObject(this, this.dataStore);
return obj.getInstallPath();
}
+
+ @Override
+ public long getAccountId() {
+ return this.imageVO.getAccountId();
+ }
+
+ @Override
+ public boolean isFeatured() {
+ return this.imageVO.isFeatured();
+ }
+
+ @Override
+ public boolean isPublicTemplate() {
+ return this.imageVO.isPublicTemplate();
+ }
+
+ @Override
+ public boolean isExtractable() {
+ return this.imageVO.isExtractable();
+ }
+
+ @Override
+ public String getName() {
+ return this.imageVO.getName();
+ }
+
+ @Override
+ public boolean isRequiresHvm() {
+ return this.imageVO.isRequiresHvm();
+ }
+
+ @Override
+ public String getDisplayText() {
+ return this.imageVO.getDisplayText();
+ }
+
+ @Override
+ public boolean getEnablePassword() {
+ return this.imageVO.getEnablePassword();
+ }
+
+ @Override
+ public boolean getEnableSshKey() {
+ return this.imageVO.getEnableSshKey();
+ }
+
+ @Override
+ public boolean isCrossZones() {
+ return this.imageVO.isCrossZones();
+ }
+
+ @Override
+ public Date getCreated() {
+ return this.imageVO.getCreated();
+ }
+
+ @Override
+ public long getGuestOSId() {
+ return this.imageVO.getGuestOSId();
+ }
+
+ @Override
+ public boolean isBootable() {
+ return this.imageVO.isBootable();
+ }
+
+ @Override
+ public TemplateType getTemplateType() {
+ return this.imageVO.getTemplateType();
+ }
+
+ @Override
+ public HypervisorType getHypervisorType() {
+ return this.imageVO.getHypervisorType();
+ }
+
+ @Override
+ public int getBits() {
+ return this.imageVO.getBits();
+ }
+
+ @Override
+ public String getUrl() {
+ return this.imageVO.getUrl();
+ }
+
+ @Override
+ public String getChecksum() {
+ return this.imageVO.getChecksum();
+ }
+
+ @Override
+ public Long getSourceTemplateId() {
+ return this.imageVO.getSourceTemplateId();
+ }
+
+ @Override
+ public String getTemplateTag() {
+ return this.imageVO.getTemplateTag();
+ }
+
+ @Override
+ public Map getDetails() {
+ return this.imageVO.getDetails();
+ }
+
+ @Override
+ public long getDomainId() {
+ return this.imageVO.getDomainId();
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index c19efb0..f5800c1 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -30,7 +30,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.command.CreateObjectAnswer;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
@@ -93,12 +92,12 @@ public class SnapshotObject implements SnapshotInfo {
if (snapStoreVO == null) {
return null;
}
-
+
long parentId = snapStoreVO.getParentSnapshotId();
if (parentId == 0) {
return null;
}
-
+
return this.snapshotFactory.getSnapshot(parentId, store);
}
@@ -145,10 +144,6 @@ public class SnapshotObject implements SnapshotInfo {
return DataObjectType.SNAPSHOT;
}
- @Override
- public DiskFormat getFormat() {
- return null;
- }
@Override
public String getUuid() {
@@ -247,7 +242,7 @@ public class SnapshotObject implements SnapshotInfo {
@Override
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
- SnapshotDataStoreVO snapshotStore = this.snapshotStoreDao.findByStoreSnapshot(this.getDataStore().getRole(),
+ SnapshotDataStoreVO snapshotStore = this.snapshotStoreDao.findByStoreSnapshot(this.getDataStore().getRole(),
this.getDataStore().getId(), this.getId());
if (answer instanceof CreateObjectAnswer) {
SnapshotObjectTO snapshotTO = (SnapshotObjectTO)((CreateObjectAnswer) answer).getData();
@@ -274,7 +269,7 @@ public class SnapshotObject implements SnapshotInfo {
@Override
public void addPayload(Object data) {
// TODO Auto-generated method stub
-
+
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java b/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java
index 37e1535..ea93560 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/LocalHostEndpoint.java
@@ -7,12 +7,12 @@ import java.util.concurrent.TimeUnit;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.command.DownloadCommand;
import com.cloud.agent.Listener;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
import com.cloud.resource.ServerResource;
import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.download.DownloadListener;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
index 567905d..31a2e6f 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeObject.java
@@ -26,7 +26,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataTO;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
import org.apache.cloudstack.storage.command.CopyCmdAnswer;
import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
@@ -78,7 +77,8 @@ public class VolumeObject implements VolumeInfo {
vo.configure(dataStore, volumeVO);
return vo;
}
-
+
+ @Override
public String getAttachedVmName() {
Long vmId = this.volumeVO.getInstanceId();
if (vmId != null) {
@@ -97,14 +97,15 @@ public class VolumeObject implements VolumeInfo {
return volumeVO.getUuid();
}
- public void setPath(String uuid) {
- volumeVO.setPath(uuid);
+ public void setUuid(String uuid) {
+ volumeVO.setUuid(uuid);
}
public void setSize(Long size) {
volumeVO.setSize(size);
}
+ @Override
public Volume.State getState() {
return volumeVO.getState();
}
@@ -119,6 +120,12 @@ public class VolumeObject implements VolumeInfo {
return volumeVO.getSize();
}
+ @Override
+ public String getInstallPath() {
+ DataObjectInStore obj = ojbectInStoreMgr.findObject(this, this.dataStore);
+ return obj.getInstallPath();
+ }
+
public long getVolumeId() {
return volumeVO.getId();
}
@@ -174,11 +181,6 @@ public class VolumeObject implements VolumeInfo {
return DataObjectType.VOLUME;
}
- @Override
- public DiskFormat getFormat() {
- // TODO Auto-generated method stub
- return null;
- }
@Override
public void processEvent(
@@ -388,7 +390,7 @@ public class VolumeObject implements VolumeInfo {
this.volumeStoreDao.update(volStore.getId(), volStore);
}
}
-
+
this.processEvent(event);
}
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 4e39dde..2159733 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -70,7 +70,6 @@ import com.cloud.storage.Volume.Type;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.storage.download.DownloadMonitor;
-import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.storage.template.TemplateProp;
import com.cloud.user.AccountManager;
@@ -643,9 +642,9 @@ public class VolumeServiceImpl implements VolumeService {
AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();
DataObject volumeOnStore = store.create(volume);
-
+
volumeOnStore.processEvent(Event.CreateOnlyRequested);
-
+
CreateVolumeContext<VolumeApiResult> context = new CreateVolumeContext<VolumeApiResult>(null, volumeOnStore, future);
AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().registerVolumeCallback(null, null))
@@ -657,7 +656,7 @@ public class VolumeServiceImpl implements VolumeService {
protected Void registerVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CreateCmdResult> callback, CreateVolumeContext<VolumeApiResult> context) {
CreateCmdResult result = callback.getResult();
-
+
VolumeObject vo = (VolumeObject)context.volume;
if (result.isFailed()) {
vo.processEvent(Event.OperationFailed);
@@ -813,7 +812,8 @@ public class VolumeServiceImpl implements VolumeService {
}
s_logger.debug("Volume " + volumeHost.getVolumeId() + " needs to be downloaded to " + store.getName());
//TODO: pass a callback later
- downloadMonitor.downloadVolumeToStorage(this.volFactory.getVolume(volumeHost.getVolumeId()), store, volumeHost.getDownloadUrl(), volumeHost.getChecksum(), volumeHost.getFormat(), null);
+ VolumeInfo vol = this.volFactory.getVolume(volumeHost.getVolumeId());
+ this.createVolumeAsync(vol, store);
}
}
@@ -843,12 +843,12 @@ public class VolumeServiceImpl implements VolumeService {
return null;
}
-
+
@Override
public SnapshotInfo takeSnapshot(VolumeInfo volume) {
VolumeObject vol = (VolumeObject)volume;
vol.stateTransit(Volume.Event.SnapshotRequested);
-
+
SnapshotInfo snapshot = null;
try {
snapshot = this.snapshotMgr.takeSnapshot(volume);
@@ -861,7 +861,7 @@ public class VolumeServiceImpl implements VolumeService {
vol.stateTransit(Volume.Event.OperationFailed);
}
}
-
+
return snapshot;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManager.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManager.java
index a90ea9e..810f330 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManager.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManager.java
@@ -16,6 +16,9 @@
// under the License.
package com.cloud.agent.manager;
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
+
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.AttachIsoCommand;
import com.cloud.agent.api.AttachVolumeAnswer;
@@ -41,8 +44,6 @@ import com.cloud.agent.api.storage.CreateAnswer;
import com.cloud.agent.api.storage.CreateCommand;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.ListVolumeCommand;
import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
index d8a3e51..a0897b8 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
@@ -48,8 +48,6 @@ import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.agent.api.storage.DestroyCommand;
import com.cloud.agent.api.storage.DownloadAnswer;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
import com.cloud.agent.api.storage.ListTemplateAnswer;
import com.cloud.agent.api.storage.ListTemplateCommand;
import com.cloud.agent.api.storage.ListVolumeAnswer;
@@ -81,6 +79,9 @@ import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.VirtualMachine.State;
+
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.api.to.NfsTO;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c60c373a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
index c234cc5..f67a818 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
@@ -34,6 +34,9 @@ import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.State;
+
+import org.apache.cloudstack.storage.command.DownloadCommand;
+import org.apache.cloudstack.storage.command.DownloadProgressCommand;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;