Class: Fog::Introspection::HuaweiCloud::Mock
- Inherits:
-
Object
- Object
- Fog::Introspection::HuaweiCloud::Mock
- Includes:
- HuaweiCloud::Core
- Defined in:
- lib/fog/introspection/huaweicloud.rb,
lib/fog/introspection/huaweicloud/requests/get_rules.rb,
lib/fog/introspection/huaweicloud/requests/list_rules.rb,
lib/fog/introspection/huaweicloud/requests/create_rules.rb,
lib/fog/introspection/huaweicloud/requests/delete_rules.rb,
lib/fog/introspection/huaweicloud/requests/delete_rules_all.rb,
lib/fog/introspection/huaweicloud/requests/get_introspection.rb,
lib/fog/introspection/huaweicloud/requests/abort_introspection.rb,
lib/fog/introspection/huaweicloud/requests/create_introspection.rb,
lib/fog/introspection/huaweicloud/requests/get_introspection_details.rb
Class Method Summary collapse
Instance Method Summary collapse
- #abort_introspection(_node_id) ⇒ Object
- #create_introspection(_node_id, _options = {}) ⇒ Object
- #create_rules(_) ⇒ Object
- #data ⇒ Object
- #delete_rules(_rule_id) ⇒ Object
- #delete_rules_all ⇒ Object
- #get_introspection(_node_id) ⇒ Object
- #get_introspection_details(_node_id) ⇒ Object
- #get_rules(_rule_id) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_rules ⇒ Object
- #reset_data ⇒ Object
Constructor Details
Class Method Details
.data ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/fog/introspection/huaweicloud.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.(file, __FILE__))) end end |
.reset ⇒ Object
51 52 53 |
# File 'lib/fog/introspection/huaweicloud.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/huaweicloud/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/huaweicloud/requests/create_introspection.rb', line 26 def create_introspection(_node_id, = {}) response = Excon::Response.new response.status = 202 response.body = "" response end |
#create_rules(_) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/fog/introspection/huaweicloud/requests/create_rules.rb', line 28 def create_rules(_) response = Excon::Response.new response.status = 200 response.body = {"rules" => data[:rules].first} response end |
#data ⇒ Object
64 65 66 |
# File 'lib/fog/introspection/huaweicloud.rb', line 64 def data self.class.data[@huaweicloud_username] end |
#delete_rules(_rule_id) ⇒ Object
15 16 17 18 19 |
# File 'lib/fog/introspection/huaweicloud/requests/delete_rules.rb', line 15 def delete_rules(_rule_id) response = Excon::Response.new response.status = 204 response end |
#delete_rules_all ⇒ Object
15 16 17 18 19 |
# File 'lib/fog/introspection/huaweicloud/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/huaweicloud/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/huaweicloud/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/huaweicloud/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_rules ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/introspection/huaweicloud/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_data ⇒ Object
68 69 70 |
# File 'lib/fog/introspection/huaweicloud.rb', line 68 def reset_data self.class.data.delete(@huaweicloud_username) end |