Class: Misty::Cloud
- Inherits:
-
Object
show all
- Defined in:
- lib/misty/cloud.rb
Defined Under Namespace
Classes: Config
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(params) ⇒ Cloud
16
17
18
19
20
21
|
# File 'lib/misty/cloud.rb', line 16
def initialize(params) @params = params
@config = self.class.set_configuration(params)
@services = Misty.services
@auth = Misty::Auth.factory(params[:auth], @config)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/misty/cloud.rb', line 139
def method_missing(method_name)
services_avail = []
@services.names.each do |service_name|
services_avail << service_name if /#{method_name}/.match(service_name)
end
if services_avail.size == 1
self.send(services_avail[0])
return self.instance_variable_get("@#{services_avail[0]}")
elsif services_avail.size > 1
raise NoMethodError, "Ambiguous Cloud Service: #{method_name}"
else
raise NoMethodError, "No such Cloud Service: #{method_name}"
end
end
|
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
10
11
12
|
# File 'lib/misty/cloud.rb', line 10
def auth
@auth
end
|
Class Method Details
.dot_to_underscore(val) ⇒ Object
12
13
14
|
# File 'lib/misty/cloud.rb', line 12
def self.dot_to_underscore(val)
val.gsub(/\./,'_')
end
|
.set_configuration(params) ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/misty/cloud.rb', line 23
def self.set_configuration(params)
config = Config.new
config.content_type = params[:content_type] ? params[:content_type] : Misty::CONTENT_TYPE
config.interface = params[:interface] ? params[:interface] : Misty::INTERFACE
config.log = Logger.new(params[:log_file] ? params[:log_file] : Misty::LOG_FILE)
config.log.level = params[:log_level] ? params[:log_level] : Misty::LOG_LEVEL
config.region_id = params[:region_id] ? params[:region_id] : Misty::REGION_ID
config.ssl_verify_mode = params.key?(:ssl_verify_mode) ? params[:ssl_verify_mode] : Misty::SSL_VERIFY_MODE
config
end
|
Instance Method Details
#alarming ⇒ Object
47
48
49
|
# File 'lib/misty/cloud.rb', line 47
def alarming
@alarming ||= build_service(:alarming)
end
|
#application_catalog ⇒ Object
43
44
45
|
# File 'lib/misty/cloud.rb', line 43
def application_catalog
@application_catalog ||= build_service(:application_catalog)
end
|
#backup ⇒ Object
51
52
53
|
# File 'lib/misty/cloud.rb', line 51
def backup
@backup ||= build_service(:backup)
end
|
55
56
57
|
# File 'lib/misty/cloud.rb', line 55
def baremetal
@baremetal ||= build_service(:baremetal)
end
|
#block_storage ⇒ Object
Also known as:
volume
59
60
61
|
# File 'lib/misty/cloud.rb', line 59
def block_storage
@block_storage ||= build_service(:block_storage)
end
|
#build_service(service_name) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/misty/cloud.rb', line 34
def build_service(service_name)
service = @services.find {|service| service.name == service_name}
service.options = @params[service.name] if @params[service.name]
service.version = service.options[:api_version]
version = self.class.dot_to_underscore(service.version)
klass = Object.const_get("Misty::Openstack::#{service.project.capitalize}::#{version.capitalize}")
klass.new(@auth, @config, service.options)
end
|
#clustering ⇒ Object
63
64
65
|
# File 'lib/misty/cloud.rb', line 63
def clustering
@clustering ||= build_service(:clustering)
end
|
#compute ⇒ Object
67
68
69
|
# File 'lib/misty/cloud.rb', line 67
def compute
@compute ||= build_service(:compute)
end
|
#container ⇒ Object
71
72
73
|
# File 'lib/misty/cloud.rb', line 71
def container
@container ||= build_service(:container)
end
|
#data_processing ⇒ Object
75
76
77
|
# File 'lib/misty/cloud.rb', line 75
def data_processing
@data_processing ||= build_service(:data_processing)
end
|
#data_protection ⇒ Object
79
80
81
|
# File 'lib/misty/cloud.rb', line 79
def data_protection
@data_protection ||= build_service(:data_protection)
end
|
#database ⇒ Object
83
84
85
|
# File 'lib/misty/cloud.rb', line 83
def database
@database ||= build_service(:database)
end
|
#dns ⇒ Object
87
88
89
|
# File 'lib/misty/cloud.rb', line 87
def dns
@dns ||= build_service(:dns)
end
|
#identity ⇒ Object
91
92
93
|
# File 'lib/misty/cloud.rb', line 91
def identity
@identity ||= build_service(:identity)
end
|
#image ⇒ Object
95
96
97
|
# File 'lib/misty/cloud.rb', line 95
def image
@image ||= build_service(:image)
end
|
#load_balancer ⇒ Object
99
100
101
|
# File 'lib/misty/cloud.rb', line 99
def load_balancer
@load_balancer ||= build_service(:load_balancer)
end
|
#messaging ⇒ Object
103
104
105
|
# File 'lib/misty/cloud.rb', line 103
def messaging
@messaging ||= build_service(:messaging)
end
|
#metering ⇒ Object
107
108
109
|
# File 'lib/misty/cloud.rb', line 107
def metering
@metering ||= build_service(:metering)
end
|
#networking ⇒ Object
111
112
113
|
# File 'lib/misty/cloud.rb', line 111
def networking
@networking ||= build_service(:networking)
end
|
#nfv_orchestration ⇒ Object
115
116
117
|
# File 'lib/misty/cloud.rb', line 115
def nfv_orchestration
@nfv_orchestration ||= build_service(:nfv_orchestration)
end
|
#object_storage ⇒ Object
119
120
121
|
# File 'lib/misty/cloud.rb', line 119
def object_storage
@object_storage ||= build_service(:object_storage)
end
|
#orchestration ⇒ Object
123
124
125
|
# File 'lib/misty/cloud.rb', line 123
def orchestration
@orchestration ||= build_service(:orchestration)
end
|
#search ⇒ Object
127
128
129
|
# File 'lib/misty/cloud.rb', line 127
def search
@search ||= build_service(:search)
end
|
#shared_file_systems ⇒ Object
131
132
133
|
# File 'lib/misty/cloud.rb', line 131
def shared_file_systems
@shared_file_systems ||= build_service(:shared_file_systems)
end
|