opsviewconfig 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/opsviewconfig.rb +20 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c292dba1f04a59c9fc94eff447331a3e16ef9ae9
4
- data.tar.gz: c8bb55f1c4abf6849d5b2e321b586a158b68fb63
3
+ metadata.gz: 5407ac507b2a1aa5434c42408d753799d0b24347
4
+ data.tar.gz: cc5ba9c5f8d752aa8509d9796926ff09fb573f71
5
5
  SHA512:
6
- metadata.gz: 2dd3e841e93356334df1253ed531680e04f9b89bd5dfdeb5f2a901ebd94d5d611e77385af10970b6331f3e5066029c79e7472e449c87b1e8995e8d80c820daa1
7
- data.tar.gz: e99891843a7ed5d0b85392347aacfb23c9529f5e61631c9498e6fd0fa7b02ad7df307af6d36c9107533246a7e5e4992dc494c04bc1030cf7c754091c26684083
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(resource,folder)
28
- res = @connection.list(:type => resource)
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.3
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-04 00:00:00.000000000 Z
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