Class: Cloudscale::Plugins::PluginMongodbPreop
- Inherits:
-
Cloudscale::Preops::Preop
- Object
- Cloudscale::Preops::Preop
- Cloudscale::Plugins::PluginMongodbPreop
- Includes:
- Singleton
- Defined in:
- lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb
Constant Summary collapse
- @@options =
{ :host => { :argument => "--host", :description => "Host for your MongoDB Instance (e.g. host.mongodb.com)", :required => true, :value => nil }, :port => { :argument => "--port", :description => "Port for your MongoDB Instance (Standard 27017)", :required => false, :value => 27017 }, :db => { :argument => "--db", :description => "Database of your MongoDB instance", :required => true, :value => nil }, :ssl => { :argument => "--ssl", :description => "Usage SSL of your MongoDB instance", :required => false, :value => false }, :username => { :argument => "--username", :description => "Username for your MongoDB instance", :required => false, :value => nil }, :password => { :argument => "--password", :description => "Password for your MongoDB instance", :required => false, :value => nil }, :connect_timeout => { :argument => "--connect_timeout", :description => "Connection Timeout for your MongoDB instance", :required => false, :value => 30 }, :op_timeout => { :argument => "--op_timeout", :description => "Operation TImeout for your MongoDB instance", :required => false, :value => 30 } }
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#db ⇒ Object
Returns the value of attribute db.
Attributes inherited from Cloudscale::Preops::Preop
Instance Method Summary collapse
-
#initialize ⇒ PluginMongodbPreop
constructor
A new instance of PluginMongodbPreop.
- #options ⇒ Object
Methods inherited from Cloudscale::Preops::Preop
#clear_options, #get_option, #get_option_value, #init, #init_charts, #init_menus, #init_options, #save_options, #set_option_value
Constructor Details
#initialize ⇒ PluginMongodbPreop
Returns a new instance of PluginMongodbPreop.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb', line 72 def initialize self.init begin @connection = Mongo::Connection.new([:host][:value], [:port][:value]) rescue Mongo::ConnectionFailure puts "Unable to connect to the MongoDB Daemon.", "Please ensure it is running on #{@host}:#{@port}\n\nException Message: #{$!.}. Also confirm if SSL should be enabled or disabled." end # Try to connect to the database if (@connection != nil) @db = @connection.db([:db][:value]) end begin if (@username != nil) @db.authenticate([:username][:value], [:password][:value]) end rescue Mongo::AuthenticationError puts "Unable to authenticate to MongoDB Database." << $!. end end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
16 17 18 |
# File 'lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb', line 16 def connection @connection end |
#db ⇒ Object
Returns the value of attribute db.
16 17 18 |
# File 'lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb', line 16 def db @db end |
Instance Method Details
#options ⇒ Object
68 69 70 |
# File 'lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb', line 68 def @@options end |