vcenter_lib_mongodb 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/lib/vcenter_lib_mongodb/logging.rb +1 -4
- data/lib/vcenter_lib_mongodb/mongodb.rb +14 -7
- data/lib/vcenter_lib_mongodb/version.rb +1 -1
- data/vcenter_lib_mongodb.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8350abc73999ce34c2839814c14672cdc35df115
|
4
|
+
data.tar.gz: cd3ce330d30d10e15694b86114b0a818c44b5cb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d42df52f45c33a049d29fcc75da3b5d3843b012ab31196cb6177a1d1d728863626300e950f19a33ce4e11e1386bc6e55f91c9af9ac3c0fe0e1ebccae04e4755
|
7
|
+
data.tar.gz: 8d866be31b461c7b7e05ea23d85a2d810818edece28e8c425b2f918b73cc133f67b153b5a4a01bca0997064a823fde92eac76ebfb77e99da1562a15568587da3
|
data/.gitignore
CHANGED
@@ -30,23 +30,29 @@ module VcenterLibMongodb
|
|
30
30
|
collection.find.batch_size(999).projection(_id: 1).map { |k| k[:_id] }
|
31
31
|
end
|
32
32
|
|
33
|
-
# get vm names that fulfill given
|
33
|
+
# get vm names that fulfill given query
|
34
34
|
#
|
35
|
-
# @param query
|
35
|
+
# @param query [String] a query for VMs.
|
36
|
+
# nil or white space only string will return all VMs
|
37
|
+
# @return [Array<String>] names of nodes that fulfill the query
|
36
38
|
def query_vms(query)
|
39
|
+
return all_nodes if query_string.nil? || query_string.strip.empty?
|
40
|
+
mongo_query = convert.query(query)
|
37
41
|
collection = connection[vms_collection]
|
38
|
-
collection.find(
|
42
|
+
collection.find(mongo_query).batch_size(999).projection(_id: 1).map { |k| k[:_id] }
|
39
43
|
end
|
40
44
|
|
41
45
|
# get vms and their facts that fulfill given mongodb query
|
42
46
|
#
|
43
|
-
# @param query
|
47
|
+
# @param query[String] a query for VMs
|
44
48
|
# @param facts [Array<String>] get these facts in the result, eg ['boot_time'], empty for all
|
49
|
+
# @return [Hash<name, <fact , value>>] VM names with their facts and values
|
45
50
|
def query_facts(query, facts = [])
|
51
|
+
mongo_query = convert.query(query)
|
46
52
|
fields = Hash[facts.collect { |fact| [fact.to_sym, 1] }]
|
47
53
|
collection = connection[vms_collection]
|
48
54
|
result = {}
|
49
|
-
collection.find(
|
55
|
+
collection.find(mongo_query).batch_size(999).projection(fields).each do |values|
|
50
56
|
id = values.delete('_id')
|
51
57
|
result[id] = values
|
52
58
|
end
|
@@ -68,7 +74,7 @@ module VcenterLibMongodb
|
|
68
74
|
result
|
69
75
|
end
|
70
76
|
|
71
|
-
# get
|
77
|
+
# get VMs and their facts for a pattern
|
72
78
|
#
|
73
79
|
# @param query mongodb query
|
74
80
|
# @param pattern [RegExp] search for
|
@@ -76,9 +82,10 @@ module VcenterLibMongodb
|
|
76
82
|
# @param facts_found [Array<String>] fact names are added to this array
|
77
83
|
# @param check_names [Boolean] also search fact names
|
78
84
|
def search_facts(query, pattern, facts = [], facts_found = [], check_names = false)
|
85
|
+
mongo_query = convert.query(query)
|
79
86
|
collection = connection[vms_collection]
|
80
87
|
result = {}
|
81
|
-
collection.find(
|
88
|
+
collection.find(mongo_query).batch_size(999).each do |values|
|
82
89
|
id = values.delete('_id')
|
83
90
|
found = {}
|
84
91
|
values.each do |k, v|
|
data/vcenter_lib_mongodb.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency 'vcenter_lib'
|
22
22
|
spec.add_dependency 'mongo'
|
23
|
-
spec.add_dependency '
|
23
|
+
spec.add_dependency 'puppetdb_query'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rspec'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcenter_lib_mongodb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Meyling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vcenter_lib
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: puppetdb_query
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|