diff options
| author | Brenton Leanhardt <bleanhar@redhat.com> | 2008-04-28 15:08:51 -0400 |
|---|---|---|
| committer | Brenton Leanhardt <bleanhar@redhat.com> | 2008-05-01 10:33:52 -0400 |
| commit | 6087621ccbdc0d5dbf0a5aae94b21ba00eff293f (patch) | |
| tree | bf15ab1f5674d5e1a881d8c333a2dd16dfd3f629 | |
| parent | e8b174ad3b74296dbc933cbb72fe7c0d7cc4bbbb (diff) | |
Adding an 'advanced' mode to everest-bootstrap
This allows you to pass in a yaml description for a node type via stdin or with
the --yaml option. See 'everest-bootstrap advanced -h' for more info.
| -rw-r--r-- | everest-bootstrap/bin/everest-bootstrap | 48 | ||||
| -rw-r--r-- | everest-bootstrap/ext/rubygem-everest-bootstrap.spec | 9 | ||||
| -rw-r--r-- | everest-bootstrap/lib/everest-bootstrap/core.rb | 28 |
3 files changed, 65 insertions, 20 deletions
diff --git a/everest-bootstrap/bin/everest-bootstrap b/everest-bootstrap/bin/everest-bootstrap index 0f4ac50..981e763 100644 --- a/everest-bootstrap/bin/everest-bootstrap +++ b/everest-bootstrap/bin/everest-bootstrap @@ -110,13 +110,59 @@ Main { } def run + # Ask all the silly questions get_input + + classes = @everest_repo.classes_for(@machine_type) + config = {"classes" => classes, "parameters" => @facts} + e = EverestMachine.new(@machine_type, @fqdn, @repo, - @facts) + config) e.post_config e.add_system_to_cobbler e.koan(@virt_path) unless params["config-only"].given? end + + mode 'advanced' do + option('fqdn', 'f'){ + required + description "Fully qualified domain name of machine to be provisioned" + argument_required + } + + option('repo', '-r'){ + required + description "Fully qualified domain name for the Everest repo machine to use for provisioning" + argument_required + } + + option('yaml', 'y'){ + description "YAML configuration for this machine" + argument_required + validate {|f| File.exist?(f)} + } + + option('virt-path', 'v'){ + description "Volume group or flat file for koan provisioning" + argument_required + } + + def run + config = if params['yaml'].given? + YAML.load(File.read(params['yaml'].value)) + else + YAML.load($stdin.read) + end + + e = EverestMachine.new(config["parameters"]["everest_machine_type"], + params['fqdn'].value, + params['repo'].value, + config) + e.post_config + e.add_system_to_cobbler + e.koan(params['virt-path'].value) if params["virt-path"].given? + end + end } diff --git a/everest-bootstrap/ext/rubygem-everest-bootstrap.spec b/everest-bootstrap/ext/rubygem-everest-bootstrap.spec index b9227ba..67ac74a 100644 --- a/everest-bootstrap/ext/rubygem-everest-bootstrap.spec +++ b/everest-bootstrap/ext/rubygem-everest-bootstrap.spec @@ -6,17 +6,18 @@ Summary: Tool for provisioning virtual machines Name: rubygem-%{gemname} -Version: 0.2.2 -Release: 1%{?dist} +Version: 0.4.0 +Release: 5%{?dist} Group: Development/Languages License: Ruby License/GPL Source0: %{gemname}-%{version}.gem BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n) Requires: rubygems -Requires: rubygem(everest) Requires: rubygem(highline) +Requires: rubygem(reststop) +Requires: rubygem(activesupport) Requires: rubygem(main) -Requires: rubygem(hoe) >= 1.3.0 +Requires: rubygem(hoe) >= 1.5.1 Requires: wget Requires: lvm2 BuildRequires: rubygems diff --git a/everest-bootstrap/lib/everest-bootstrap/core.rb b/everest-bootstrap/lib/everest-bootstrap/core.rb index 2bae4f4..acd608b 100644 --- a/everest-bootstrap/lib/everest-bootstrap/core.rb +++ b/everest-bootstrap/lib/everest-bootstrap/core.rb @@ -7,9 +7,10 @@ module EverestBootstrap class EverestRepo attr_reader :machines, :machine_types_url, :cobbler_profiles, :fqdn - def initialize(repo_name) - @repo_name = repo_name - @fqdn = "#{@repo_name}-repo.usersys.redhat.com" + def initialize(repo) + @repo = repo + # Allow users to pass in just the machine-name or the fqdn + @fqdn = @repo.split(".").size > 1 ? @repo : "#{@repo}-repo.usersys.redhat.com" @everestd = "http://#{@fqdn}:8106" @machine_types_url = @everestd + "/machine_types.html" @@ -37,10 +38,10 @@ module EverestBootstrap end # Here's where we make use of the DSL's simple templating - f.instance_variable_set(:@repo_name, @repo_name) + f.instance_variable_set(:@repo, @repo) f.instance_variable_set(:@machine_name, machine_name) def f.default - self["default"].gsub("%repo%", @repo_name).gsub("%machine_name%", @machine_name) + self["default"].gsub("%repo%", @repo).gsub("%machine_name%", @machine_name) end f @@ -70,10 +71,8 @@ module EverestBootstrap end end - def post_config(node_name, machine_type, params) - classes = classes_for(machine_type) - config = YAML.dump({"classes" => classes, "parameters" => params}) - Restr.post("#{@everestd}/nodes", :node_name => node_name, :yaml => config) + def post_yaml(node_name, machine_type, yaml) + Restr.post("#{@everestd}/nodes", :node_name => node_name, :yaml => yaml) end def add_system_to_cobbler(name, params) @@ -94,20 +93,19 @@ module EverestBootstrap include RedHatDDNS attr_reader :type, :hostname, :fqdn - def initialize(machine_type, fqdn, repo_name, facts) + def initialize(machine_type, fqdn, repo, config) @machine_type = machine_type @fqdn = fqdn - @repo_name = repo_name + "-repo" - @facts = facts - @everest_repo = EverestRepo.new(repo_name) + @config = config + @everest_repo = EverestRepo.new(repo) end def post_config - @everest_repo.post_config(@fqdn, @machine_type, @facts) + @everest_repo.post_yaml(@fqdn, @machine_type, YAML.dump(@config)) end def add_system_to_cobbler - @everest_repo.add_system_to_cobbler(@fqdn, @facts) + @everest_repo.add_system_to_cobbler(@fqdn, @config["parameters"]) end def koan(virt_path) |
