Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 61 lines (48 sloc) 1.41 KB
#!/usr/bin/env ruby
require 'yaml'
require 'securerandom'
require 'meld'
require_relative 'lib/api'
HOSTNAME = ARGV.first || raise('Please supply a hostname')
CONFIG_FILES = ['config.yaml', "configs/#{HOSTNAME}.yaml"].freeze
CONFIG = CONFIG_FILES.each_with_object({}) do |file, obj|
next unless File.exist? file
obj.deep_merge! YAML.load(File.read(file))
end
API_IDS = CONFIG['api_ids']
wrapper = API.new HOSTNAME
wrapper.delete_all!
wrapper.wait_for_jobs
puts 'Creating new disks'
disks = {}
CONFIG['disks'].each do |disk|
disk = Hash[disk.map { |k, v| [k.to_sym, v] }]
disks[disk[:label].to_sym] = wrapper.create_disk disk
end
ROOT_PW = SecureRandom.hex(24)
disks[:maker] = wrapper.create_from_image(
imageid: wrapper.get_image('meta_dock0').imageid,
rootpass: ROOT_PW,
label: 'maker',
size: 1024
)
disks[:finnix] = API_IDS['finnix']
CONFIG_ID = wrapper.create_config(
kernelid: API_IDS['stock_kernel'],
disklist: disks.values_at(:maker, :finnix, :root, :lvm).join(','),
label: 'dock0'
)
puts 'Booting maker image'
wrapper.boot(CONFIG_ID)
wrapper.update_config(
configid: CONFIG_ID,
helper_depmod: false,
helper_distro: false,
helper_disableupdatedb: false,
helper_network: false,
devtmpfs_automount: false,
disklist: disks.values_at(:root, :lvm).join(','),
kernelid: API_IDS["#{wrapper.hypervisor}_kernel"]
)
puts "Success! (maker pw is #{ROOT_PW})"
system "./meta/configure.rb #{HOSTNAME}"
You can’t perform that action at this time.