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 |
# File 'lib/fucking_shell_scripts/server.rb', line 17 def build @server = connection.servers.create( 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) ) @server.username = .fetch(:username) if .fetch(:username) print "Creating #{.fetch(:size)} from #{.fetch(:image)}" server.wait_for do print "." ready? end puts "ready!" puts "" print "Waiting for ssh access" server.wait_for do print "." sshable? end puts "#{server.dns_name} ready!" end |
#configure ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/fucking_shell_scripts/server.rb', line 47 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 |