Class: Fog::Introspection::OpenStack::Mock

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core
Defined in:
lib/fog/introspection/openstack.rb,
lib/fog/introspection/openstack/requests/get_rules.rb,
lib/fog/introspection/openstack/requests/list_rules.rb,
lib/fog/introspection/openstack/requests/create_rules.rb,
lib/fog/introspection/openstack/requests/delete_rules.rb,
lib/fog/introspection/openstack/requests/delete_rules_all.rb,
lib/fog/introspection/openstack/requests/get_introspection.rb,
lib/fog/introspection/openstack/requests/abort_introspection.rb,
lib/fog/introspection/openstack/requests/create_introspection.rb,
lib/fog/introspection/openstack/requests/get_introspection_details.rb

Instance Attribute Summary

Attributes included from OpenStack::Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_api_version, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OpenStack::Core

#credentials, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



57
58
59
60
# File 'lib/fog/introspection/openstack.rb', line 57

def initialize(options = {})
  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86_400).iso8601
end

Class Method Details

.dataObject



43
44
45
46
47
48
49
# File 'lib/fog/introspection/openstack.rb', line 43

def self.data
  @data ||= Hash.new do |hash, key|
    # Introspection data is *huge* we load it from a yaml file
    file = "../../../../test/fixtures/introspection.yaml"
    hash[key] = YAML.load(File.read(File.expand_path(file, __FILE__)))
  end
end

.resetObject



51
52
53
# File 'lib/fog/introspection/openstack.rb', line 51

def self.reset
  @data = nil
end

Instance Method Details

#abort_introspection(_node_id) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/introspection/openstack/requests/abort_introspection.rb', line 16

def abort_introspection(_node_id)
  response = Excon::Response.new
  response.status = 202
  response.body = ""
  response
end

#create_introspection(_node_id, _options = {}) ⇒ Object



26
27
28
29
30
31
# File 'lib/fog/introspection/openstack/requests/create_introspection.rb', line 26

def create_introspection(_node_id, _options = {})
  response = Excon::Response.new
  response.status = 202
  response.body = ""
  response
end

#create_rules(_) ⇒ Object



28
29
30
31
32
33
# File 'lib/fog/introspection/openstack/requests/create_rules.rb', line 28

def create_rules(_)
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#dataObject



62
63
64
# File 'lib/fog/introspection/openstack.rb', line 62

def data
  self.class.data[@openstack_username]
end

#delete_rules(_rule_id) ⇒ Object



15
16
17
18
19
# File 'lib/fog/introspection/openstack/requests/delete_rules.rb', line 15

def delete_rules(_rule_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_rules_allObject



15
16
17
18
19
# File 'lib/fog/introspection/openstack/requests/delete_rules_all.rb', line 15

def delete_rules_all
  response = Excon::Response.new
  response.status = 204
  response
end

#get_introspection(_node_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/introspection/openstack/requests/get_introspection.rb', line 15

def get_introspection(_node_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"error" => "null", "finished" => "true"}
  response
end

#get_introspection_details(_node_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/introspection/openstack/requests/get_introspection_details.rb', line 15

def get_introspection_details(_node_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"data" => data[:introspection_data]}
  response
end

#get_rules(_rule_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/introspection/openstack/requests/get_rules.rb', line 15

def get_rules(_rule_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#list_rulesObject



15
16
17
18
19
20
# File 'lib/fog/introspection/openstack/requests/list_rules.rb', line 15

def list_rules
  response = Excon::Response.new
  response.status = 200
  response.body = {"rules" => data[:rules].first}
  response
end

#reset_dataObject



66
67
68
# File 'lib/fog/introspection/openstack.rb', line 66

def reset_data
  self.class.data.delete(@openstack_username)
end