Class: Fog::Workflow::OpenStack::V2::Mock

Inherits:
Object
  • Object
show all
Includes:
OpenStack::Core
Defined in:
lib/fog/workflow/openstack/v2.rb,
lib/fog/workflow/openstack/v2/requests/get_task.rb,
lib/fog/workflow/openstack/v2/requests/get_action.rb,
lib/fog/workflow/openstack/v2/requests/rerun_task.rb,
lib/fog/workflow/openstack/v2/requests/list_tasks.rb,
lib/fog/workflow/openstack/v2/requests/get_workflow.rb,
lib/fog/workflow/openstack/v2/requests/list_actions.rb,
lib/fog/workflow/openstack/v2/requests/get_workbook.rb,
lib/fog/workflow/openstack/v2/requests/delete_action.rb,
lib/fog/workflow/openstack/v2/requests/get_execution.rb,
lib/fog/workflow/openstack/v2/requests/create_action.rb,
lib/fog/workflow/openstack/v2/requests/update_action.rb,
lib/fog/workflow/openstack/v2/requests/list_services.rb,
lib/fog/workflow/openstack/v2/requests/list_workbooks.rb,
lib/fog/workflow/openstack/v2/requests/list_workflows.rb,
lib/fog/workflow/openstack/v2/requests/create_workbook.rb,
lib/fog/workflow/openstack/v2/requests/delete_workflow.rb,
lib/fog/workflow/openstack/v2/requests/validate_action.rb,
lib/fog/workflow/openstack/v2/requests/list_executions.rb,
lib/fog/workflow/openstack/v2/requests/update_workbook.rb,
lib/fog/workflow/openstack/v2/requests/create_workflow.rb,
lib/fog/workflow/openstack/v2/requests/update_workflow.rb,
lib/fog/workflow/openstack/v2/requests/delete_workbook.rb,
lib/fog/workflow/openstack/v2/requests/get_environment.rb,
lib/fog/workflow/openstack/v2/requests/get_cron_trigger.rb,
lib/fog/workflow/openstack/v2/requests/create_execution.rb,
lib/fog/workflow/openstack/v2/requests/delete_execution.rb,
lib/fog/workflow/openstack/v2/requests/update_execution.rb,
lib/fog/workflow/openstack/v2/requests/validate_workbook.rb,
lib/fog/workflow/openstack/v2/requests/validate_workflow.rb,
lib/fog/workflow/openstack/v2/requests/list_environments.rb,
lib/fog/workflow/openstack/v2/requests/update_environment.rb,
lib/fog/workflow/openstack/v2/requests/list_cron_triggers.rb,
lib/fog/workflow/openstack/v2/requests/delete_environment.rb,
lib/fog/workflow/openstack/v2/requests/create_environment.rb,
lib/fog/workflow/openstack/v2/requests/create_cron_trigger.rb,
lib/fog/workflow/openstack/v2/requests/delete_cron_trigger.rb,
lib/fog/workflow/openstack/v2/requests/get_action_execution.rb,
lib/fog/workflow/openstack/v2/requests/list_action_executions.rb,
lib/fog/workflow/openstack/v2/requests/update_action_execution.rb,
lib/fog/workflow/openstack/v2/requests/delete_action_execution.rb,
lib/fog/workflow/openstack/v2/requests/create_action_execution.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_prefix, #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, #initialize_identity, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Mock


83
84
85
86
87
88
# File 'lib/fog/workflow/openstack/v2.rb', line 83

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

  initialize_identity options
end

Class Method Details

.dataObject


69
70
71
72
73
74
75
# File 'lib/fog/workflow/openstack/v2.rb', line 69

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :workflows => {}
    }
  end
end

.resetObject


77
78
79
# File 'lib/fog/workflow/openstack/v2.rb', line 77

def self.reset
  @data = nil
end

Instance Method Details

#create_action(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/create_action.rb', line 18

def create_action(_definition)
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_action_execution(_action, _input = {}, _params = {}) ⇒ Object


21
22
23
24
25
26
# File 'lib/fog/workflow/openstack/v2/requests/create_action_execution.rb', line 21

