mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-23 17:33:56 +03:00
M #-: minor changes in provision (#678)
This commit is contained in:
parent
0df9ee4d1d
commit
aafdf3d357
@ -19,20 +19,15 @@
|
||||
ONE_LOCATION = ENV['ONE_LOCATION']
|
||||
|
||||
if !ONE_LOCATION
|
||||
LIB_LOCATION = '/usr/lib/one'
|
||||
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION = '/usr/share/one/gems'
|
||||
REMOTES_LOCATION = '/var/lib/one/remotes'
|
||||
ANSIBLE_LOCATION = '/usr/share/one/oneprovision/ansible'
|
||||
PROVIDERS_LOCATION = '/usr/lib/one/oneprovision/lib/terraform/providers'
|
||||
LIB_LOCATION = '/usr/lib/one'
|
||||
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION = '/usr/share/one/gems'
|
||||
REMOTES_LOCATION = '/var/lib/one/remotes'
|
||||
else
|
||||
LIB_LOCATION = ONE_LOCATION + '/lib'
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
||||
REMOTES_LOCATION = ONE_LOCATION + '/var/remotes'
|
||||
ANSIBLE_LOCATION = ONE_LOCATION + '/share/oneprovision/ansible'
|
||||
PROVIDERS_LOCATION = ONE_LOCATION +
|
||||
'/lib/oneprovision/lib/terraform/providers'
|
||||
LIB_LOCATION = ONE_LOCATION + '/lib'
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
||||
REMOTES_LOCATION = ONE_LOCATION + '/var/remotes'
|
||||
end
|
||||
|
||||
if File.directory?(GEMS_LOCATION)
|
||||
|
@ -23,13 +23,11 @@ if !ONE_LOCATION
|
||||
RUBY_LIB_LOCATION = '/usr/lib/one/ruby'
|
||||
GEMS_LOCATION = '/usr/share/one/gems'
|
||||
REMOTES_LOCATION = '/var/lib/one/remotes'
|
||||
ANSIBLE_LOCATION = '/usr/share/one/oneprovision/ansible'
|
||||
else
|
||||
LIB_LOCATION = ONE_LOCATION + '/lib'
|
||||
RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby'
|
||||
GEMS_LOCATION = ONE_LOCATION + '/share/gems'
|
||||
REMOTES_LOCATION = ONE_LOCATION + '/var/remotes'
|
||||
ANSIBLE_LOCATION = ONE_LOCATION + '/share/oneprovision/ansible'
|
||||
end
|
||||
|
||||
if File.directory?(GEMS_LOCATION)
|
||||
|
@ -1,61 +0,0 @@
|
||||
:plans:
|
||||
Type 2A5:
|
||||
cpu: 1
|
||||
memory: 96.0
|
||||
c2.large.arm:
|
||||
cpu: 1
|
||||
memory: 128.0
|
||||
c2.medium.x86:
|
||||
cpu: 1
|
||||
memory: 64.0
|
||||
c3.medium.x86:
|
||||
cpu: 1
|
||||
memory: 64.0
|
||||
c3.small.x86:
|
||||
cpu: 1
|
||||
memory: 32.0
|
||||
g2.large.x86:
|
||||
cpu: 2
|
||||
memory: 192.0
|
||||
m2.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 384.0
|
||||
m3.large.x86:
|
||||
cpu: 1
|
||||
memory: 256.0
|
||||
n2.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 384.0
|
||||
s3.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 192.0
|
||||
x2.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 384.0
|
||||
x.large.arm:
|
||||
cpu: 2
|
||||
memory: 256.0
|
||||
c1.large.arm:
|
||||
cpu: 2
|
||||
memory: 128.0
|
||||
c1.large.arm.xda:
|
||||
cpu: 2
|
||||
memory: 128.0
|
||||
c1.small.x86:
|
||||
cpu: 1
|
||||
memory: 32.0
|
||||
c1.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 128.0
|
||||
m1.xlarge.x86:
|
||||
cpu: 2
|
||||
memory: 256.0
|
||||
s1.large.x86:
|
||||
cpu: 1
|
||||
memory: 64.0
|
||||
t1.small.x86:
|
||||
cpu: 1
|
||||
memory: 8.0
|
||||
x1.small.x86:
|
||||
cpu: 1
|
||||
memory: 32.0
|
@ -1,52 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'net/http'
|
||||
|
||||
unless ARGV[0]
|
||||
STDERR.puts 'No API token provied'
|
||||
STDERR.puts '`packet_plans.rb` <API_TOKEN>'
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
uri = URI('https://api.packet.net/plans')
|
||||
req = Net::HTTP::Get.new(uri)
|
||||
|
||||
req['Accept'] = 'application/json'
|
||||
req['X-Auth-Token'] = ARGV[0]
|
||||
|
||||
res = Net::HTTP.new(uri.hostname, uri.port)
|
||||
res.use_ssl = true
|
||||
|
||||
response = res.request(req)
|
||||
|
||||
unless response.is_a? Net::HTTPOK
|
||||
STDERR.puts 'Error getting plans from Packet'
|
||||
exit(-1)
|
||||
end
|
||||
|
||||
plans = JSON.parse(response.body)['plans']
|
||||
file = ":plans:\n"
|
||||
|
||||
plans.each do |plan|
|
||||
specs = plan['specs']
|
||||
|
||||
specs['cpus'].nil? ? cpu = 0 : cpu = specs['cpus'][0]['count']
|
||||
specs['memory'].nil? ? mem = 0 : mem = specs['memory']['total']
|
||||
|
||||
next if cpu == 0 || mem == 0
|
||||
|
||||
file << " #{plan['name']}:\n"
|
||||
file << " cpu: #{cpu}\n"
|
||||
file << " memory: #{mem[/\d+/]}.0\n"
|
||||
end
|
||||
|
||||
puts file
|
||||
puts
|
||||
|
||||
print 'Do you want to overwrite file packet_driver.conf? '
|
||||
over = STDIN.readline.chop.downcase
|
||||
|
||||
exit if over != 'yes'
|
||||
|
||||
File.open('packet_driver.conf', 'w') {|f| f.write(file) }
|
@ -23,6 +23,12 @@ require 'base64'
|
||||
require 'erb'
|
||||
require 'ostruct'
|
||||
|
||||
if !ONE_LOCATION
|
||||
ANSIBLE_LOCATION = '/usr/share/one/oneprovision/ansible'
|
||||
else
|
||||
ANSIBLE_LOCATION = ONE_LOCATION + '/share/oneprovision/ansible'
|
||||
end
|
||||
|
||||
# Default provision parameters
|
||||
CONFIG_DEFAULTS = {
|
||||
'connection' => {
|
||||
|
@ -197,6 +197,8 @@ module OneProvision
|
||||
path = 'resource'
|
||||
end
|
||||
|
||||
return [] unless @body['provision'][path][object]
|
||||
|
||||
resource = Resource.object(object)
|
||||
|
||||
@body['provision'][path][object].each do |o|
|
||||
|
@ -19,6 +19,13 @@ require 'ostruct'
|
||||
require 'yaml'
|
||||
require 'zlib'
|
||||
|
||||
if !ONE_LOCATION
|
||||
PROVIDERS_LOCATION = '/usr/lib/one/oneprovision/lib/terraform/providers'
|
||||
else
|
||||
PROVIDERS_LOCATION = ONE_LOCATION +
|
||||
'/lib/oneprovision/lib/terraform/providers'
|
||||
end
|
||||
|
||||
# Module OneProvision
|
||||
module OneProvision
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user