Skip to content

Commit e2bcbe9

Browse files
committed
- CLOUDSTACK-3229: Fixes a think-o in the handling of unmodifiable
collections and adds a rail in s3xen to raise an exception if the file being put does not exist
1 parent 1ae682d commit e2bcbe9

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@
290290
import java.util.UUID;
291291

292292
import static com.cloud.utils.ReflectUtil.flattenProperties;
293+
import static com.google.common.collect.Lists.newArrayList;
293294

294295
/**
295296
* CitrixResourceBase encapsulates the calls to the XenServer Xapi process
@@ -7404,8 +7405,8 @@ private boolean backupSnapshotToS3(final Connection connection,
74047405

74057406
try {
74067407

7407-
final List<String> parameters = flattenProperties(s3,
7408-
S3Utils.ClientOptions.class);
7408+
final List<String> parameters = newArrayList(flattenProperties(s3,
7409+
S3Utils.ClientOptions.class));
74097410
parameters.addAll(Arrays.asList("operation", "put", "directory",
74107411
dir, "filename", filename, "iSCSIFlag",
74117412
iSCSIFlag.toString(), "bucket", s3.getBucketName(), "key", key));

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/XenServerStorageProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import java.util.UUID;
8282

8383
import static com.cloud.utils.ReflectUtil.flattenProperties;
84+
import static com.google.common.collect.Lists.newArrayList;
8485

8586
public class XenServerStorageProcessor implements StorageProcessor {
8687
private static final Logger s_logger = Logger.getLogger(XenServerStorageProcessor.class);
@@ -1073,8 +1074,8 @@ private boolean backupSnapshotToS3(final Connection connection,
10731074

10741075
try {
10751076

1076-
final List<String> parameters = flattenProperties(s3,
1077-
S3Utils.ClientOptions.class);
1077+
final List<String> parameters = newArrayList(flattenProperties(s3,
1078+
S3Utils.ClientOptions.class));
10781079
parameters.addAll(Arrays.asList("operation", "put", "directory",
10791080
dir, "filename", filename, "iSCSIFlag",
10801081
iSCSIFlag.toString(), "bucket", s3.getBucketName(), "key", key));

scripts/vm/hypervisor/xenserver/s3xen

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class S3Client(object):
179179
max_error_retry, self.DEFAULT_MAX_ERROR_RETRY)
180180

181181
def build_canocialized_resource(self, bucket, key):
182-
return "/" + join([bucket, key], '/')
182+
return "/" + join([bucket, key], "/")
183183

184184
def noop_send_body(connection):
185185
pass
@@ -256,6 +256,10 @@ class S3Client(object):
256256

257257
def put(self, bucket, key, src_filename):
258258

259+
if not os.path.isfile(src_filename):
260+
raise Exception(
261+
"Attempt to put " + src_filename + " that does not exist.")
262+
259263
headers = {
260264
self.HEADER_CONTENT_MD5: compute_md5(src_filename),
261265
self.HEADER_CONTENT_TYPE: 'application/octet-stream',

0 commit comments

Comments
 (0)