Class: Beaker::Blimper
- Inherits:
-
Hypervisor
- Object
- Hypervisor
- Beaker::Blimper
- Defined in:
- lib/beaker/hypervisor/blimper.rb
Constant Summary
Constants inherited from Hypervisor
Constants included from HostPrebuiltSteps
HostPrebuiltSteps::APT_CFG, HostPrebuiltSteps::ETC_HOSTS_PATH, HostPrebuiltSteps::ETC_HOSTS_PATH_SOLARIS, HostPrebuiltSteps::IPS_PKG_REPO, HostPrebuiltSteps::NTPSERVER, HostPrebuiltSteps::PACKAGES, HostPrebuiltSteps::ROOT_KEYS_SCRIPT, HostPrebuiltSteps::ROOT_KEYS_SYNC_CMD, HostPrebuiltSteps::SLEEPWAIT, HostPrebuiltSteps::SLES_PACKAGES, HostPrebuiltSteps::TRIES, HostPrebuiltSteps::UNIX_PACKAGES
Instance Method Summary collapse
-
#cleanup ⇒ Object
revert_blimpy.
-
#initialize(blimpy_hosts, options) ⇒ Blimper
constructor
A new instance of Blimper.
- #provision ⇒ Object
Methods inherited from Hypervisor
#configure, create, #generate_host_name, #validate
Methods included from HostPrebuiltSteps
#add_el_extras, #add_master_entry, #apt_get_update, #copy_file_to_remote, #copy_ssh_to_root, #disable_iptables, #disable_se_linux, #enable_root_login, #epel_info_for!, #get_domain_name, #get_ip, #hack_etc_hosts, #proxy_config, #set_etc_hosts, #sync_root_keys, #timesync, #validate_host
Constructor Details
#initialize(blimpy_hosts, options) ⇒ Blimper
Returns a new instance of Blimper.
8 9 10 11 12 13 |
# File 'lib/beaker/hypervisor/blimper.rb', line 8 def initialize(blimpy_hosts, ) @options = @logger = [:logger] @hosts = blimpy_hosts @blimpy = Blimpy end |
Instance Method Details
#cleanup ⇒ Object
revert_blimpy
94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/beaker/hypervisor/blimper.rb', line 94 def cleanup fleet = @blimpy.fleet do |fleet| @hosts.each do |host| fleet.add(:aws) do |ship| ship.name = host.name end end end @logger.notify "Destroying Blimpy boxes" fleet.destroy end |
#provision ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/beaker/hypervisor/blimper.rb', line 15 def provision ami_spec= YAML.load_file(@options[:ec2_yaml])["AMI"] fleet = @blimpy.fleet do |fleet| @hosts.each do |host| amitype = host['vmname'] || host['platform'] amisize = host['amisize'] || 'm1.small' #use snapshot provided for this host image_type = host['snapshot'] if not image_type raise "No snapshot/image_type provided for blimpy provisioning" end ami = ami_spec[amitype] fleet.add(:aws) do |ship| ship.name = host.name ship.ports = Beaker::EC2Helper.amiports(host['roles']) ship.image_id = ami[:image][image_type.to_sym] if not ship.image_id raise "No image_id found for host #{ship.name} (#{amitype}:#{amisize}) using snapshot/image_type #{image_type}" end ship.flavor = amisize ship.region = ami[:region] ship.username = 'root' ship. = { :department => @options[:department], :project => @options[:project], :jenkins_build_url => @options[:jenkins_build_url], } end @logger.debug "Added #{host.name} (#{amitype}:#{amisize}) using snapshot/image_type #{image_type} to blimpy fleet" end end # Attempt to start the fleet, we wrap it with some error handling that # deals with generic Fog errors and retrying in case these errors are # transient. fleet_retries = 0 begin fleet.start rescue Fog::Errors::Error, SystemCallError => ex fleet_retries += 1 if fleet_retries <= 3 sleep_time = rand(10) + 10 @logger.notify("Calling fleet.destroy, sleeping #{sleep_time} seconds and retrying fleet.start due to exception #{ex.class.to_s} (#{ex.}), retry attempt #{fleet_retries}.") begin timeout(30) do fleet.destroy end rescue end sleep sleep_time retry else @logger.error("Retried Fog #{fleet_retries} times, giving up and throwing the exception") raise ex end end # Configure our nodes to match the blimp fleet # Also generate hosts entries for the fleet, since we're iterating etc_hosts = "127.0.0.1\tlocalhost localhost.localdomain\n" fleet.ships.each do |ship| ship.wait_for_sshd name = ship.name host = @hosts.select { |host| host.name == name }[0] host['ip'] = ship.dns host.exec(Command.new("hostname #{name}")) ip = get_ip(host) domain = get_domain_name(host) etc_hosts += "#{ip}\t#{name}\t#{name}.#{domain}\n" end # Send our hosts information to the nodes @hosts.each do |host| set_etc_hosts(host, etc_hosts) end end |