def create_action_execution(_action, _input = {}, _params = {})
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_cron_trigger(_name, _workflow_identifier, _workflow_input = nil, _workflow_params = nil, _pattern = nil, _first_time = nil, _count = nil) ⇒ Object


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/workflow/openstack/v2/requests/create_cron_trigger.rb', line 39

def create_cron_trigger(_name,
                        _workflow_identifier,
                        _workflow_input = nil,
                        _workflow_params = nil,
                        _pattern = nil,
                        _first_time = nil,
                        _count = nil)
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_environment(_definition) ⇒ Object


21
22
23
24
25
26
# File 'lib/fog/workflow/openstack/v2/requests/create_environment.rb', line 21

def create_environment(_definition)
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_execution(_workflow, _input = {}) ⇒ Object


20
21
22
23
24
25
# File 'lib/fog/workflow/openstack/v2/requests/create_execution.rb', line 20

def create_execution(_workflow, _input = {})
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_workbook(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/create_workbook.rb', line 18

def create_workbook(_definition)
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#create_workflow(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/create_workflow.rb', line 18

def create_workflow(_definition)
  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response
end

#dataObject


90
91
92
# File 'lib/fog/workflow/openstack/v2.rb', line 90

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

#delete_action(_name) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_action.rb', line 16

def delete_action(_name)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_action_execution(_id) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_action_execution.rb', line 16

def delete_action_execution(_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_cron_trigger(_name) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_cron_trigger.rb', line 16

def delete_cron_trigger(_name)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_environment(_name) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_environment.rb', line 16

def delete_environment(_name)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_execution(_id) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_execution.rb', line 16

def delete_execution(_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_workbook(_name) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_workbook.rb', line 16

def delete_workbook(_name)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_workflow(_identifier) ⇒ Object


16
17
18
19
20
# File 'lib/fog/workflow/openstack/v2/requests/delete_workflow.rb', line 16

def delete_workflow(_identifier)
  response = Excon::Response.new
  response.status = 204
  response
end

#get_action(_name) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/fog/workflow/openstack/v2/requests/get_action.rb', line 16

def get_action(_name)
  response = Excon::Response.new
  response.status = 200
  response.body = {"version" => "2.0",
                   "action1" => {"input" => ['test_id']}}
  response
end

#get_action_execution(_execution_id) ⇒ Object


16
17
18
19
20
21
# File 'lib/fog/workflow/openstack/v2/requests/get_action_execution.rb', line 16

def get_action_execution(_execution_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"state" => "running", "id" => "1111"}
  response
end

#get_cron_trigger(_name) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/get_cron_trigger.rb', line 16

def get_cron_trigger(_name)
  response = Excon::Response.new
  response.status = 200
  response.body = {"version"     => "2.0",
                   "name"        => "cron_trigger1",
                   "description" => "d1"}
  response
end

#get_environment(_name) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/get_environment.rb', line 16

def get_environment(_name)
  response = Excon::Response.new
  response.status = 200
  response.body = {"name"      => "environment1",
                   "variables" => {"var1" => "value1",
                                   "var2" => "value2"}}
  response
end

#get_execution(_execution_id) ⇒ Object


16
17
18
19
20
21
# File 'lib/fog/workflow/openstack/v2/requests/get_execution.rb', line 16

def get_execution(_execution_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"state" => "running", "id" => "1111"}
  response
end

#get_task(_id) ⇒ Object


16
17
18
19
20
21
22
# File 'lib/fog/workflow/openstack/v2/requests/get_task.rb', line 16

def get_task(_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"version" => "2.0",
                   "task1"   => {"id" => ['test_id']}}
  response
end

#get_workbook(_name) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/get_workbook.rb', line 16

def get_workbook(_name)
  response = Excon::Response.new
  response.status = 200
  response.body = {"version"     => "2.0",
                   "name"        => "workbook1",
                   "description" => "d1"}
  response
end

#get_workflow(_identifier) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/get_workflow.rb', line 16

def get_workflow(_identifier)
  response = Excon::Response.new
  response.status = 200
  response.body = {"version"     => "2.0",
                   "name"        => "workflow1",
                   "description" => "d1"}
  response
end

#list_action_executionsObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_action_executions.rb', line 16

def list_action_executions
  response = Excon::Response.new
  response.status = 200
  response.body = {"action_executions" =>
                                          [{"state" => "ERROR", "id" => "1111"},
                                           {"state" => "RUNNING", "id" => "2222"}]}
  response
end

#list_actions(_params = {}) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/fog/workflow/openstack/v2/requests/list_actions.rb', line 18

def list_actions(_params = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {"actions" =>
                                [{"name" => "action1", "description" => "d1"},
                                 {"name" => "action2", "description" => "d2"}]}
  response
end

#list_cron_triggersObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_cron_triggers.rb', line 16

def list_cron_triggers
  response = Excon::Response.new
  response.status = 200
  response.body = {"cron_triggers" =>
                                      [{"name" => "cron_trigger1", "description" => "d1"},
                                       {"name" => "cron_trigger2", "description" => "d2"}]}
  response
end

#list_environmentsObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_environments.rb', line 16

def list_environments
  response = Excon::Response.new
  response.status = 200
  response.body = {"environments" =>
                                     [{"name" => "environment1", "description" => "d1"},
                                      {"name" => "environment2", "description" => "d2"}]}
  response
end

#list_executionsObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_executions.rb', line 16

def list_executions
  response = Excon::Response.new
  response.status = 200
  response.body = {"executions" =>
                                   [{"state" => "ERROR", "id" => "1111"},
                                    {"state" => "RUNNING", "id" => "2222"}]}
  response
end

#list_servicesObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_services.rb', line 16

def list_services
  response = Excon::Response.new
  response.status = 200
  response.body = {"services" =>
                                 [{"name" => "service1", "description" => "d1"},
                                  {"name" => "service2", "description" => "d2"}]}
  response
end

#list_tasks(_workflow_execution_id) ⇒ Object


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_tasks.rb', line 16

def list_tasks(_workflow_execution_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {"tasks" =>
                              [{"name" => "task1", "description" => "d1"},
                               {"name" => "task2", "description" => "d2"}]}
  response
end

#list_workbooksObject


16
17
18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/list_workbooks.rb', line 16

def list_workbooks
  response = Excon::Response.new
  response.status = 200
  response.body = {"workbooks" =>
                                  [{"name" => "workbook1", "description" => "d1"},
                                   {"name" => "workbook2", "description" => "d2"}]}
  response
end

#list_workflows(_params = {}) ⇒ Object


18
19
20
21
22
23
24
25
# File 'lib/fog/workflow/openstack/v2/requests/list_workflows.rb', line 18

def list_workflows(_params = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {"workflows" =>
                                  [{"name" => "workflow1", "description" => "d1"},
                                   {"name" => "workflow2", "description" => "d2"}]}
  response
end

#reset_dataObject


94
95
96
# File 'lib/fog/workflow/openstack/v2.rb', line 94

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

#update_action(_definition) ⇒ Object


23
24
25
26
27
28
# File 'lib/fog/workflow/openstack/v2/requests/rerun_task.rb', line 23

def update_action(_task_ex_id)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#update_action_execution(_id, _name, _value) ⇒ Object


23
24
25
26
27
28
# File 'lib/fog/workflow/openstack/v2/requests/update_action_execution.rb', line 23

def update_action_execution(_id, _name, _value)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#update_environment(_definition) ⇒ Object


21
22
23
24
25
26
# File 'lib/fog/workflow/openstack/v2/requests/update_environment.rb', line 21

def update_environment(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#update_execution(_id, _name, _value) ⇒ Object


23
24
25
26
27
28
# File 'lib/fog/workflow/openstack/v2/requests/update_execution.rb', line 23

def update_execution(_id, _name, _value)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#update_workbook(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/update_workbook.rb', line 18

def update_workbook(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#update_workflow(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/update_workflow.rb', line 18

def update_workflow(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = ""
  response
end

#validate_action(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/validate_action.rb', line 18

def validate_action(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = "{\"valid\": true}"
  response
end

#validate_workbook(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/validate_workbook.rb', line 18

def validate_workbook(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = "{\"valid\": true}"
  response
end

#validate_workflow(_definition) ⇒ Object


18
19
20
21
22
23
# File 'lib/fog/workflow/openstack/v2/requests/validate_workflow.rb', line 18

def validate_workflow(_definition)
  response = Excon::Response.new
  response.status = 200
  response.body = "{\"valid\": true}"
  response
end