diff options
Diffstat (limited to 'genome-bootstrap')
-rw-r--r-- | genome-bootstrap/bin/genome-bootstrap | 42 | ||||
-rw-r--r-- | genome-bootstrap/extra/genome-bootstrap.spec | 2 | ||||
-rw-r--r-- | genome-bootstrap/lib/genome-bootstrap/core.rb | 39 |
3 files changed, 32 insertions, 51 deletions
diff --git a/genome-bootstrap/bin/genome-bootstrap b/genome-bootstrap/bin/genome-bootstrap index 0a25ba5..9deab7e 100644 --- a/genome-bootstrap/bin/genome-bootstrap +++ b/genome-bootstrap/bin/genome-bootstrap @@ -20,6 +20,22 @@ Main { say("<%= color(\"#{text}\", :red) %>") end + # It's a little silly to have this much indirection. Smells like things need + # to be refactored a bit. + def get_system_ip(repo, system_name) + sleep_time = 5 + tries = 10 + + say("Trying to determine the ip address.") + say("We'll try and maximum of #{tries} times.") + repo.get_system_ip(system_name, tries) do + # It's really silly that we have to poll for the ip like this. + say("Polling for cobbler status...") + say("Retrying in #{sleep_time} seconds") + sleep sleep_time + end + end + def get_input @facts = Hash.new @@ -99,20 +115,10 @@ Main { unless config_only cloud_master = CloudController.new(@cloudmaster, @genome_repo) host = cloud_master.create_machine(@system_name, @email) - if @genome_repo.cobbler_dns? - @genome_repo.register_dns_entry - end - installed_system = @genome_repo.get_installed_system(@system_name) - if not installed_system.empty? - if @genome_repo.cobbler_dns? - # register the new system with cobbler dns using the name, - # the installed_system's IP - end - fqdn = installed_system["hostname"] + if ip = get_system_ip(@genome_repo, @system_name) say("Your new system is being provisioned on #{host}.") - say("The FQDN of new system is #{fqdn}.") - say("The IP address of the new system is #{installed_system["ip"]}.") + say("The IP address of the new system is #{ip}.") else say("Your new system is being provisioned on #{host}.") say("You can visit #{@cloudmaster.cloud} to see the status of the new system.") @@ -193,17 +199,9 @@ Main { cloud_master = CloudController.new(params['cloudmaster'].value, genome_repo) host = cloud_master.create_machine(name, params['email'].value) - installed_system = genome_repo.get_installed_system(name) - if not installed_system.empty? - if genome_repo.cobbler_dns? and params['fqdn'].given? - # register the new system with cobbler dns using the name, - # the installed_system's IP, and the given fqdn - else - fqdn = installed_system["hostname"] - end + if ip = get_system_ip(genome_repo, name) say("Your new system is being provisioned on #{host}.") - say("The FQDN of new system is #{fqdn}.") - say("The IP address of the new system is #{installed_system["ip"]}.") + say("The IP address of the new system is #{ip}.") else say("Your new system is being provisioned on #{host}.") say("You can visit #{cloud_master.cloud} to see the status of the new system.") diff --git a/genome-bootstrap/extra/genome-bootstrap.spec b/genome-bootstrap/extra/genome-bootstrap.spec index 71b4d1c..ca114bd 100644 --- a/genome-bootstrap/extra/genome-bootstrap.spec +++ b/genome-bootstrap/extra/genome-bootstrap.spec @@ -7,7 +7,7 @@ Summary: Tool for provisioning virtual machines Name: rubygem-%{gemname} Version: 1.0.0 -Release: 3%{?dist} +Release: 4%{?dist} Group: Development/Languages License: Ruby License/GPL Source0: %{gemname}-%{version}.gem diff --git a/genome-bootstrap/lib/genome-bootstrap/core.rb b/genome-bootstrap/lib/genome-bootstrap/core.rb index 44616b8..28b7e61 100644 --- a/genome-bootstrap/lib/genome-bootstrap/core.rb +++ b/genome-bootstrap/lib/genome-bootstrap/core.rb @@ -119,38 +119,21 @@ module GenomeBootstrap add_system_to_cobbler(machine_fqdn, config["parameters"], email) end - # Retrive information form the /var/log/cobbler/install.log - def get_installed_systems - systems = restr_get("#{@genomed}/systems.xml")[0] - return systems["system"].map do |system| - def system.name - self["name"].to_s + def get_system_ip(system_name, max_tries=1) + status = 1.upto(max_tries) do + # Technically the yield should be after the remote call, but it would + # trip up the 'find' + yield if block_given? + + data = @cobblerd.call2("get_status")[1].find do |ip, s| + s[2] == "system:%s" % system_name && s[5] =~ /^installing/ end - def system.ip - self["ip"].to_s - end - - def system.hostname - self["hostname"].to_s - end - system + # This returns from the block + break data unless data.nil? end - end - - def get_installed_system(system_name) - systems = get_installed_systems.delete_if{|system| - system.name != system_name.to_s - } - return systems.empty? ? {} : systems[0] - end - - def cobbler_dns? - return false - end - - def register_dns_entry(ip, name) + return status.nil? ? nil : status[0] end # This is a workaround for a Restr "feature". If only one element it is |