brpm_module_brpm 0.1.10 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/config.yml +1 -1
  3. data/lib/brpm_rest_client.rb +124 -22
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2ZhNDlhYmE2YzVmNTUwZjM1MTI5NjJmNzg3NTVmNWVjY2MyYmZmMw==
4
+ ZGQxYzI2OTcxYjVmYzVlODIxYTg3ZjFiMjNhZmM4NzczN2Q1MWM2YQ==
5
5
  data.tar.gz: !binary |-
6
- MjFlZGFkYTY0MGRjOTJkZGY5ODZiZWQ3MzgwNTUwZDEzMTY5MjU2Zg==
6
+ MGRmNmJlYjBjYWZiNDE3MzYyODNjNTNhODVmMGZkZDFhNTdlZjM1ZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDJjYTk1N2RjMDM3ODFiNmFjZTBkMzUxOTlhYzVjNDBiNDNlZWYwMWQwNjk5
10
- NjY4ZTcxYjE3NGE0MmUxNTEzYzQ5Y2Y0NDRmMDQ4ODE3ZjZiYjhmMjI0MGRi
11
- Mzg3NTY4MGMwYjhjM2Y5ZWQ2YTc1NWM5YjIwNzU3MjhiM2ZmZGQ=
9
+ MTg3NDI3OTc0MDQzZTg5NmQ2NWQ3ZWY2NDg3ZTI3N2ViOWVhNjg0NjI2MTI0
10
+ YWQzZDFiMGE0MjlkOWViYjRmZDU4MTUyNmYwYWM1YTBhODY5ZjZhZmY3MGJh
11
+ MTdmMTA1ZjNjZTFiM2IyNWQ0NjU4NmFhMDk5ZDJhNzdmOWZkZjc=
12
12
  data.tar.gz: !binary |-
13
- YmQyOWExMWU5OTM5OWU5ZTlkOWE3MGJjMWYyMmFjMWQ0Y2E1ZGE5NTY0OTg4
14
- ZjA5NjkyYzg2ODhkYjA3YjQ5YTIwODg3NmVmMzU0YjRkMjlkYmMyZWY4ZWQ5
15
- MWUxYTJkMTBhM2NlNjc4NjdhYWY2NjM0Mjc1NDNiZjc1ZmUxYWE=
13
+ MGZiZTMxZWViNDliOTYzYjE5ZDJhYWRlMWMxZTdjN2ZkOTFhMmNiMTU2Y2Jk
14
+ ZDUxZTFjNjQyMzcyNjY1ZTJmZTUzZmM3MWE1NWNiN2QyZWJhN2RkZjJiMzA3
15
+ ZjBjZDM1ZTQ0NDc2MjAxMDFiYzUyNzBhY2ZhMzNmZGI3MTJmNWQ=
data/config.yml CHANGED
@@ -2,7 +2,7 @@ dependencies:
2
2
 
3
3
  integration_servers:
4
4
 
5
- version: 0.1.10
5
+ version: 0.1.11
6
6
 
7
7
  author: Niek Bartholomeus
8
8
  email: niek.bartholomeus@gmail.com
@@ -1127,7 +1127,7 @@ class BrpmRestClient
1127
1127
  found = false
1128
1128
  request["steps"].each do |step|
1129
1129
  if (monitor_step_name != "none" and step["name"] == monitor_step_name) or
1130
- (monitor_step_id != "none" and step["id"] == monitor_step_id)
1130
+ (monitor_step_id != "none" and step["id"] == monitor_step_id)
1131
1131
  req_status = step["aasm_state"]
1132
1132
  found = true
1133
1133
  break
@@ -1387,7 +1387,6 @@ class BrpmRestClient
1387
1387
  sync_attribute "first received", now, ticket["extended_attributes_attributes"] unless ticket_already_exists
1388
1388
  sync_attribute "last updated", now, ticket["extended_attributes_attributes"]
1389
1389
 
1390
- # Create/update the ticket
1391
1390
  data = {}
1392
1391
  data["ticket"] = ticket
1393
1392
 
@@ -1402,6 +1401,109 @@ class BrpmRestClient
1402
1401
  end
1403
1402
  end
1404
1403
 
