Class: Fog::Workflow::OpenStack::V2::Real
- Inherits:
-
Object
- Object
- Fog::Workflow::OpenStack::V2::Real
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/list_tasks.rb,
lib/fog/workflow/openstack/v2/requests/rerun_task.rb,
lib/fog/workflow/openstack/v2/requests/get_workbook.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/create_action.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/list_services.rb,
lib/fog/workflow/openstack/v2/requests/update_action.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/create_workflow.rb,
lib/fog/workflow/openstack/v2/requests/delete_workbook.rb,
lib/fog/workflow/openstack/v2/requests/delete_workflow.rb,
lib/fog/workflow/openstack/v2/requests/get_environment.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/update_workflow.rb,
lib/fog/workflow/openstack/v2/requests/validate_action.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/get_cron_trigger.rb,
lib/fog/workflow/openstack/v2/requests/update_execution.rb,
lib/fog/workflow/openstack/v2/requests/list_environments.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/create_environment.rb,
lib/fog/workflow/openstack/v2/requests/delete_environment.rb,
lib/fog/workflow/openstack/v2/requests/list_cron_triggers.rb,
lib/fog/workflow/openstack/v2/requests/update_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/create_action_execution.rb,
lib/fog/workflow/openstack/v2/requests/delete_action_execution.rb,
lib/fog/workflow/openstack/v2/requests/update_action_execution.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, #unscoped_token
Instance Method Summary
collapse
-
#create_action(definition) ⇒ Object
-
#create_action_execution(action, input = {}, params = {}) ⇒ Object
-
#create_cron_trigger(name, workflow_identifier, workflow_input = nil, workflow_params = nil, pattern = "* * * * *", first_time = nil, count = nil) ⇒ Object
-
#create_environment(definition) ⇒ Object
-
#create_execution(workflow, input = {}) ⇒ Object
-
#create_workbook(definition) ⇒ Object
-
#create_workflow(definition) ⇒ Object
-
#delete_action(name) ⇒ Object
-
#delete_action_execution(id) ⇒ Object
-
#delete_cron_trigger(name) ⇒ Object
-
#delete_environment(name) ⇒ Object
-
#delete_execution(id) ⇒ Object
-
#delete_workbook(name) ⇒ Object
-
#delete_workflow(identifier) ⇒ Object
-
#get_action(name) ⇒ Object
-
#get_action_execution(execution_id) ⇒ Object
-
#get_cron_trigger(name) ⇒ Object
-
#get_environment(name) ⇒ Object
-
#get_execution(execution_id) ⇒ Object
-
#get_task(id) ⇒ Object
-
#get_workbook(name) ⇒ Object
-
#get_workflow(identifier) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
-
#list_action_executions ⇒ Object
-
#list_actions(params = {}) ⇒ Object
-
#list_cron_triggers ⇒ Object
-
#list_environments ⇒ Object
-
#list_executions ⇒ Object
-
#list_services ⇒ Object
-
#list_tasks(workflow_execution_id) ⇒ Object
-
#list_workbooks ⇒ Object
-
#list_workflows(params = {}) ⇒ Object
-
#request(params) ⇒ Object
-
#rerun_task(task_ex_id) ⇒ Object
-
#update_action(definition) ⇒ Object
-
#update_action_execution(id, name, value) ⇒ Object
-
#update_environment(definition) ⇒ Object
-
#update_execution(id, name, value) ⇒ Object
-
#update_workbook(definition) ⇒ Object
-
#update_workflow(definition) ⇒ Object
-
#validate_action(definition) ⇒ Object
-
#validate_workbook(definition) ⇒ Object
-
#validate_workflow(definition) ⇒ Object
#credentials, #initialize_identity, not_found_class, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/fog/workflow/openstack/v2.rb', line 102
def initialize(options = {})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['workflowv2']
@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
#create_action(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/create_action.rb', line 6
def create_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "actions"
)
end
|
#create_action_execution(action, input = {}, params = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/fog/workflow/openstack/v2/requests/create_action_execution.rb', line 6
def create_action_execution(action, input = {}, params = {})
data = {:name => action}
data[:input] = Fog::JSON.encode(input) unless input.empty?
data[:params] = Fog::JSON.encode(params) unless params.empty?
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "action_executions"
)
end
|
#create_cron_trigger(name, workflow_identifier, workflow_input = nil, workflow_params = nil, pattern = "* * * * *", first_time = nil, count = nil) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/fog/workflow/openstack/v2/requests/create_cron_trigger.rb', line 6
def create_cron_trigger(name,
workflow_identifier,
workflow_input = nil,
workflow_params = nil,
pattern = "* * * * *",
first_time = nil,
count = nil)
data = {
:name => name,
:pattern => pattern,
:first_execution_time => first_time,
:remaining_executions => count
}
if workflow_identifier
data[:workflow_id] = workflow_identifier
end
if workflow_input
data[:workflow_input] = Fog::JSON.encode(workflow_input)
end
if workflow_params
data[:workflow_params] = Fog::JSON.encode(workflow_params)
end
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "cron_triggers"
)
end
|
#create_environment(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/fog/workflow/openstack/v2/requests/create_environment.rb', line 6
def create_environment(definition)
unless definition["variables"].nil?
definition["variables"] = Fog::JSON.encode(definition["variables"])
end
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "environments"
)
end
|
#create_execution(workflow, input = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/fog/workflow/openstack/v2/requests/create_execution.rb', line 6
def create_execution(workflow, input = {})
data = {:workflow_name => workflow}
data[:input] = Fog::JSON.encode(input) unless input.empty?
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "executions"
)
end
|
#create_workbook(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/create_workbook.rb', line 6
def create_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "workbooks"
)
end
|
#create_workflow(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/create_workflow.rb', line 6
def create_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 201,
:method => "POST",
:path => "workflows"
)
end
|
#delete_action(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_action.rb', line 6
def delete_action(name)
request(
:expects => 204,
:method => "DELETE",
:path => "actions/#{URI.encode(name)}"
)
end
|
#delete_action_execution(id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_action_execution.rb', line 6
def delete_action_execution(id)
request(
:expects => 204,
:method => "DELETE",
:path => "action_executions/#{id}"
)
end
|
#delete_cron_trigger(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_cron_trigger.rb', line 6
def delete_cron_trigger(name)
request(
:expects => 204,
:method => "DELETE",
:path => "cron_triggers/#{URI.encode(name)}"
)
end
|
#delete_environment(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_environment.rb', line 6
def delete_environment(name)
request(
:expects => 204,
:method => "DELETE",
:path => "environments/#{URI.encode(name)}"
)
end
|
#delete_execution(id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_execution.rb', line 6
def delete_execution(id)
request(
:expects => 204,
:method => "DELETE",
:path => "executions/#{id}"
)
end
|
#delete_workbook(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_workbook.rb', line 6
def delete_workbook(name)
request(
:expects => 204,
:method => "DELETE",
:path => "workbooks/#{URI.encode(name)}"
)
end
|
#delete_workflow(identifier) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/delete_workflow.rb', line 6
def delete_workflow(identifier)
request(
:expects => 204,
:method => "DELETE",
:path => "workflows/#{identifier}"
)
end
|
#get_action(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_action.rb', line 6
def get_action(name)
request(
:expects => 200,
:method => "GET",
:path => "actions/#{URI.encode(name)}"
)
end
|
#get_action_execution(execution_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_action_execution.rb', line 6
def get_action_execution(execution_id)
request(
:expects => 200,
:method => "GET",
:path => "action_executions/#{execution_id}"
)
end
|
#get_cron_trigger(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_cron_trigger.rb', line 6
def get_cron_trigger(name)
request(
:expects => 200,
:method => "GET",
:path => "cron_triggers/#{URI.encode(name)}"
)
end
|
#get_environment(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_environment.rb', line 6
def get_environment(name)
request(
:expects => 200,
:method => "GET",
:path => "environments/#{URI.encode(name)}"
)
end
|
#get_execution(execution_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_execution.rb', line 6
def get_execution(execution_id)
request(
:expects => 200,
:method => "GET",
:path => "executions/#{execution_id}"
)
end
|
#get_task(id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_task.rb', line 6
def get_task(id)
request(
:expects => 200,
:method => "GET",
:path => "tasks/#{id}"
)
end
|
#get_workbook(name) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_workbook.rb', line 6
def get_workbook(name)
request(
:expects => 200,
:method => "GET",
:path => "workbooks/#{URI.encode(name)}"
)
end
|
#get_workflow(identifier) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/get_workflow.rb', line 6
def get_workflow(identifier)
request(
:expects => 200,
:method => "GET",
:path => "workflows/#{identifier}"
)
end
|
#list_action_executions ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_action_executions.rb', line 6
def list_action_executions
request(
:expects => 200,
:method => "GET",
:path => "action_executions"
)
end
|
#list_actions(params = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/list_actions.rb', line 6
def list_actions(params = {})
body = Fog::JSON.encode(params)
request(
:body => body,
:expects => 200,
:method => "GET",
:path => "actions"
)
end
|
#list_cron_triggers ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_cron_triggers.rb', line 6
def list_cron_triggers
request(
:expects => 200,
:method => "GET",
:path => "cron_triggers"
)
end
|
#list_environments ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_environments.rb', line 6
def list_environments
request(
:expects => 200,
:method => "GET",
:path => "environments"
)
end
|
#list_executions ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_executions.rb', line 6
def list_executions
request(
:expects => 200,
:method => "GET",
:path => "executions"
)
end
|
#list_services ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_services.rb', line 6
def list_services
request(
:expects => 200,
:method => "GET",
:path => "services"
)
end
|
#list_tasks(workflow_execution_id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_tasks.rb', line 6
def list_tasks(workflow_execution_id)
request(
:expects => 200,
:method => "GET",
:path => "executions/#{workflow_execution_id}/tasks"
)
end
|
#list_workbooks ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/workflow/openstack/v2/requests/list_workbooks.rb', line 6
def list_workbooks
request(
:expects => 200,
:method => "GET",
:path => "workbooks"
)
end
|
#list_workflows(params = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/list_workflows.rb', line 6
def list_workflows(params = {})
body = Fog::JSON.encode(params)
request(
:body => body,
:expects => 200,
:method => "GET",
:path => "workflows"
)
end
|
#request(params) ⇒ Object
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/fog/workflow/openstack/v2.rb', line 125
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::Workflow::OpenStack::NotFound.slurp(error)
else
error
end
else
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
end
response
end
|
#rerun_task(task_ex_id) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/fog/workflow/openstack/v2/requests/rerun_task.rb', line 6
def rerun_task(task_ex_id)
rerun_payload = {
:id => task_ex_id,
:state => 'RUNNING',
:reset => true
}
body = Fog::JSON.encode(rerun_payload)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "tasks/#{task_ex_id}"
)
end
|
#update_action(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/update_action.rb', line 6
def update_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "actions"
)
end
|
#update_action_execution(id, name, value) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/fog/workflow/openstack/v2/requests/update_action_execution.rb', line 6
def update_action_execution(id, name, value)
data = {:id => id}
data[name] = Fog::JSON.encode(value)
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "action_executions"
)
end
|
#update_environment(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/fog/workflow/openstack/v2/requests/update_environment.rb', line 6
def update_environment(definition)
unless definition["variables"].nil?
definition["variables"] = Fog::JSON.encode(definition["variables"])
end
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "environments"
)
end
|
#update_execution(id, name, value) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/fog/workflow/openstack/v2/requests/update_execution.rb', line 6
def update_execution(id, name, value)
data = {:id => id}
data[name] = Fog::JSON.encode(value)
body = Fog::JSON.encode(data)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "executions"
)
end
|
#update_workbook(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/update_workbook.rb', line 6
def update_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "workbooks"
)
end
|
#update_workflow(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/update_workflow.rb', line 6
def update_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "PUT",
:path => "workflows"
)
end
|
#validate_action(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/validate_action.rb', line 6
def validate_action(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "actions/validate"
)
end
|
#validate_workbook(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/validate_workbook.rb', line 6
def validate_workbook(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "workbooks/validate"
)
end
|
#validate_workflow(definition) ⇒ Object
6
7
8
9
10
11
12
13
14
|
# File 'lib/fog/workflow/openstack/v2/requests/validate_workflow.rb', line 6
def validate_workflow(definition)
body = Fog::JSON.encode(definition)
request(
:body => body,
:expects => 200,
:method => "POST",
:path => "workflows/validate"
)
end
|