brpm_module_servicenow 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGMyYjczYTA0NTMzNDU5NjQ5YTc5YWQ1ODRmY2Q2Mzg4MDg1NzE0Zg==
4
+ MzY1YTBiMDVhMzNlNzBmOGExMjJjNDEyMDdjM2Y4Zjc4MGM1OGMzMA==
5
5
  data.tar.gz: !binary |-
6
- NzA2ZjJhYzlkNzJlMzI2ZmU5NTgwZDgwMDA4MGU5NDA5MTNjMzNkOQ==
6
+ YjNhMjY4NjE1NmY0ZjlmNTBmY2RkMzU5YjJiODgxZDEwYTI5ZWQ0OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWZlNGMyNGY1ZmUyYjcyZjkxNDQ0NzZlODE2YTZmNTk0YTA3MmI5N2MyYWJl
10
- Y2VmNGMyMmRhZTM4MjkxZTM0YWUzNWU4MDhiYzlmODE0YTY0YmEyMTI3MzIx
11
- YTI2YzIxMDdkODk2OGY3MzJlNjIzZmI3NmZhOGNmNzcxY2UwMTQ=
9
+ YmFlMTA5MmM2ZWExZmFmMjdiZWVkODUzZmU0NDJmMmJmOGYxM2VlMGZlZjcy
10
+ MjQ2NDcxZTZhOTUxNzJhYmY4MmVmZWQzOTNlMThjMTQzMjBhOWVkYjIxNjg3
11
+ YTY0OGY2MDRkN2NkMWQwYzFjNmZiYjIwZDE2ODEzZjEyMzVlZGY=
12
12
  data.tar.gz: !binary |-
13
- NzkwMmI2ZGE1MTFjZDgyMTQ2ZGE3MTliMWIzM2YwYmMwM2I3NGY0OTNhM2Q4
14
- M2UxY2I3ZTBjMGQ3OWEzMTc4OGM0ZmI2NTc3OTBmYTA3MWJjZjhjZWI1OTRi
15
- MGI1NjFhYjlhNzIxOTU3NmM3Nzk5MTZiODYzOTQ2ZjQxYjA5Mjk=
13
+ NmM2NDQxMDhmZDIwZTQ3MDZiOWE5MjdjYzAyMmIwOWVhNTkwOTFmMTQwZDJl
14
+ YWQxNmRiNzIxODA4MmYxNmNiNTFhODQwZDg4MmNiYmJkYTZmNzYyNGNmYmEz
15
+ Y2RmOGQ5ODY1MzRlMTEwYjhhNjNmOWI2M2IxMjNiNjU2ZTdkOGY=
@@ -0,0 +1,12 @@
1
+ params:
2
+ change_request_id:
3
+ name: Change request id (optional, if not specified the change request id of the request param will be used)
4
+ position: A1:C1
5
+ change_request_url:
6
+ name: Change request url
7
+ type: out-url
8
+ position: A1:E1
9
+
10
+
11
+ integration_server_type: ServiceNow
12
+
@@ -0,0 +1,35 @@
1
+ change_request_id = BrpmAuto.all_params["change_request_id"]
2
+
3
+ raise "No change request id was specified." if change_request_id.nil? or change_request_id.empty?
4
+
5
+ snow_rest_client = SnowRestClient.new
6
+
7
+ max_time = 15*60 # seconds
8
+ checking_interval = 15 #seconds
9
+
10
+ start_time = Time.now
11
+ elapsed = 0
12
+
13
+ BrpmAuto.log "Starting the monitoring loop for change request #{change_request_id} with an interval of #{checking_interval} seconds and a maximum time of #{max_time} seconds ..."
14
+ until elapsed > max_time
15
+ change_request = snow_rest_client.get_record("change_request", change_request_id)
16
+
17
+ if change_request["approval"] == "approved"
18
+ BrpmAuto.log "The change request is approved."
19
+ break
20
+ end
21
+
22
+ if change_request["approval"] == "rejected"
23
+ raise "The change request is rejected."
24
+ end
25
+
26
+ BrpmAuto.log "\tWaiting(#{elapsed.floor.to_s}) - Current status: #{change_request["approval"]}"
27
+ sleep(checking_interval)
28
+ elapsed = Time.now - start_time
29
+ end
30
+
31
+ if elapsed > max_time
32
+ raise "Maximum time: #{max_time}(secs) reached."
33
+ end
34
+
35
+ BrpmAuto.pack_response("change_request_url", "#{BrpmAuto.integration_settings.dns}/nav_to.do?uri=change_request.do?sys_id=#{change_request_id}")
@@ -0,0 +1,15 @@
1
+ params:
2
+ short_description:
3
+ name: Short description
4
+ position: A1:F1
5
+ description:
6
+ name: Description
7
+ position: A2:F2
8
+ change_request_url:
9
+ name: Change request url
10
+ type: out-url
11
+ position: A1:E1
12
+
13
+
14
+ integration_server_type: ServiceNow
15
+
@@ -0,0 +1,16 @@
1
+ snow_rest_client = SnowRestClient.new
2
+
3
+ fields = {}
4
+ fields["short_description"] = BrpmAuto.params["short_description"]
5
+ fields["description"] = BrpmAuto.params["description"]
6
+ fields["u_brpm_url"] = "#{BrpmAuto.params["base_url"]}/requests/#{BrpmAuto.params["request_id"]}"
7
+
8
+ change_request = snow_rest_client.create_record("change_request", fields)
9
+
10
+ fields = {}
11
+ fields["approval"] = "requested"
12
+ snow_rest_client.update_record("change_request", change_request["sys_id"], fields)
13
+
14
+ BrpmAuto.pack_response("change_request_url", "#{BrpmAuto.integration_settings.dns}/nav_to.do?uri=change_request.do?sys_id=#{change_request["sys_id"]}")
15
+
16
+ BrpmAuto.request_params["change_request_id"] = change_request["sys_id"]
@@ -2,9 +2,12 @@ params:
2
2
  change_request_id:
