如何使用 Amazon AWS SDK 访问 Eucalyptus Walrus(S3)

如何使用 Amazon AWS SDK 访问 Eucalyptus Walrus(S3)

我已经下载了适用于 C# 的 Amazon AWS SDK,我可以毫无问题地访问运行 Eucalyptus 的私有云的 EC2 部分,我可以列出图像、实例、区域...

这工作正常:

AmazonEC2 ec2 = AWSClientFactory.CreateAmazonEC2Client("abcdefghijklmnopqrstuvwxyz1234567890", "abcdefghijklmnopqrstuvwxyz1234567890", new AmazonEC2Config().WithServiceURL("http://10.140.54.12:8773/services/Eucalyptus"));

DescribeInstancesRequest ec2Request = new DescribeInstancesRequest();
try
{
    DescribeInstancesResponse ec2Response = ec2.DescribeInstances(ec2Request);
    int numInstances = 0;
    numInstances = ec2Response.DescribeInstancesResult.Reservation.Count;
    textBoxInstancesLog.AppendText("You have " + numInstances + " running instances");
    textBoxInstancesLog.AppendText(ec2Response.ToString());
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}

但我需要访问我们云的 Walrus (S3) 部分。这是我尝试访问 Walrus 的方法,代码几乎相同,但通过此调用我会得到一个异常。

这不起作用:

AmazonS3 s3 = AWSClientFactory.CreateAmazonS3Client("abcdefghijklmnopqrstuvwxyz1234567890", "abcdefghijklmnopqrstuvwxyz1234567890", new AmazonS3Config().WithServiceURL("http://10.140.54.12:8773/services/Walrus"));
ListBucketsRequest s3Request = new ListBucketsRequest();
try
{
    ListBucketsResponse s3Response = s3.ListBuckets(s3Request);
    textBoxS3Log.AppendText(s3Response.ToString());
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}

我会收到此异常:

System.Net.WebException: The remote name could not be resolved: 'http'
   at Amazon.S3.AmazonS3Client.processRequestError(String actionName, HttpWebRequest request, WebException we, HttpWebResponse errorResponse, String requestAddr, WebHeaderCollection& respHdrs, Type t, Exception& cause)
   at Amazon.S3.AmazonS3Client.handleHttpWebErrorResponse(S3Request userRequest, WebException we, HttpWebRequest request, HttpWebResponse httpResponse, Exception& cause, HttpStatusCode& statusCode)
   at Amazon.S3.AmazonS3Client.getResponseCallback[T](IAsyncResult result)
   at Amazon.S3.AmazonS3Client.endOperation[T](IAsyncResult result)
   at Amazon.S3.AmazonS3Client.ListBuckets(ListBucketsRequest request)
   at IAASClient.FormMain.buttonS3Test_Click(Object sender, EventArgs e) in X:\work\IAASClient\FormMain.cs:line 107

来自 Eucalyptus 网站:

Eucalyptus 实现了 IaaS(基础设施即服务)私有云,可通过与 Amazon EC2 和 Amazon S3 兼容的 API 进行访问

我错过了什么?

注意:相同的代码与 Amazon S3 完美兼容,问题在于访问 Eucalyptus Walrus。

答案1

在 zip 文件 AWS_Console_App1 (AWS_控制台_应用程序1_1_0_3699_15931.zip)您会在 Readme.txt 文件中找到对 Walrus 支持的引用。我在文章科学云

它提到以下内容:“Amazon.S3\AmazonS3Config.cs:添加了 privateServiceUrl 属性和字段以支持 Walrus 兼容性”。

看起来这可能是一个很好的线索。

相关内容