vcoworkflows 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f0db2d5004d39e1e915ed6951c54a2dad6301f06
4
- data.tar.gz: 93b6739926461ec0504308166cdf227bf0fbcc12
3
+ metadata.gz: d50183ce8d642ade7378ff0c0993cf53daded6c4
4
+ data.tar.gz: 31b515782d348804ff9f74c8e9dacdda314a2cf6
5
5
  SHA512:
6
- metadata.gz: d2782bfa11dc901f086ed0e80c5dc3b00fb10551d7bf6e0a16e01ea778549eb57c9faddfed25b6208d3566bb2e550f8fbc9a47b6c6c32d1ba478ea14f24f27be
7
- data.tar.gz: 671989455477f0555aca1c0b5d677994b2f11a5bbb6c44307916806719668c849af13d90db548b30ddecc3b2c3c0b9ca9814c1ffdf178f130e5d0199b1c38e5f
6
+ metadata.gz: 2800e407f0acfe52d4e275a57f420739fdc0cdd73aa6e8dd2e48a30a840588f941d279a14c12095c5e78049d4b1b96d25723f9e1b950e55be6b2594eaa99dfa0
7
+ data.tar.gz: ff1a54bfcb3afe64467031a57b0c2860e28e6c18655872b76abc73f66b904429b43a34b648286dfccb0a6221b44b89fa664046aff94cf3e7b91aaf8bb33841f1
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Vcoworkflows
2
2
 