3
3
  name: Change request id (optional, if not specified the change request id of the request param will be used)
4
4
  position: A1:C1
5
- fields:
6
- name: Fields
5
+ comments:
6
+ name: Comments
7
7
  position: A2:F2
8
+ work_notes:
9
+ name: Work notes
10
+ position: A3:F3
8
11
  change_request_url:
9
12
  name: Change request url
10
13
  type: out-url
@@ -2,7 +2,11 @@ change_request_id = BrpmAuto.all_params["change_request_id"]
2
2
 
3
3
  raise "No change request id was specified." if change_request_id.nil? or change_request_id.empty?
4
4
 
5
+ fields = {}
6
+ fields["comments"] = BrpmAuto.params["comments"]
7
+ fields["work_notes"] = BrpmAuto.params["work_notes"]
8
+
5
9
  snow_rest_client = SnowRestClient.new
6
- snow_rest_client.update_record("change_request", change_request_id, BrpmAuto.all_params["fields"])
10
+ snow_rest_client.update_record("change_request", change_request_id, fields)
7
11
 
8
12
  BrpmAuto.pack_response("change_request_url", "#{BrpmAuto.integration_settings.dns}/nav_to.do?uri=change_request.do?sys_id=#{change_request_id}")
data/config.yml CHANGED
@@ -1,4 +1,4 @@
1
- version: 0.0.10
1
+ version: 0.0.11
2
2
 
3
3
  author: Niek Bartholomeus
4
4
  email: niek.bartholomeus@gmail.com
@@ -23,6 +23,30 @@ class SnowRestClient
23
23
  end
24
24
  end
25
25
 
26
+ def get_record(table, id)
27
+ url = "#{@api_url}/#{table}/#{id}"
28
+
29
+ result = Rest.get(url, { :username => @username, :password => @password })
30
+
31
+ unless result["status"] == "success"
32
+ raise "Could not get the record: #{result["error_message"]}"
33
+ end
34
+
35
+ result["response"]["result"]
36
+ end
37
+
38
+ def create_record(table, fields)
39
+ url = "#{@api_url}/#{table}"
40
+
41
+ result = Rest.post(url, fields, { :username => @username, :password => @password })
42
+
43
+ unless result["status"] == "success"
44
+ raise "Could not create the record: #{result["error_message"]}"
45
+ end
46
+
47
+ result["response"]["result"]
48
+ end
49
+
26
50
  def update_record(table, id, fields)
27
51
  url = "#{@api_url}/#{table}/#{id}"
28
52
 
@@ -32,6 +56,6 @@ class SnowRestClient
32
56
  raise "Could not update the record: #{result["error_message"]}"
33
57
  end
34
58
 
35
- result["response"]
59
+ result["response"]["result"]
36
60
  end
37
61
  end