1404
+ def get_project_servers
1405
+ result = brpm_get "v1/project_servers"
1406
+
1407
+ if result["status"] == "success"
1408
+ result_hash = result["response"]
1409
+ else
1410
+ if result["code"] == 404
1411
+ result_hash = {}
1412
+ else
1413
+ raise "Error getting project servers: #{result["error_message"]}"
1414
+ end
1415
+ end
1416
+
1417
+ result_hash
1418
+ end
1419
+
1420
+ def get_id_for_project_server_type(integration_server_type)
1421
+ case integration_server_type.downcase
1422
+ when "Jira".downcase
1423
+ return 2
1424
+ when "Hudson/Jenkins".downcase, "Jenkins".downcase
1425
+ return 5
1426
+ when "Remedy via AO".downcase, "AO".downcase, "AtriumOrchestrator".downcase
1427
+ return 8
1428
+ when "BMC Application Automation".downcase, "Bladelogic".downcase
1429
+ return 9
1430
+ when "RLM Deployment Engine".downcase, "BRPD".downcase
1431
+ return 10
1432
+ else
1433
+ return nil
1434
+ end
1435
+ end
1436
+
1437
+ def get_scripts_by(filter)
1438
+ filter_string = "?"
1439
+ filter.each do |key, value|
1440
+ filter_string += "filters[#{key}]=#{value}&"
1441
+ end
1442
+ filter_string = filter_string[0..-1]
1443
+
1444
+ result = brpm_get "v1/scripts#{filter_string}"
1445
+
1446
+ if result["status"] == "success"
1447
+ result_hash = result["response"]
1448
+ else
1449
+ if result["code"] == 404
1450
+ result_hash = {}
1451
+ else
1452
+ raise "Error searching for scripts by #{filter_string}: #{result["error_message"]}"
1453
+ end
1454
+ end
1455
+
1456
+ result_hash
1457
+ end
1458
+
1459
+ def create_script_from_hash(script)
1460
+ result = brpm_post "v1/scripts", { :script => script }
1461
+
1462
+ unless result["status"] == "success"
1463
+ raise "Could not create the script: #{result["error_message"]}"
1464
+ end
1465
+
1466
+ result["response"]
1467
+ end
1468
+
1469
+ def update_script_from_hash(script)
1470
+ result = brpm_put "v1/scripts/#{script["id"]}", { :script => script }
1471
+
1472
+ unless result["status"] == "success"
1473
+ raise "Could not update the script: #{result["error_message"]}"
1474
+ end
1475
+
1476
+ result["response"]
1477
+ end
1478
+
1479
+ def create_or_update_script(script)
1480
+ BrpmAuto.log "Checking if the corresponding script already exists ..."
1481
+ existing_script = get_script_by_name script["name"]
1482
+
1483
+ if existing_script.nil?
1484
+ BrpmAuto.log "Script doesn't exist yet."
1485
+ script_already_exists=false
1486
+ else
1487
+ BrpmAuto.log "Script already exists."
1488
+ script_already_exists=true
1489
+
1490
+ script["id"] = existing_script["id"].to_s
1491
+ end
1492
+
1493
+ data = {}
1494
+ data["script"] = script
1495
+
1496
+ if script_already_exists
1497
+ BrpmAuto.log "Updating the script..."
1498
+ update_script_from_hash(script)
1499
+ BrpmAuto.log "Script is updated."
1500
+ else
1501
+ BrpmAuto.log "Creating the script..."
1502
+ create_script_from_hash(script)
1503
+ BrpmAuto.log "Script is created."
1504
+ end
1505
+ end
1506
+
1405
1507
  def sync_attributes(existing_attributes, updated_attributes)
1406
1508
  existing_attributes ||= []
1407
1509
  updated_attributes ||= []
@@ -1470,32 +1572,32 @@ class BrpmRestClient
1470
1572
 
1471
1573
  private
1472
1574
 
1473
- def add_token(path)
1474
- path + (path.include?("?") ? "&" : "?") + "token=#{@brpm_api_token}"
1475
- end
1575
+ def add_token(path)
1576
+ path + (path.include?("?") ? "&" : "?") + "token=#{@brpm_api_token}"
1577
+ end
1476
1578
 
1477
- def get_brpm_url(model_name, id = nil, filters = nil)
1478
- url = "#{@brpm_url}/v1/#{model_name}#{id == nil ? "" : "/#{id}" }"
1479
- url += "?#{filters}" if filters
1579
+ def get_brpm_url(model_name, id = nil, filters = nil)
1580
+ url = "#{@brpm_url}/v1/#{model_name}#{id == nil ? "" : "/#{id}" }"
1581
+ url += "?#{filters}" if filters
1480
1582
 
1481
- add_token(url)
1482
- end
1583
+ add_token(url)
1584
+ end
1483
1585
 
1484
- def brpm_get(path, options = {})
1485
- Rest.get("#{@brpm_url}/#{add_token(path)}", options)
1486
- end
1586
+ def brpm_get(path, options = {})
1587
+ Rest.get("#{@brpm_url}/#{add_token(path)}", options)
1588
+ end
1487
1589
 
1488
- def brpm_post(path, data, options = {})
1489
- Rest.post("#{@brpm_url}/#{add_token(path)}", data, options)
1490
- end
1590
+ def brpm_post(path, data, options = {})
1591
+ Rest.post("#{@brpm_url}/#{add_token(path)}", data, options)
1592
+ end
1491
1593
 
1492
- def brpm_put(path, data, options = {})
1493
- Rest.put("#{@brpm_url}/#{add_token(path)}", data, options)
1494
- end
1594
+ def brpm_put(path, data, options = {})
1595
+ Rest.put("#{@brpm_url}/#{add_token(path)}", data, options)
1596
+ end
1495
1597
 
1496
- def brpm_delete(path, options = {})
1497
- Rest.delete("#{@brpm_url}/#{add_token(path)}", options)
1498
- end
1598
+ def brpm_delete(path, options = {})
1599
+ Rest.delete("#{@brpm_url}/#{add_token(path)}", options)
1600
+ end
1499
1601
  end
1500
1602
 
1501
1603
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brpm_module_brpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niek Bartholomeus