mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-27 10:50:10 +03:00
Feature #4256: script that generates the instance types yaml
This commit is contained in:
parent
3abf2a73c8
commit
09dfd8ee5e
25
share/ec2/get-instance-types.rb
Executable file
25
share/ec2/get-instance-types.rb
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'pp'
|
||||
require 'yaml'
|
||||
require 'open-uri'
|
||||
|
||||
puts "Very slow script... hold on tight for a couple of minutes..."
|
||||
puts
|
||||
|
||||
content = open('https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json').read
|
||||
content = JSON.parse(content)
|
||||
|
||||
types = {}
|
||||
content["products"].each do |k,v|
|
||||
instanceType = v["attributes"]["instanceType"]
|
||||
memory = v["attributes"]["memory"].split[0] rescue nil
|
||||
cpu = v["attributes"]["vcpu"]
|
||||
|
||||
if types[instanceType].nil? && instanceType && memory && cpu
|
||||
types[instanceType] = {"cpu" => cpu, "memory" => memory}
|
||||
end
|
||||
end
|
||||
|
||||
puts ({"instance_types" => types.sort.to_h}).to_yaml(:indentation=>4)
|
Loading…
x
Reference in New Issue
Block a user