@@ -0,0 +1,20 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe 'await approval of issue' do
4
+ before(:all) do
5
+ setup_brpm_auto
6
+ cleanup_request_params
7
+ end
8
+
9
+ describe '' do
10
+ it 'should await the approval of a change request in ServiceNow' do
11
+ params = get_default_params
12
+ params = params.merge(get_integration_params_for_servicenow)
13
+
14
+ params["change_request_id"] = "6e262e730f8d120072588b9ae1050e62"
15
+
16
+ BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "await_approval_of_change_request", params)
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,24 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe 'create issue' do
4
+ before(:all) do
5
+ setup_brpm_auto
6
+ cleanup_request_params
7
+ end
8
+
9
+ describe '' do
10
+ it 'should create a change request in ServiceNow' do
11
+ params = get_default_params
12
+ params = params.merge(get_integration_params_for_servicenow)
13
+
14
+ params["short_description"] = "This change request is created by BRPM"
15
+ params["description"] = "And a bit more blablabla"
16
+
17
+ params["base_url"] = "http://brpm.pulsar-it.be:29418/brpm"
18
+ params["request_id"] = "2199"
19
+
20
+ BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "create_change_request", params)
21
+ end
22
+ end
23
+ end
24
+
@@ -25,9 +25,15 @@ end
25
25
 
26
26
  def get_integration_params_for_servicenow
27
27
  params = {}
28
- params["SS_integration_dns"] = 'https://dev14275.service-now.com'
28
+ params["SS_integration_dns"] = 'https://dev17019.service-now.com'
29
29
  params["SS_integration_username"] = 'admin'
30
30
  params["SS_integration_password"] = ENV["SERVICENOW_PASSWORD"]
31
31
 
32
32
  params
33
33
  end
34
+
35
+ def cleanup_request_params
36
+ request_params_file = "/tmp/brpm_content/request_data.json"
37
+ File.delete(request_params_file) if File.exist?(request_params_file)
38
+ end
39
+
@@ -3,6 +3,7 @@ require_relative "spec_helper"
3
3
  describe 'transition issue' do
4
4
  before(:all) do
5
5
  setup_brpm_auto
6
+ cleanup_request_params
6
7
  end
7
8
 
8
9
  describe '' do
@@ -10,7 +11,7 @@ describe 'transition issue' do
10
11
  params = get_default_params
11
12
  params = params.merge(get_integration_params_for_servicenow)
12
13
 
13
- params["change_request_id"] = "2f31ef3b0fbb42000d3f758ce1050edd"
14
+ params["change_request_id"] = "af5362730f8d120072588b9ae1050e5c"
14
15
 
15
16
  params["target_change_request_status"] = "Pending"
16
17
  BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "transition_change_request", params)
@@ -0,0 +1,23 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe 'update issue' do
4
+ before(:all) do
5
+ setup_brpm_auto
6
+ cleanup_request_params
7
+ end
8
+
9
+ describe '' do
10
+ it 'should update a change request in ServiceNow' do
11
+ params = get_default_params
12
+ params = params.merge(get_integration_params_for_servicenow)
13
+
14
+ params["change_request_id"] = "6e262e730f8d120072588b9ae1050e62"
15
+
16
+ params["comments"] = "Hello world"
17
+ params["work_notes"] = "Lots of work to do"
18
+
19
+ BrpmScriptExecutor.execute_automation_script("brpm_module_servicenow", "update_change_request", params)
20
+ end
21
+ end
22
+ end
23
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brpm_module_servicenow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niek Bartholomeus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-02 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: brpm_content_framework
@@ -65,6 +65,10 @@ files:
65
65
  - Gemfile
66
66
  - README.md
67
67
  - Rakefile
68
+ - automations/await_approval_of_change_request.meta
69
+ - automations/await_approval_of_change_request.rb
70
+ - automations/create_change_request.meta
71
+ - automations/create_change_request.rb
68
72
  - automations/transition_change_request.meta
69
73
  - automations/transition_change_request.rb
70
74
  - automations/update_change_request.meta
@@ -72,8 +76,11 @@ files:
72
76
  - config.yml
73
77
  - lib/snow_rest_client.rb
74
78
  - module.gemspec
79
+ - tests/await_approval_of_change_request_spec.rb
80
+ - tests/create_change_request_spec.rb
75
81
  - tests/spec_helper.rb
76
82
  - tests/transition_change_request_spec.rb
83
+ - tests/update_change_request_spec.rb
77
84
  homepage: https://github.com/BMC-RLM/brpm_module_servicenow
78
85
  licenses:
79
86
  - MIT