opsviewconfig 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/opsviewconfig.rb +20 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5407ac507b2a1aa5434c42408d753799d0b24347
|
4
|
+
data.tar.gz: cc5ba9c5f8d752aa8509d9796926ff09fb573f71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3a62f5ac7965b9ce8b76ac8279712401c899c681cfbfd9c519f840bcebf5310247302851c4af6e13de92d20e8ac25ee828e30baefbdc053dede2d81e62ab54d
|
7
|
+
data.tar.gz: cb85c3a01eee6820822f218ec697194ccdb1acda84e95c7fdbf03e4f93e7988797565560349323d176e01fb2918bfa5385d7e3be2fa2f2da1b571fd5b5e06df2
|
data/lib/opsviewconfig.rb
CHANGED
@@ -24,10 +24,10 @@ class Opsviewconfig
|
|
24
24
|
return @connecton
|
25
25
|
end
|
26
26
|
|
27
|
-
def export(
|
28
|
-
res = @connection.list(:type =>
|
27
|
+
def export(resourcetype,folder)
|
28
|
+
res = @connection.list(:type => resourcetype)
|
29
29
|
# Need to parse out junk we don't need to export
|
30
|
-
res = export_parse(res)
|
30
|
+
res = export_parse(res,resourcetype)
|
31
31
|
res.each do |resource|
|
32
32
|
filename = resource['name'].dup
|
33
33
|
filename.gsub!(/[^0-9A-Za-z.\-]/, '_')
|
@@ -39,10 +39,26 @@ class Opsviewconfig
|
|
39
39
|
end
|
40
40
|
|
41
41
|
# Function to clean up the exported object
|
42
|
-
def export_parse(export)
|
42
|
+
def export_parse(export,resourcetype)
|
43
43
|
cleanexport = Array.new()
|
44
44
|
export.each do |resource|
|
45
|
+
# Delete the id's, since these are installation specific
|
45
46
|
resource.delete("id")
|
47
|
+
|
48
|
+
# Delete the hosts to which the some of these resources are assigned to, since these might not exist elsewhere
|
49
|
+
if resourcetype == "servicecheck" || resourcetype == "hosttemplate" || resourcetype == "hostcheckcommand"
|
50
|
+
resource.delete("hosts")
|
51
|
+
end
|
52
|
+
|
53
|
+
# Remove hosttemplates from servicechecks
|
54
|
+
if resourcetype == "servicecheck"
|
55
|
+
resource.delete("hosttemplates")
|
56
|
+
end
|
57
|
+
|
58
|
+
# Don't save if this is an EC2 host instance, those should be generated automatically and we don't need to version control them
|
59
|
+
next if resource["hosttemplates"].find { |h| h['name'] == 'ec2instance'}
|
60
|
+
|
61
|
+
# Save
|
46
62
|
cleanexport << resource.sort_by_key(true)
|
47
63
|
end
|
48
64
|
return cleanexport
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsviewconfig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy M
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple class to import and export OpsView config
|
14
14
|
email: dmitriy.mar@gmail.com
|