Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 通过Fog获取Amazon映像的操作系统_Ruby_Amazon Web Services_Fog - Fatal编程技术网

Ruby 通过Fog获取Amazon映像的操作系统

Ruby 通过Fog获取Amazon映像的操作系统,ruby,amazon-web-services,fog,Ruby,Amazon Web Services,Fog,我的最终目标是获得亚马逊镜像的操作系统。当我这样做时: connection = Fog::Compute.new(provider: 'AWS', aws_access_key_id: 'blah', aws_secret_access_key: 'thing') images = connection.describe_images('Owner' => 'self'

我的最终目标是获得亚马逊镜像的操作系统。当我这样做时:

connection = Fog::Compute.new(provider: 'AWS',
                              aws_access_key_id: 'blah',
                              aws_secret_access_key: 'thing')
images = connection.describe_images('Owner' => 'self').body['imagesSet']
我返回的数据不包括所建议的
平台
。但是,我得到的值如下:

architecture: "x86_64",
imageType: "machine",
kernelId: "aki-825ea7eb",
如果我在谷歌上搜索内核ID,我会发现它是Linux。有没有一种方法可以通过Fog将
kernelId
传递给Amazon,并获取有关
kernelId
的数据,例如
linux


另一方面,有时我的映像没有
kernelId
,因此
中是否有其他字段是操作系统的明确指示器?

如果您使用内核ID,这里有一个解决方案

将内核ID传递给ruby中的变量

    ker_id = imagesSet

    url = []
    url_0 = "http://thecloudmarket.com/image/"
    url_1 = "ker_id"
    url_2 = "#/definition"

    new_url = url_0 + url_1 _ url_2
有很多方法可以伪造这个url,只是为了让它更容易阅读

然后使用nokogiri解析网页,并将图像名称放回脚本中。
我在文档中没有看到其他通知程序。

我希望有一种更干净的方式,最好是亚马逊本身的服务,甚至是外部API,比如来自Cloudmarket.com的API。