Class: Fog::Introspection::OpenStack::Real
- Inherits:
-
Object
- Object
- Fog::Introspection::OpenStack::Real
show all
- Includes:
- OpenStack::Core
- Defined in:
- lib/fog/openstack/introspection.rb,
lib/fog/openstack/requests/introspection/get_rules.rb,
lib/fog/openstack/requests/introspection/list_rules.rb,
lib/fog/openstack/requests/introspection/create_rules.rb,
lib/fog/openstack/requests/introspection/delete_rules.rb,
lib/fog/openstack/requests/introspection/delete_rules_all.rb,
lib/fog/openstack/requests/introspection/get_introspection.rb,
lib/fog/openstack/requests/introspection/abort_introspection.rb,
lib/fog/openstack/requests/introspection/create_introspection.rb,
lib/fog/openstack/requests/introspection/get_introspection_details.rb
Instance Attribute Summary
#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id
Instance Method Summary
collapse
#credentials, #initialize_identity, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/fog/openstack/introspection.rb', line 76
def initialize(options = {})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['introspection']
@openstack_service_name = options[:openstack_service_name]
@connection_options = options[:connection_options] || {}
authenticate
unless @path.match(SUPPORTED_VERSIONS)
@path = "/" + Fog::OpenStack.get_supported_version(
SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options
)
end
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
|
Instance Method Details
#abort_introspection(node_id) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/fog/openstack/requests/introspection/abort_introspection.rb', line 5
def abort_introspection(node_id)
request(
:body => "",
:expects => 202,
:method => "POST",
:path => "introspection/#{node_id}/abort"
)
end
|
#create_introspection(node_id, options = {}) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/fog/openstack/requests/introspection/create_introspection.rb', line 5
def create_introspection(node_id, options = {})
if options
data = {
'new_ipmi_username' => options[:new_ipmi_username],
'new_ipmi_password' => options[:new_ipmi_password]
}
body = Fog::JSON.encode(data)
else
body = ""
end
request(
:body => body,
:expects => 202,
:method => "POST",
:path => "introspection/#{node_id}"
)
end
|
#create_rules(attributes) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/fog/openstack/requests/introspection/create_rules.rb', line 5
def create_rules(attributes)
attributes_valid = [
:actions,
:conditions,
:uuid,
:description
]
data = attributes.select do |key, _|
attributes_valid.include?(key.to_sym)
end
request(
:body => Fog::JSON.encode(data),
:expects => 200,
:method => "POST",
:path => "rules"
)
end
|
#delete_rules(rule_id) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/delete_rules.rb', line 5
def delete_rules(rule_id)
request(
:expects => 204,
:method => "DELETE",
:path => "rules/#{rule_id}"
)
end
|
#delete_rules_all ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/delete_rules_all.rb', line 5
def delete_rules_all
request(
:expects => 204,
:method => "DELETE",
:path => "rules"
)
end
|
#get_introspection(node_id) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/get_introspection.rb', line 5
def get_introspection(node_id)
request(
:expects => 200,
:method => "GET",
:path => "introspection/#{node_id}"
)
end
|
#get_introspection_details(node_id) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/get_introspection_details.rb', line 5
def get_introspection_details(node_id)
request(
:expects => 200,
:method => 'GET',
:path => "introspection/#{node_id}/data"
)
end
|
#get_rules(rule_id) ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/get_rules.rb', line 5
def get_rules(rule_id)
request(
:expects => 200,
:method => 'GET',
:path => "rules/#{rule_id}"
)
end
|
#list_rules ⇒ Object
5
6
7
8
9
10
11
|
# File 'lib/fog/openstack/requests/introspection/list_rules.rb', line 5
def list_rules
request(
:expects => 200,
:method => 'GET',
:path => "rules"
)
end
|
#request(params) ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/fog/openstack/introspection.rb', line 99
def request(params)
response = @connection.request(
params.merge(
:headers => {
'Content-Type' => 'application/json',
'X-Auth-Token' => @auth_token
}.merge!(params[:headers] || {}),
:path => "#{@path}/#{params[:path]}"
)
)
rescue Excon::Errors::Unauthorized => error
if error.response.body != "Bad username or password" @openstack_must_reauthenticate = true
authenticate
retry
else raise error
end
rescue Excon::Errors::HTTPStatusError => error
raise case error
when Excon::Errors::NotFound
Fog::Introspection::OpenStack::NotFound.slurp(error)
else
error
end
else
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
end
response
end
|