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
|
# File 'lib/misty/cloud.rb', line 16
def initialize(params) @params = params
@config = self.class.set_configuration(params)
@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 = []
Misty.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
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/misty/cloud.rb', line 22
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. = params[:headers]
config
end
|
Instance Method Details
#alarming ⇒ Object
46
47
48
|
# File 'lib/misty/cloud.rb', line 46
def alarming
@alarming ||= build_service(:alarming)
end
|
#application_catalog ⇒ Object
42
43
44
|
# File 'lib/misty/cloud.rb', line 42
def application_catalog
@application_catalog ||= build_service(:application_catalog)
end
|
#backup ⇒ Object
50
51
52
|
# File 'lib/misty/cloud.rb', line 50
def backup
@backup ||= build_service(:backup)
end
|
54
55
56
|
# File 'lib/misty/cloud.rb', line 54
def baremetal
@baremetal ||= build_service(:baremetal)
end
|
#block_storage ⇒ Object
Also known as:
volume
58
59
60
|
# File 'lib/misty/cloud.rb', line 58
def block_storage
@block_storage ||= build_service(:block_storage)
end
|
#build_service(service_name) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/misty/cloud.rb', line 34
def build_service(service_name)
service = Misty.services.find {|service| service.name == service_name}
options = @params[service.name] ? @params[service.name] : {}
version = self.class.dot_to_underscore(service.version(options[:api_version]))
klass = Object.const_get("Misty::Openstack::#{service.project.capitalize}::#{version.capitalize}")
klass.new(@auth, @config, options)
end
|
#clustering ⇒ Object
62
63
64
|
# File 'lib/misty/cloud.rb', line 62
def clustering
@clustering ||= build_service(:clustering)
end
|
#compute ⇒ Object
66
67
68
|
# File 'lib/misty/cloud.rb', line 66
def compute
@compute ||= build_service(:compute)
end
|
#container_infrastructure_management ⇒ Object
70
71
72
|
# File 'lib/misty/cloud.rb', line 70
def container_infrastructure_management
@container_infrastructure_management ||= build_service(:container_infrastructure_management)
end
|
#data_processing ⇒ Object
74
75
76
|
# File 'lib/misty/cloud.rb', line 74
def data_processing
@data_processing ||= build_service(:data_processing)
end
|
#data_protection_orchestration ⇒ Object
78
79
80
|
# File 'lib/misty/cloud.rb', line 78
def data_protection_orchestration
@data_protection_orchestration ||= build_service(:data_protection_orchestration)
end
|
#database ⇒ Object
82
83
84
|
# File 'lib/misty/cloud.rb', line 82
def database
@database ||= build_service(:database)
end
|
#domain_name_server ⇒ Object
Also known as:
dns
86
87
88
|
# File 'lib/misty/cloud.rb', line 86
def domain_name_server
@domain_name_server ||= build_service(:domain_name_server)
end
|
#identity ⇒ Object
90
91
92
|
# File 'lib/misty/cloud.rb', line 90
def identity
@identity ||= build_service(:identity)
end
|
#image ⇒ Object
94
95
96
|
# File 'lib/misty/cloud.rb', line 94
def image
@image ||= build_service(:image)
end
|
#load_balancer ⇒ Object
98
99
100
|
# File 'lib/misty/cloud.rb', line 98
def load_balancer
@load_balancer ||= build_service(:load_balancer)
end
|
#messaging ⇒ Object
102
103
104
|
# File 'lib/misty/cloud.rb', line 102
def messaging
@messaging ||= build_service(:messaging)
end
|
#metering ⇒ Object
106
107
108
|
# File 'lib/misty/cloud.rb', line 106
def metering
@metering ||= build_service(:metering)
end
|
#networking ⇒ Object
110
111
112
|
# File 'lib/misty/cloud.rb', line 110
def networking
@networking ||= build_service(:networking)
end
|
#nfv_orchestration ⇒ Object
114
115
116
|
# File 'lib/misty/cloud.rb', line 114
def nfv_orchestration
@nfv_orchestration ||= build_service(:nfv_orchestration)
end
|
#object_storage ⇒ Object
118
119
120
|
# File 'lib/misty/cloud.rb', line 118
def object_storage
@object_storage ||= build_service(:object_storage)
end
|
#orchestration ⇒ Object
122
123
124
|
# File 'lib/misty/cloud.rb', line 122
def orchestration
@orchestration ||= build_service(:orchestration)
end
|
#search ⇒ Object
126
127
128
|
# File 'lib/misty/cloud.rb', line 126
def search
@search ||= build_service(:search)
end
|
#shared_file_systems ⇒ Object
130
131
132
|
# File 'lib/misty/cloud.rb', line 130
def shared_file_systems
@shared_file_systems ||= build_service(:shared_file_systems)
end
|