3
3
  [![Build Status](https://travis-ci.org/ActiveSCM/vcoworkflows.svg?branch=master)][travis]
4
- [![Dependency Status](https://gemnasium.com/ActiveSCM/vcoworkflows.svg)](https://gemnasium.com/ActiveSCM/vcoworkflows)
5
- [![Coverage Status](https://coveralls.io/repos/ActiveSCM/vcoworkflows/badge.svg)](https://coveralls.io/r/ActiveSCM/vcoworkflows)
4
+ [![Dependency Status](https://gemnasium.com/ActiveSCM/vcoworkflows.svg)][gemnasium]
5
+ [![Coverage Status](https://coveralls.io/repos/ActiveSCM/vcoworkflows/badge.png?branch=master)][coveralls]
6
6
  [![Inline docs](http://inch-ci.org/github/ActiveSCM/vcoworkflows.png?branch=master)][inch]
7
7
 
8
8
  [travis]: http://travis-ci.org/ActiveSCM/vcoworkflows
@@ -13,7 +13,7 @@
13
13
  `vcoworkflows` provides a Ruby API for finding and executing vCenter
14
14
  Orchestrator workflows. You can search for a workflow either by name or
15
15
  by GUID, populate the resulting `VcoWorkflows::Workflow` object's
16
- `inputParameters` with the required values, and then request that the
16
+ input parameters with the required values, and then request that the
17
17
  the configured workflow be executed by vCenter Orchestrator.
18
18
 
19
19
  Under the hood, communcations with vCenter Orchestrator is done via its
@@ -55,12 +55,11 @@ Quick example:
55
55
 
56
56
  ```ruby
57
57
  require 'vcoworkflows'
58
- my_workflow = VcoWorkflows::Workflow.new(
59
- 'Request Component,
58
+ workflow = VcoWorkflows::Workflow.new(
59
+ 'Request Component',
60
60
  url: 'https://vco.example.com:8281/vco/api',
61
61
  username: 'jdoe',
62
- password: 's3cr3t',
63
-
62
+ password: 's3cr3t'
64
63
  )
65
64
 
66
65
  ```
@@ -73,7 +72,7 @@ class.
73
72
 
74
73
  It is possible to select a Workflow by GUID (as divined by the vCenter
75
74
  Orchestrator client) or by specifying the Workflow's name. If specifying by
76
- name, however, an exeption will be raised if either no workflows are found,
75
+ name, however, an exception will be raised if either no workflows are found,
77
76
  or multiple workflows are found. Therefor, GUID is likely "safer". In either
78
77
  case, however, the workflow name must be given, as in the example above.
79
78
 
@@ -81,13 +80,12 @@ Selecting a workflow by GUID is done by adding the `id:` parameter when
81
80
  creating a new `Workflow` object:
82
81
 
83
82
  ```ruby
84
- my_workflow = VcoWorkflows::Workflow.new(
85
- 'Request Component,
83
+ workflow = VcoWorkflows::Workflow.new(
84
+ 'Request Component',
86
85
  id: '6e04a460-4a45-4e16-9603-db2922c24462',
87
86
  url: 'https://vco.example.com:8281/vco/api',
88
87
  username: 'jdoe',
89
- password: 's3cr3t',
90
- verify_ssl: false
88
+ password: 's3cr3t'
91
89
  )
92
90
  ```
93
91
 
@@ -287,4 +285,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
287
285
  See the License for the specific language governing permissions and
288
286
  limitations under the License.
289
287
  ```
290
-
@@ -4,14 +4,28 @@ require 'vcoworkflows/constants'
4
4
  module VcoWorkflows
5
5
  # Cli
6
6
  module Cli
7
- # Auth
7
+ # Auth is a very small helper class to allow pulling authentication
8
+ # credentials from the environment when using one of the executable
9
+ # commands.
10
+ #
11
+ # If credentials aren't passed in as options to the command, we'll
12
+ # also check the environment for $VCO_USER and $VCO_PASSWD and use
13
+ # those. Otherwise, command line options will override environment
14
+ # values.
8
15
  class Auth
16
+ # username
17
+ # @return [String]
9
18
  attr_reader :username
19
+
20
+ # password
21
+ # @return [String]
10
22
  attr_reader :password
11
23
 
12
- # Initialize the Auth object
13
- # @param [String] username
14
- # @param [String] password
24
+ # Initialize the Auth object. If the paramaters are nil, look
25
+ # for values in the environment instead.
26
+ # @param [String] username vCenter Orchestrator user name
27
+ # @param [String] password vCenter Orchestrator password
28
+ # @return [VcoWorkflows::Cli::Auth]
15
29
  def initialize(username: nil, password: nil)
16
30
  # Set username and password from parameters, if provided, or
17
31
  # environment variables $VCO_USER and $VCO_PASSWD, if not.
@@ -8,7 +8,7 @@ require 'thor/group'
8
8
  module VcoWorkflows
9
9
  # Cli
10
10
  module Cli
11
- # Execute
11
+ # Execute a workflow with the given options.
12
12
  class Execute < Thor::Group
13
13
  include Thor::Actions
14
14
 
@@ -24,6 +24,7 @@ module VcoWorkflows
24
24
 
25
25
  class_option :parameters, type: :string, required: true, desc: DESC_CLI_EXECUTE_PARAMETERS
26
26
 
27
+ # Thor
27
28
  def self.source_root
28
29
  File.dirname(__FILE__)
29
30
  end
@@ -27,6 +27,7 @@ module VcoWorkflows
27
27
  class_option :logs, type: :boolean, aliases: ['-L', '--log'], desc: DESC_CLI_QUERY_EXEC_LOG
28
28
  class_option :show_json, type: :boolean, default: false, desc: DESC_CLI_QUERY_JSON
29
29
 
30
+ # Thor
30
31
  def self.source_root
31
32
  File.dirname(__FILE__)
32
33
  end
@@ -3,25 +3,65 @@ module VcoWorkflows
3
3
  # rubocop:disable LineLength
4
4
 
5
5
  # Options description messages
6
+
7
+ # Version
6
8
  DESC_VERSION = 'Display the installed version of the VcoWorkflows gem'
9
+
10
+ # Execute
7
11
  DESC_CLI_EXECUTE = 'Execute the specified workflow'
12
+
13
+ # Query
8
14
  DESC_CLI_QUERY = 'Query vCO for a workflow'
15
+
16
+ # Workflow
9
17
  DESC_CLI_WORKFLOW = 'Name of the workflow'
18
+
19
+ # ID
10
20
  DESC_CLI_WORKFLOW_ID = 'GUID of the workflow'
21
+
22
+ # dry-run
11
23
  DESC_CLI_DRY_RUN = 'Dry run; do not actually perform operations against vCO'
24
+
25
+ # verbose
12
26
  DESC_CLI_VERBOSE = 'Show extra information'
27
+
28
+ # name
13
29
  DESC_CLI_NAME = 'Name of the workflow to execute'
30
+
31
+ # server
14
32
  DESC_CLI_SERVER = 'VMware vCenter Orchestrator server URL'
33
+
34
+ # username
15
35
  DESC_CLI_USERNAME = 'vCO user name'
36
+
37
+ # password
16
38
  DESC_CLI_PASSWORD = 'vCO password'
39
+
40
+ # verify certificates
17
41
  DESC_CLI_VERIFY_SSL = 'Perform TSL Certificate verification'
42
+
43
+ # watch execution
18
44
  DESC_CLI_EXECUTE_WATCH = 'Wait around for workflow results'
45
+
46
+ # execution parameter list
19
47
  DESC_CLI_EXECUTE_PARAMETERS = 'Comma-separated list of key=value parameters for workflow'
48
+
49
+ # query exeuction list
20
50
  DESC_CLI_QUERY_EXECS = 'Fetch a list of executions for the workflow'
51
+
52
+ # limit queried execution list size
21
53
  DESC_CLI_QUERY_EXEC_LIM = 'Limit the number of returned executions to the most recent N'
54
+
55
+ # exeuction id
22
56
  DESC_CLI_QUERY_EXEC_ID = 'Fetch the execution data for this execution GUID'
57
+
58
+ # execution state
23
59
  DESC_CLI_QUERY_EXEC_STATE = 'Fetch the state of the specified workflow execution'
60
+
61
+ # execution log
24
62
  DESC_CLI_QUERY_EXEC_LOG = 'In addition to execution data, show the execution log'
63
+
64
+ # show JSON
25
65
  DESC_CLI_QUERY_JSON = 'Show the JSON document for the requested information'
26
66
 
27
67
  # What do all the vCO REST URIs start with?
@@ -3,7 +3,8 @@ require 'rest_client'
3
3
 
4
4
  # VcoWorkflows
5
5
  module VcoWorkflows
6
- # VcoSession
6
+ # VcoSession is a simple wrapper for RestClient::Resource, and supports
7
+ # GET and POST operations against the vCO API.
7
8
  class VcoSession
8
9
  # Accessor for rest-client object, primarily for testing purposes
9
10
  attr_reader :rest_resource
@@ -1,4 +1,5 @@
1
1
  # VcoWorkflows
2
2
  module VcoWorkflows
3
- VERSION = '0.1.1'
3
+ # Gem Version
4
+ VERSION = '0.1.2'
4
5
  end
@@ -11,17 +11,46 @@ module VcoWorkflows
11
11
 
12
12
  # Class to represent a Workflow as presented by vCenter Orchestrator.
13
13
  class Workflow
14
+ # rubocop:disable LineLength
15
+
16
+ # Workflow GUID
17
+ # @return [String] workflow GUID
14
18
  attr_reader :id
19
+
20
+ # Workflow name
21
+ # @return [String] workflow name
15
22
  attr_reader :name
23
+
24
+ # Workflow version
25
+ # @return [String] workflow version
16
26
  attr_reader :version
27
+
28
+ # Workflow description
29
+ # @return [String] workflow description
17
30
  attr_reader :description
31
+
32
+ # Workflow Input Parameters
33
+ # @return [VcoWorkflows::WorkflowParameter{}] Hash of WorkflowParameter objects, keyed by name
18
34
  attr_reader :input_parameters
35
+
36
+ # Workflow Output Parameters
37
+ # @return [VcoWorkflows::WorkflowParameter{}] Hash of WorkflowParameter objects, keyed by name
19
38
  attr_reader :output_parameters
39
+
40
+ # Workflow Service
41
+ # @return [VcoWorkflows::WorkflowService] The WorkflowService currently being used to interface with vCO
20
42
  attr_accessor :service
43
+
44
+ # Workflow execution ID
45
+ # @return [String] workflow execution ID
21
46
  attr_reader :execution_id
22
47
 
48
+ # Workflow source JSON
49
+ # @return [String] the source JSON returned by vCO for this workflow
23
50
  attr_reader :source_json
24
51
 
52
+ # rubocop:enable LineLength
53
+
25
54
  # rubocop:disable CyclomaticComplexity, PerceivedComplexity, MethodLength, LineLength
26
55
 
27
56
  # Create a Workflow object given vCenter Orchestrator's JSON description
@@ -100,18 +129,26 @@ module VcoWorkflows
100
129
  end
101
130
  # rubocop:enable CyclomaticComplexity, PerceivedComplexity, MethodLength, LineLength
102
131
 
132
+ # vCO API URL used when creating this workflow
133
+ # @return [String]
103
134
  def url
104
135
  options[:url]
105
136
  end
106
137
 
138
+ # vCO user name used when creating this workflow object
139
+ # @return [String]
107
140
  def username
108
141
  options[:username]
109
142
  end
110
143
 
144
+ # vCO password used when creating this workflow object
145
+ # @return [String]
111
146
  def password
112
147
  options[:password]
113
148
  end
114
149
 
150
+ # Verify SSL?
151
+ # @return [Boolean]
115
152
  def verify_ssl?
116
153
  options[:verify_ssl]
117
154
  end
@@ -6,6 +6,8 @@ module VcoWorkflows
6
6
  # WorkflowExecutionLog is a simple object to contain the log for an
7
7
  # execution of a workflow.
8
8
  class WorkflowExecutionLog
9
+ # Log messages
10
+ # @return [String[]] Array of log message lines
9
11
  attr_reader :messages
10
12
 
11
13
  # Create an execution log object
@@ -5,9 +5,20 @@ module VcoWorkflows
5
5
  # WorkflowParameter is an object wrapper for workflow input and output
6
6
  # parameters.
7
7
  class WorkflowParameter
8
+ # Parameter name
9
+ # @return [String] parameter name
8
10
  attr_reader :name
11
+
12
+ # Parameter type
13
+ # @return [String] parameter type
9
14
  attr_reader :type
15
+
16
+ # Parameter subtype (used when type is 'Array')
17
+ # @return [String] parameter subtype
10
18
  attr_reader :subtype
19
+
20
+ # Parameter value
21
+ # @return [Object] parameter value
11
22
  attr_reader :value
12
23
 
13
24
  # rubocop:disable MethodLength
@@ -14,7 +14,12 @@ module VcoWorkflows
14
14
  # WorkflowPresentation examines the presentation JSON from vCO to determine
15
15
  # whether input parameters for the workflow are required or not.
16
16
  class WorkflowPresentation
17
+ # Accessor for the data structure
18
+ # @return [Hash] parsed JSON
17
19
  attr_reader :presentation_data
20
+
21
+ # Get the list of required parameters for the workflow
22
+ # @return [String[]] Array of strings (names of parameters)
18
23
  attr_reader :required
19
24
 
20
25
  # rubocop:disable LineLength, MethodLength
@@ -11,7 +11,8 @@ module VcoWorkflows
11
11
  # WorkflowService is the object which acts as the interface to the vCO
12
12
  # API, and is loosely modeled from the vCO API documentation.
13
13
  class WorkflowService
14
- # Return the VcoSession
14
+ # The VcoSession used by this service
15
+ # @return [VcoWorkflows::VcoSession]
15
16
  attr_reader :session
16
17
 
17
18
  # rubocop:disable LineLength
@@ -26,7 +27,7 @@ module VcoWorkflows
26
27
 
27
28
  # Get a workflow by GUID
28
29
  # @param [String] id Workflow GUID
29
- # @return [VcoWorkflows::Workflow] the requested workflow
30
+ # @return [String] the JSON document of the requested workflow
30
31
  def get_workflow_for_id(id)
31
32
  @session.get("/workflows/#{id}").body
32
33
  end
@@ -40,7 +41,7 @@ module VcoWorkflows
40
41
 
41
42
  # Get one workflow with a specified name.
42
43
  # @param [String] name Name of the workflow
43
- # @return [VcoWorkflows::Workflow] the requested workflow
44
+ # @return [String] the JSON document of the requested workflow
44
45
  def get_workflow_for_name(name)
45
46
  path = "/workflows?conditions=name=#{url_encode(name)}"
46
47
  response = JSON.parse(@session.get(path).body)
@@ -70,7 +71,7 @@ module VcoWorkflows
70
71
 
71
72
  # Get a list of executions for the given workflow GUID
72
73
  # @param [String] workflow_id Workflow GUID
73
- # @return [Hash]
74
+ # @return [Hash] workflow executions, keyed by execution ID
74
75
  def get_execution_list(workflow_id)
75
76
  path = "/workflows/#{workflow_id}/executions/"
76
77
  relations = JSON.parse(@session.get(path).body)['relations']
@@ -7,22 +7,66 @@ module VcoWorkflows
7
7
  # WorkflowToken is used for workflow execution results, and contains as much
8
8
  # data on the given workflow execution instance as vCO can provide.
9
9
  class WorkflowToken
10
+ # rubocop:disable LineLength
11
+
12
+ # Workflow execution ID
13
+ # @return [String] the execution id for this token
10
14
  attr_reader :id
15
+
16
+ # Workflow ID
17
+ # @return [String] the GUID for this workflow
11
18
  attr_reader :workflow_id
19
+
20
+ # Workflow name
21
+ # @return [String] name of the workflow
12
22
  attr_reader :name
23
+
24
+ # Execution state
25
+ # @return [String] current state of the workflow execution
13
26
  attr_reader :state
27
+
28
+ # Execution href
29
+ # @return [String] link to this execution via the REST API
14
30
  attr_reader :href
31
+
32
+ # Execution start date
33
+ # @return [String] date and time the workflow execution started
15
34
  attr_reader :start_date
35
+
36
+ # Execution end date
37
+ # @return [String] date and time the workflow execution ended
16
38
  attr_reader :end_date
39
+
40
+ # Execution started by
41
+ # @return [String] vCO user who started this execution
17
42
  attr_reader :started_by
43
+
44
+ # @return [String]
18
45
  attr_reader :current_item_name
46
+
47
+ # @return [String]
19
48
  attr_reader :current_item_state
49
+
50
+ # @return [String]
20
51
  attr_reader :content_exception
52
+
53
+ # @return [String]
21
54
  attr_reader :global_state
55
+
56
+ # Workflow execution input parameters
57
+ # @return [VcoWorkflows::WorkflowParameter{}] Hash of input parameters which were given when the workflow was executed
22
58
  attr_reader :input_parameters
59
+
60
+ # Workflow execution output parameters
61
+ # @return [VcoWorkflows::WorkflowParameter{}] Hash of output parameters set by the workflow execution
23
62
  attr_reader :output_parameters
63
+
64
+ # Source JSON
65
+ # @return [String] source JSON document returned by vCO for this execution
24
66
  attr_reader :json_content
25
67
 
68
+ # rubocop:enable LineLength
69
+
26
70
  # rubocop:disable CyclomaticComplexity, PerceivedComplexity, MethodLength, LineLength
27
71
 
28
72
  # Create a new workflow token
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  $LOAD_PATH << '../../lib'
2
2
 
3
- # require 'coveralls'
4
- # Coveralls.wear!
3
+ require 'coveralls'
4
+ Coveralls.wear!
data/vcoworkflows.gemspec CHANGED
@@ -7,8 +7,8 @@ require 'vcoworkflows/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'vcoworkflows'
9
9
  spec.version = VcoWorkflows::VERSION
10
- spec.authors = %w('Gregory Ruiz-ade')
11
- spec.email = %w('gregory.ruiz-ade@activenetwork.com')
10
+ spec.authors = 'Gregory Ruiz-ade'
11
+ spec.email = 'gregory.ruiz-ade@activenetwork.com'
12
12
  spec.summary = 'vCO Workflows REST API Wrapper'
13
13
  spec.description = 'Ruby implementation of vCenter Orchestrator REST API'
14
14
  spec.homepage = ''
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcoworkflows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
- - "'Gregory"
8
- - Ruiz-ade'
7
+ - Gregory Ruiz-ade
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-02 00:00:00.000000000 Z
11
+ date: 2015-02-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
@@ -180,8 +179,7 @@ dependencies:
180
179
  - !ruby/object:Gem::Version
181
180
  version: '0'
182
181
  description: Ruby implementation of vCenter Orchestrator REST API
183
- email:
184
- - "'gregory.ruiz-ade@activenetwork.com'"
182
+ email: gregory.ruiz-ade@activenetwork.com
185
183
  executables:
186
184
  - vcoworkflows
187
185
  extensions: []