我已经下载了用于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)部分。 这是我如何尝试访问海象,代码是几乎相同的,但与此呼吁,我会得到一个例外。
这不工作:
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实现了IaaS(基础设施即服务)私有云,可通过与Amazon EC2和Amazon S3兼容的API访问
我错过了什么?
注意:相同的代码工作与Amazon S3完美无瑕,问题在于访问Eucalyptus Walrus。
在压缩文件AWS_Console_App1( AWS_Console_App1_1_0_3699_15931.zip )中,您会在Readme.txt文件中find对Walrus支持的引用。 我在“科学云”的 这篇文章中find了它。
它提到了以下内容:“Amazon.S3 \ AmazonS3Config.cs:添加了privateServiceUrl属性和字段以支持Walrus兼容性”。
看起来这可能是一个很好的领先。