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
Returns a new instance of Cloud.
17
18
19
20
21
|
# File 'lib/misty/cloud.rb', line 17
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/misty/cloud.rb', line 141
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.
11
12
13
|
# File 'lib/misty/cloud.rb', line 11
def auth
@auth
end
|
Class Method Details
.dot_to_underscore(val) ⇒ Object
13
14
15
|
# File 'lib/misty/cloud.rb', line 13
def self.dot_to_underscore(val)
val.gsub(/\./,'_')
end
|
.set_configuration(params) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# 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. = Misty::HTTP::Header.new('Accept' => 'application/json; q=1.0')
config..add(params[:headers]) if params[:headers] && !params[:headers].empty?
config
end
|
Instance Method Details
#alarming ⇒ Object
48
49
50
|
# File 'lib/misty/cloud.rb', line 48
def alarming
@alarming ||= build_service(:alarming)
end
|
#application_catalog ⇒ Object
44
45
46
|
# File 'lib/misty/cloud.rb', line 44
def application_catalog
@application_catalog ||= build_service(:application_catalog)
end
|
#backup ⇒ Object
52
53
54
|
# File 'lib/misty/cloud.rb', line 52
def backup
@backup ||= build_service(:backup)
end
|
56
57
58
|
# File 'lib/misty/cloud.rb', line 56
def baremetal
@baremetal ||= build_service(:baremetal)
end
|
#block_storage ⇒ Object
Also known as:
volume
60
61
62
|
# File 'lib/misty/cloud.rb', line 60
def block_storage
@block_storage ||= build_service(:block_storage)
end
|
#build_service(service_name) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/misty/cloud.rb', line 36
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
64
65
66
|
# File 'lib/misty/cloud.rb', line 64
def clustering
@clustering ||= build_service(:clustering)
end
|
#compute ⇒ Object
68
69
70
|
# File 'lib/misty/cloud.rb', line 68
def compute
@compute ||= build_service(:compute)
end
|
#container_infrastructure_management ⇒ Object
72
73
74
|
# File 'lib/misty/cloud.rb', line 72
def container_infrastructure_management
@container_infrastructure_management ||= build_service(:container_infrastructure_management)
end
|
#data_processing ⇒ Object
76
77
78
|
# File 'lib/misty/cloud.rb', line 76
def data_processing
@data_processing ||= build_service(:data_processing)
end
|
#data_protection_orchestration ⇒ Object
80
81
82
|
# File 'lib/misty/cloud.rb', line 80
def data_protection_orchestration
@data_protection_orchestration ||= build_service(:data_protection_orchestration)
end
|
#database ⇒ Object
84
85
86
|
# File 'lib/misty/cloud.rb', line 84
def database
@database ||= build_service(:database)
end
|
#domain_name_server ⇒ Object
Also known as:
dns
88
89
90
|
# File 'lib/misty/cloud.rb', line 88
def domain_name_server
@domain_name_server ||= build_service(:domain_name_server)
end
|
#identity ⇒ Object
92
93
94
|
# File 'lib/misty/cloud.rb', line 92
def identity
@identity ||= build_service(:identity)
end
|
#image ⇒ Object
96
97
98
|
# File 'lib/misty/cloud.rb', line 96
def image
@image ||= build_service(:image)
end
|
#load_balancer ⇒ Object
100
101
102
|
# File 'lib/misty/cloud.rb', line 100
def load_balancer
@load_balancer ||= build_service(:load_balancer)
end
|
#messaging ⇒ Object
104
105
106
|
# File 'lib/misty/cloud.rb', line 104
def messaging
@messaging ||= build_service(:messaging)
end
|
#metering ⇒ Object
108
109
110
|
# File 'lib/misty/cloud.rb', line 108
def metering
@metering ||= build_service(:metering)
end
|
#networking ⇒ Object
112
113
114
|
# File 'lib/misty/cloud.rb', line 112
def networking
@networking ||= build_service(:networking)
end
|
#nfv_orchestration ⇒ Object
116
117
118
|
# File 'lib/misty/cloud.rb', line 116
def nfv_orchestration
@nfv_orchestration ||= build_service(:nfv_orchestration)
end
|
#object_storage ⇒ Object
120
121
122
|
# File 'lib/misty/cloud.rb', line 120
def object_storage
@object_storage ||= build_service(:object_storage)
end
|
#orchestration ⇒ Object
124
125
126
|
# File 'lib/misty/cloud.rb', line 124
def orchestration
@orchestration ||= build_service(:orchestration)
end
|
#search ⇒ Object
128
129
130
|
# File 'lib/misty/cloud.rb', line 128
def search
@search ||= build_service(:search)
end
|
#shared_file_systems ⇒ Object
132
133
134
|
# File 'lib/misty/cloud.rb', line 132
def shared_file_systems
@shared_file_systems ||= build_service(:shared_file_systems)
end
|