diff --git a/src/cli/oneprovision b/src/cli/oneprovision index d82d9fe089..e7ba66612e 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -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) diff --git a/src/cli/oneprovision-template b/src/cli/oneprovision-template index 8ee19dc36b..64f3d7a81c 100755 --- a/src/cli/oneprovision-template +++ b/src/cli/oneprovision-template @@ -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) diff --git a/src/oneprovision/etc/packet_driver.conf b/src/oneprovision/etc/packet_driver.conf deleted file mode 100644 index f281be4045..0000000000 --- a/src/oneprovision/etc/packet_driver.conf +++ /dev/null @@ -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 diff --git a/src/oneprovision/etc/packet_plans.rb b/src/oneprovision/etc/packet_plans.rb deleted file mode 100755 index e9a1d8f77a..0000000000 --- a/src/oneprovision/etc/packet_plans.rb +++ /dev/null @@ -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` ' - 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) } diff --git a/src/oneprovision/lib/provision/ansible.rb b/src/oneprovision/lib/provision/ansible.rb index e341a65bd8..d47934da76 100644 --- a/src/oneprovision/lib/provision/ansible.rb +++ b/src/oneprovision/lib/provision/ansible.rb @@ -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' => { diff --git a/src/oneprovision/lib/provision/provision.rb b/src/oneprovision/lib/provision/provision.rb index 49bcd64a8d..7e05e03e59 100644 --- a/src/oneprovision/lib/provision/provision.rb +++ b/src/oneprovision/lib/provision/provision.rb @@ -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| diff --git a/src/oneprovision/lib/terraform/terraform.rb b/src/oneprovision/lib/terraform/terraform.rb index 0a5d9b62a1..575eee22ee 100644 --- a/src/oneprovision/lib/terraform/terraform.rb +++ b/src/oneprovision/lib/terraform/terraform.rb @@ -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