brpm_module_brpm 0.1.25 → 0.1.26
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 +8 -8
- data/config.yml +1 -1
- data/lib/brpm_rest_client.rb +24 -33
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
MGVjM2UxNDU2ZGFmZWExODY2MDI4ZDAzMTVlYzgyMTVmOTZhOWI4MA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
ZDg3YTQ0OWFjYjMzMzk2OGQxZTUyYmYzYWVlODM3MjkzYTYwMTc3OA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NmE1NTE2NzA0MzUwOTQ1YmJhNjg3NzRjNzVhYTEwNDQ0NjQwNDRiMmE2YmQ5
|
|
10
|
+
YTczZTE4YjJkMGI3MGU2NmM1OGE3Y2RmNzViYjcxZmIyZjVmNDdhMDk4ZGM4
|
|
11
|
+
OTFlNWYzMWE4MjE0YmQ2YjNjYjMwZjEwMDc2NTM1MmFiM2MwMDE=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
ZjQ0NzNlMmY2MjJiMGE5NTYyNzA4ZDkzMGU0MTBiNGRkN2QyMzU4YzdhNTUz
|
|
14
|
+
MTc2YjE5YWY0ZTFlYTMzM2Y5YmQ5NjFhMzQwMzdmZDZhNmUyMzIwOTk5YWUy
|
|
15
|
+
M2I2YTk1Mjc0NDlhZTA4YzY1ZmVlZDg1N2MwNzI4N2RjODQyOWU=
|
data/config.yml
CHANGED
data/lib/brpm_rest_client.rb
CHANGED
|
@@ -1633,10 +1633,14 @@ class BrpmRestClient
|
|
|
1633
1633
|
end
|
|
1634
1634
|
|
|
1635
1635
|
def get_script_by_name(name)
|
|
1636
|
-
|
|
1636
|
+
# TODO: the scripts REST API is not finished yet: get_script_by_name always returns "null". So for now we are going to create the script and if it returns an error that the name is already taken we will update it
|
|
1637
|
+
|
|
1638
|
+
# result = brpm_get "v1/scripts?filters[name]=#{name}"
|
|
1639
|
+
result = brpm_get "v1/scripts"
|
|
1637
1640
|
|
|
1638
1641
|
if result["status"] == "success"
|
|
1639
|
-
result_hash = result["response"].first
|
|
1642
|
+
# result_hash = result["response"].first
|
|
1643
|
+
result_hash = result["response"].find { |script| script["name"] == name}
|
|
1640
1644
|
else
|
|
1641
1645
|
if result["code"] == 404
|
|
1642
1646
|
result_hash = nil
|
|
@@ -1691,44 +1695,31 @@ class BrpmRestClient
|
|
|
1691
1695
|
end
|
|
1692
1696
|
|
|
1693
1697
|
def create_or_update_script(script)
|
|
1694
|
-
# TODO: the scripts REST API is not finished yet: get_script_by_name always returns "null". So for now we are going to create the script and if it returns an error that the name is already taken we will update it
|
|
1695
1698
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1699
|
+
BrpmAuto.log "Checking if the corresponding script already exists ..."
|
|
1700
|
+
existing_script = get_script_by_name(script["name"])
|
|
1701
|
+
|
|
1702
|
+
if existing_script.nil?
|
|
1703
|
+
BrpmAuto.log "Script doesn't exist yet."
|
|
1704
|
+
script_already_exists=false
|
|
1705
|
+
else
|
|
1706
|
+
BrpmAuto.log "Script already exists."
|
|
1707
|
+
script_already_exists=true
|
|
1708
|
+
|
|
1709
|
+
script["id"] = existing_script["id"].to_s
|
|
1710
|
+
end
|
|
1708
1711
|
|
|
1709
1712
|
data = {}
|
|
1710
1713
|
data["script"] = script
|
|
1711
1714
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
# script = create_script_from_hash(script)
|
|
1719
|
-
# BrpmAuto.log "Script is created."
|
|
1720
|
-
# end
|
|
1721
|
-
|
|
1722
|
-
BrpmAuto.log "Creating the script..."
|
|
1723
|
-
begin
|
|
1715
|
+
if script_already_exists
|
|
1716
|
+
BrpmAuto.log "Updating the script..."
|
|
1717
|
+
script = update_script_from_hash(script)
|
|
1718
|
+
BrpmAuto.log "Script is updated."
|
|
1719
|
+
else
|
|
1720
|
+
BrpmAuto.log "Creating the script..."
|
|
1724
1721
|
script = create_script_from_hash(script)
|
|
1725
1722
|
BrpmAuto.log "Script is created."
|
|
1726
|
-
rescue Exception => e
|
|
1727
|
-
if "#{e}".include?("has already been taken")
|
|
1728
|
-
BrpmAuto.log "Script already exists, updating it..."
|
|
1729
|
-
script = update_script_from_hash(script)
|
|
1730
|
-
BrpmAuto.log "Script is updated."
|
|
1731
|
-
end
|
|
1732
1723
|
end
|
|
1733
1724
|
|
|
1734
1725
|
script
|