Module: Bosh::OpenstackRegistry
- Defined in:
- lib/openstack_registry/config.rb,
lib/openstack_registry.rb,
lib/openstack_registry/errors.rb,
lib/openstack_registry/models.rb,
lib/openstack_registry/runner.rb,
lib/openstack_registry/version.rb,
lib/openstack_registry/yaml_helper.rb,
lib/openstack_registry/api_controller.rb,
lib/openstack_registry/server_manager.rb
Overview
Copyright © 2009-2012 VMware, Inc.
Defined Under Namespace
Modules: Models, YamlHelper Classes: ApiController, ConfigError, ConnectionError, Error, FatalError, OpenstackError, Runner, ServerError, ServerManager, ServerNotFound
Constant Summary collapse
- VERSION =
"0.0.5"
Class Attribute Summary collapse
-
.db ⇒ Object
Returns the value of attribute db.
-
.http_password ⇒ Object
Returns the value of attribute http_password.
-
.http_port ⇒ Object
Returns the value of attribute http_port.
-
.http_user ⇒ Object
Returns the value of attribute http_user.
-
.logger ⇒ Object
Returns the value of attribute logger.
- .openstack ⇒ Object
Class Method Summary collapse
Class Attribute Details
.db ⇒ Object
Returns the value of attribute db.
11 12 13 |
# File 'lib/openstack_registry/config.rb', line 11 def db @db end |
.http_password ⇒ Object
Returns the value of attribute http_password.
10 11 12 |
# File 'lib/openstack_registry/config.rb', line 10 def http_password @http_password end |
.http_port ⇒ Object
Returns the value of attribute http_port.
8 9 10 |
# File 'lib/openstack_registry/config.rb', line 8 def http_port @http_port end |
.http_user ⇒ Object
Returns the value of attribute http_user.
9 10 11 |
# File 'lib/openstack_registry/config.rb', line 9 def http_user @http_user end |
.logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/openstack_registry/config.rb', line 7 def logger @logger end |
.openstack ⇒ Object
42 43 44 |
# File 'lib/openstack_registry/config.rb', line 42 def openstack openstack ||= Fog::Compute.new(@openstack_options) end |
Class Method Details
.configure(config) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/openstack_registry/config.rb', line 15 def configure(config) validate_config(config) @logger ||= Logger.new(config["logfile"] || STDOUT) if config["loglevel"].kind_of?(String) @logger.level = Logger.const_get(config["loglevel"].upcase) end @http_port = config["http"]["port"] @http_user = config["http"]["user"] @http_password = config["http"]["password"] @openstack_properties = config["openstack"] @openstack_options = { :provider => "OpenStack", :openstack_auth_url => @openstack_properties["auth_url"], :openstack_username => @openstack_properties["username"], :openstack_api_key => @openstack_properties["api_key"], :openstack_tenant => @openstack_properties["tenant"], :openstack_region => @openstack_properties["region"] } @db = connect_db(config["db"]) end |
.connect_db(db_config) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/openstack_registry/config.rb', line 46 def connect_db(db_config) = { :max_connections => db_config["max_connections"], :pool_timeout => db_config["pool_timeout"] } db = Sequel.connect(db_config["database"], ) db.logger = @logger db.sql_log_level = :debug db end |
.validate_config(config) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/openstack_registry/config.rb', line 58 def validate_config(config) unless config.is_a?(Hash) raise ConfigError, "Invalid config format, Hash expected, " \ "#{config.class} given" end unless config.has_key?("http") && config["http"].is_a?(Hash) raise ConfigError, "HTTP configuration is missing from " \ "config file" end unless config.has_key?("db") && config["db"].is_a?(Hash) raise ConfigError, "Database configuration is missing from " \ "config file" end unless config.has_key?("openstack") && config["openstack"].is_a?(Hash) raise ConfigError, "OpenStack configuration is missing from " \ "config file" end end |