Class: Skewer::CLI
- Inherits:
-
Object
- Object
- Skewer::CLI
- Defined in:
- lib/cli.rb,
lib/parser.rb
Overview
this is responsible for composing all the other components. or should be.
Defined Under Namespace
Classes: Parser
Instance Attribute Summary collapse
-
#bootstrapper ⇒ Object
readonly
Returns the value of attribute bootstrapper.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Class Method Summary collapse
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #destroy ⇒ Object
- #go ⇒ Object
-
#initialize(options) ⇒ CLI
constructor
A new instance of CLI.
- #select_node(kind) ⇒ Object
Constructor Details
#initialize(options) ⇒ CLI
Returns a new instance of CLI.
14 15 16 17 18 19 20 |
# File 'lib/cli.rb', line 14 def initialize() @options = @config = SkewerConfig.instance @config.() @util = Util.new @config.set(:logger, Skewer.logger) end |
Instance Attribute Details
#bootstrapper ⇒ Object (readonly)
Returns the value of attribute bootstrapper.
12 13 14 |
# File 'lib/cli.rb', line 12 def bootstrapper @bootstrapper end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
12 13 14 |
# File 'lib/cli.rb', line 12 def node @node end |
Class Method Details
.bootstrap_and_go(options) ⇒ Object
92 93 94 95 96 |
# File 'lib/cli.rb', line 92 def self.bootstrap_and_go() skewer = self.new() skewer.bootstrap skewer.go end |
Instance Method Details
#bootstrap ⇒ Object
65 66 67 68 69 |
# File 'lib/cli.rb', line 65 def bootstrap node = select_node(@options[:kind]) @node = node @bootstrapper = Bootstrapper.new(node, @options) end |
#destroy ⇒ Object
61 62 63 |
# File 'lib/cli.rb', line 61 def destroy @node.destroy unless @options[:keep] end |
#go ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cli.rb', line 71 def go require 'puppet' require 'cuke' begin node = @node node.wait_for { ready? } @bootstrapper.go Puppet.run(node, @options) location = @util.get_location(node) Hooks.new(location).run Cuke.new(@config.get(:cuke_dir), location).run if @config.get(:cuke_dir) Skewer.logger.debug "Node ready\n open http://#{location} or \n ssh -l #{node.username} #{location}" rescue Exception => exception Skewer.logger.debug exception raise "Something went wrong, and we killed the node" ensure destroy end end |
#select_node(kind) ⇒ Object
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 |
# File 'lib/cli.rb', line 22 def select_node(kind) Skewer.logger.debug "Evaluating cloud #{kind}" image = @options[:image] case kind when :ec2 require 'aws/security_group' require 'aws/node' require 'aws/service' Skewer.logger.debug 'Launching an EC2 node' aws_group = @options[:group] group = aws_group ? aws_group : 'default' node = AWS::Node.new(image, [group]).node when :rackspace require 'rackspace/node' Skewer.logger.debug 'Launching a Rackspace node' node = Rackspace::Node.new(@config.get('flavor_id'), image, 'default').node when :linode raise "not implemented" when :eucalyptus Skewer.logger.debug 'Using the EC2 API' require 'eucalyptus' node = Eucalyptus.new when :vagrant Skewer.logger.debug 'Launching a local vagrant node' require 'ersatz/ersatz_node.rb' node = ErsatzNode.new('default', 'vagrant') when :stub Skewer.logger.debug "Launching stubbed node for testing" require 'stub_node' node = StubNode.new when :ersatz require 'ersatz/ersatz_node.rb' node = ErsatzNode.new(@config.get('host'), @config.get('user')) else raise "I don't know that cloud" end node end |