Class: FuckingShellScripts::Server
- Inherits:
-
Object
- Object
- FuckingShellScripts::Server
- Defined in:
- lib/fucking_shell_scripts/server.rb
Constant Summary collapse
- NoServerSelected =
Class.new(StandardError)
- MissingInstanceID =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #build ⇒ Object
- #configure ⇒ Object
-
#initialize(connection, options) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(connection, options) ⇒ Server
Returns a new instance of Server.
8 9 10 |
# File 'lib/fucking_shell_scripts/server.rb', line 8 def initialize(connection, ) @connection, @options = connection, end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
6 7 8 |
# File 'lib/fucking_shell_scripts/server.rb', line 6 def server @server end |
Instance Method Details
#bootstrap ⇒ Object
12 13 14 15 |
# File 'lib/fucking_shell_scripts/server.rb', line 12 def bootstrap build configure end |
#build ⇒ Object
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 |
# File 'lib/fucking_shell_scripts/server.rb', line 17 def build = { image_id: .fetch(:image), flavor_id: .fetch(:size), key_name: .fetch(:key_name), tags: { "Name" => name }, groups: .fetch(:security_groups), private_key_path: .fetch(:private_key_path) } .merge!({subnet_id: [:subnet]}) if .has_key?(:subnet) .merge!({block_device_mapping: [:block_device_mapping]}) if .has_key?(:block_device_mapping) @server = connection.servers.create() @server.username = .fetch(:username) if [:username] $stdout.print "Creating #{.fetch(:size)} from #{.fetch(:image)}" server.wait_for do $stdout.print "." ready? end $stdout.puts "ready!" $stdout.puts "" $stdout.print "Waiting for ssh access" server.wait_for do $stdout.print "." sshable? end $stdout.puts "#{server.dns_name} ready!" end |
#configure ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/fucking_shell_scripts/server.rb', line 52 def configure get([:instance_id]) if server.nil? raise NoServerSelected, "Unable to find server. Try specifying the server ID." if server.nil? FuckingShellScripts::SCP.new(server, ).to_server server.ssh(.fetch(:scripts)) end |