diff options
| author | Matthew Hicks <mhicks@mhicks-host.usersys.redhat.com> | 2008-06-18 21:22:21 -0400 |
|---|---|---|
| committer | Matthew Hicks <mhicks@mhicks-host.usersys.redhat.com> | 2008-06-18 21:22:21 -0400 |
| commit | 5ea212d8f77e1014afdc9fde9cd4f2a476d50ae5 (patch) | |
| tree | c39acf05fac386e4d509667d311f9ef20da1549c | |
| parent | 6866dab02b31a3464174e52eae4257e3c15be117 (diff) | |
| download | tools-5ea212d8f77e1014afdc9fde9cd4f2a476d50ae5.tar.gz tools-5ea212d8f77e1014afdc9fde9cd4f2a476d50ae5.tar.xz tools-5ea212d8f77e1014afdc9fde9cd4f2a476d50ae5.zip | |
More cloud functionality support
| -rw-r--r-- | everest-bootstrap/bin/everest-bootstrap | 114 | ||||
| -rw-r--r-- | everest-bootstrap/lib/everest-bootstrap/core.rb | 17 |
2 files changed, 34 insertions, 97 deletions
diff --git a/everest-bootstrap/bin/everest-bootstrap b/everest-bootstrap/bin/everest-bootstrap index 31bcb29..3f39eb3 100644 --- a/everest-bootstrap/bin/everest-bootstrap +++ b/everest-bootstrap/bin/everest-bootstrap @@ -21,7 +21,7 @@ Main { say("<%= color(\"#{text}\", :red) %>") end - def get_input + def get_input(cloud=false) unless ENV['USER'] == 'root' || params["config-only"].given? raise "You must run this command as root unless " + "you specify the '--config-only' option" @@ -29,6 +29,11 @@ Main { @facts = Hash.new + if cloud + @cloud = ask("Enter your cloud master (leave off the '-repo'): ") + @email = ask("Enter your email address for cloud notifications: ") + end + @repo = ask("Enter your Everest repo machine name (leave off the '-repo'): ") @user = ask("Enter your kerberos username: ") @@ -93,7 +98,7 @@ Main { end while agree("Enter another? ", true) end - unless params["config-only"].given? + unless params["config-only"].given? || cloud if agree("Use LVM for VM storage (recommended)? (y/n)", true) @virt_path = choose do |menu| menu.prompt = "Select the Volume Group to use: " @@ -180,89 +185,23 @@ Main { end mode 'cloud' do - def collect_input - unless ENV['USER'] == 'root' || params["config-only"].given? - raise "You must run this command as root unless " + - "you specify the '--config-only' option" - end - - @facts = Hash.new - - @repo = ask("Enter your Everest repo machine name (leave off the '-repo'): ") - @cloud = ask("Enter your cloud master (leave off the '-repo'): ") - @user = ask("Enter your kerberos username: ") - - say_red("Your machine name is the part right before the Everest type.") - say_red("For example, 'sso1-build.usersys.redhat.com' has a machine name of 'sso1'.") - say_red("If you do not specify a machine name it will default to your kerberos name.") - - if agree("Enter machine name? (y/n)", true) - @machine_name = ask("Machine name: ") - else - @machine_name = @user - end - - # Once we know the repo we can fetch the supported machines - @everest_repo = EverestRepo.new(@repo) - say_red("To see a description of these machine types visit: " + - "#{@everest_repo.machine_types_url}") - - @machine_type = choose do |menu| - menu.prompt = "Select your machine type: " - menu.choices(*@everest_repo.machines.map{|m| m.name}) - end - - # This might be useful is we stop using DDNS - @facts["everest_machine_type"] = @machine_type - - if agree("Configure this machine with Red Hat DDNS? (y/n)", true) - # Our naming convention - hostname = @machine_name + "-" + @machine_type - @fqdn = hostname + ".usersys.redhat.com" - - if agree("Do you know the DDNS hash for this machine? (y/n)", true) - @facts["rh_ddns_hash"] = ask("Enter Red Hat DDNS hash: ") - else - @password = ask("Enter your kerberos password to setup DDNS: ") { |q| q.echo = "*" } - @facts["rh_ddns_hash"] = RedHatDDNS::DDNS.new(@user, @password, hostname).ddns_hash - end - else - @fqdn = ask("Enter fully qualified domain name for this machine: ") - end - - @facts["cobbler_profile"] = choose do |menu| - menu.prompt = "Select your cobbler profile (This determines the OS): " - menu.choices(*@everest_repo.cobbler_profiles) - end - - say_red("Now you need to enter some parameters what will be used to configure this machine.") - say_red("Most of the defaults will work out fine for development.") - - @everest_repo.facts_for(@machine_type, @machine_name).each do |f| - say_red("Description: #{f.desc}") unless f.desc.empty? - @facts[f.name] = ask("Enter value for #{f.name}: ") do |q| - q.default = f.default - end - end - - if agree("Enter addition facts? (y/n)", true) - begin - name = ask("Enter fact name: ") - value = ask("Enter fact value: ") - @facts[name] = value - end while agree("Enter another? ", true) - end - - say_red("The Koan process will start on a machine in the cloud.") - end - def run - collect_input + # Get input for the cloud + get_input(true) classes = @everest_repo.classes_for(@machine_type) config = {"classes" => classes, "parameters" => @facts} - @everest_repo.register_machine(@fqdn, config) + # Create the everest machine + e = EverestMachine.new(@machine_type, + @fqdn, + @repo, + config, + @email) + + e.post_config + e.add_system_to_cobbler + cloud_repo = CloudRepo.new cloud_repo.create_machine(@fqdn, @cloud) end @@ -281,8 +220,9 @@ Main { argument_required } - option('cloud-controller', '-c'){ - description "Fully qualified domain name for the Everest repo machine to use for provisioning" + option('cloud-master', '-l'){ + required + description "Fully qualified domain name for the machine controlling the cloud" argument_required } @@ -299,16 +239,10 @@ Main { YAML.load($stdin.read) end - cloud_controller = if params['cloud-controller'].given? - params['cloud-controller'].value - else - "everest-repo.usersys.redaht.com" - end - everest_repo = EverestRepo.new(params['repo'].value) everest_repo.register_machine(params['fqdn'].value, config) - cloud_repo = CloudRepo.new(everest_repo.repo) - cloud_repo.create_machine(params['fqdn'].value, everest_repo.repo) + cloud_repo = CloudRepo.new + cloud_repo.create_machine(params['fqdn'].value, params['cloud-master']) end end diff --git a/everest-bootstrap/lib/everest-bootstrap/core.rb b/everest-bootstrap/lib/everest-bootstrap/core.rb index a285213..6ee545d 100644 --- a/everest-bootstrap/lib/everest-bootstrap/core.rb +++ b/everest-bootstrap/lib/everest-bootstrap/core.rb @@ -76,7 +76,7 @@ module EverestBootstrap Restr.post("#{@everestd}/nodes", :node_name => node_name, :yaml => yaml) end - def add_system_to_cobbler(name, params) + def add_system_to_cobbler(name, params, email) system_id = @cobblerd.call2("new_system", @token)[1] @cobblerd.call2('modify_system', system_id, 'name', name, @token) @cobblerd.call2('modify_system', system_id, 'profile', params["cobbler_profile"], @token) @@ -85,11 +85,13 @@ module EverestBootstrap ksmeta = "fqdn=#{name} " + "everest_repo=#{@fqdn}" + ksmeta << " email=#{email}" if email + @cobblerd.call2('modify_system', system_id, 'ksmeta', ksmeta, @token) @cobblerd.call2('save_system', system_id, @token) end - def register_machine(machine_fqdn, config) + def register_machine(machine_fqdn, config, email=nil) machine_type = config["parameters"]["everest_machine_type"] post_yaml(machine_fqdn, machine_type, YAML.dump(config)) add_system_to_cobbler(machine_fqdn, config["parameters"]) @@ -97,8 +99,7 @@ module EverestBootstrap end class CloudRepo < EverestRepo - DEFAULT_CLOUD_REPO = "everest-repo.usersys.redhat.com" - def initialize(repo=DEFAULT_CLOUD_REPO) + def initialize(repo) super(repo) end @@ -111,10 +112,12 @@ module EverestBootstrap include RedHatDDNS attr_reader :type, :hostname, :fqdn - def initialize(machine_type, fqdn, repo, config) + def initialize(machine_type, fqdn, repo, config, email=nil) + puts "Initializing" @machine_type = machine_type @fqdn = fqdn @config = config + @email = email @everest_repo = EverestRepo.new(repo) end @@ -123,9 +126,9 @@ module EverestBootstrap end def add_system_to_cobbler - @everest_repo.add_system_to_cobbler(@fqdn, @config["parameters"]) + @everest_repo.add_system_to_cobbler(@fqdn, @config["parameters"], @email) end - + def koan(virt_path) koan_command = "/usr/bin/koan -s #{@everest_repo.fqdn} " + "--virt --virt-type=xenpv --virt-path=#{virt_path} " + |
