Class: Cloudscale::Plugins::PluginPostgresPreop

Inherits:
Cloudscale::Preops::Preop show all
Includes:
Singleton
Defined in:
lib/cloudscale/plugins/preops/plugin_postgres_preop.rb

Constant Summary collapse

@@options =
{
    :host => {
    :argument => "--host",
    :description => "Host for your Postgres Instance (e.g. host.instance.com)",
    :required => true,
    :value => nil     
  },
  :port => {
    :argument => "--port",
    :description => "Port for your Postgres Instance (Standard 5432)",
    :required => false,
    :value => 5432
  },        
  :db => {
    :argument => "--db",
    :description => "Database of your Postgres instance",
    :required => true,
    :value => nil
  },   
  :username => {
    :argument => "--username",
    :description => "Username for your Postgres instance",
    :required => false,
    :value => nil
  },
  :password => {
    :argument => "--password",
    :description => "Password for your Postgres instance",
    :required => false,
    :value => nil
  }
}

Instance Attribute Summary

Attributes inherited from Cloudscale::Preops::Preop

#log, #registry

Instance Method Summary collapse

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

#initializePluginPostgresPreop

Returns a new instance of PluginPostgresPreop.



53
54
55
56
57
58
59
60
61
62
# File 'lib/cloudscale/plugins/preops/plugin_postgres_preop.rb', line 53

def initialize
  self.init
  begin
    @connection = PG.connect(:host => options[:host][:value], :user => options[:username][:value], 
      :password => options[:password][:value], 
      :port => options[:port][:value].to_i, :dbname => options[:db][:value])
  rescue PGError => e
    puts e.message
  end
end

Instance Method Details

#connectionObject



64
65
66
# File 'lib/cloudscale/plugins/preops/plugin_postgres_preop.rb', line 64

def connection
  @connection
end

#optionsObject



49
50
51
# File 'lib/cloudscale/plugins/preops/plugin_postgres_preop.rb', line 49

def options      
  @@options
end