usd 0.2.2 → 0.2.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -22
- data/bin/rusdc +41 -7
- data/change_log.md +103 -1
- data/usd.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f696d29388c8753c8af789acf542239241211c06846def69b792a9cc95eee735
|
4
|
+
data.tar.gz: 53f51965deba761faa9d759d77661599631609e2e7e4cf04d76eaa30088347a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317cd855b80a7fd240cccfb94211529c7857bcd4fa0347c72b7c29a4ec10135f713e1edc45d42de469febfa4fe405ffe137db92e0a0db9b1a54ba812eb2a9848
|
7
|
+
data.tar.gz: 02d8a72b2f6a552cd999629409e739ae7e87eeed93b10a5e9daa16c875a51f6afcaf474811931c20d75dd07840e749b62a00ae8d8b233849d21b498451451cd5
|
data/README.md
CHANGED
@@ -21,6 +21,14 @@ yum group install "Development Tools"
|
|
21
21
|
yum install ruby-devel
|
22
22
|
```
|
23
23
|
|
24
|
+
# documentation
|
25
|
+
|
26
|
+
see [https://github.com/ogaida/usd/wiki](https://github.com/ogaida/usd/wiki)
|
27
|
+
|
28
|
+
## bash-completion
|
29
|
+
|
30
|
+
see [https://github.com/ogaida/usd/wiki/bash-completion](https://github.com/ogaida/usd/wiki/bash-completion)
|
31
|
+
|
24
32
|
# external tools
|
25
33
|
|
26
34
|
If you use the `rusdc find` command with `--format mlr` option then you need `mlr`.
|
@@ -32,28 +40,31 @@ Place the `mlr`-binary in a path, which is in your PATH-Environment. Download-Ur
|
|
32
40
|
# functions from the commandline-tool `rusdc`
|
33
41
|
|
34
42
|
```
|
35
|
-
rusdc
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
43
|
+
rusdc chg_add_nr <co> <ci> # add a CI to a changeorder
|
44
|
+
rusdc chg_list_nr <co> # list all CIs of one changeorder
|
45
|
+
rusdc create # pipe json-data to create object
|
46
|
+
rusdc field_names <object-type> [wc] # list all fields of an object including its format
|
47
|
+
rusdc find <object-type> [where-clause] [fields, comma separated] [options] # finds each object which meets the wc-condition
|
48
|
+
rusdc get <object-type> <common_name|id> # shows one object by name or id
|
49
|
+
rusdc get_all_attachments_of_co <co_name> # get all attachments of a changeorder and save all th...
|
50
|
+
rusdc get_attachment_of_ci <ci_name> <filename> # download an attachment of a CI and print it out on s...
|
51
|
+
rusdc get_attachment_of_co <co_name> <filename> # download an attachment of a changeorder and print it...
|
52
|
+
rusdc help [COMMAND] # Describe available commands or one specific command
|
53
|
+
rusdc in_add_2_chg <changeorder> <incident> # add incident to changeorder
|
54
|
+
rusdc in_list_child_ins <in> # list all child-incidents of one incident
|
55
|
+
rusdc list_attachments_of_ci <ci_name> # list all attachments of a CI
|
56
|
+
rusdc list_attachments_of_co <co_name> # list all attachments of a changeorder
|
57
|
+
rusdc nr_add_child <nr-name> <child-name> # add one child CI to another CI
|
58
|
+
rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem
|
59
|
+
rusdc nr_changes <nr> [inactive-too] # list all open changeorders of one CI
|
60
|
+
rusdc nr_childs <ci-name> # lists all childs CIs of a specific CI
|
61
|
+
rusdc nr_incidents <nr> [inactive-too] # lists all incident of a specific CI
|
62
|
+
rusdc nr_parents <ci-name> # lists all parent CIs of a specific CI
|
63
|
+
rusdc update # pipe json-data to update object
|
64
|
+
rusdc update_attr <obj> <common_name|wc> <key> <value> # updates a direct (not referenced) attribute of one o...
|
65
|
+
rusdc update_attr_by_id <obj> <id> <key> <value> # updates a plain attribute of one object by id, does ...
|
66
|
+
rusdc update_ref_attr <obj> <common_name> <key> <value> # updates a referenced attribute of one object.
|
67
|
+
rusdc update_ref_attr_by_id <obj> <id> <key> <value_id> # updates a referenced attribute of one object_id by v...
|
57
68
|
```
|
58
69
|
|
59
70
|
# environment-variables
|
@@ -81,3 +92,14 @@ then
|
|
81
92
|
export usdpass
|
82
93
|
fi
|
83
94
|
```
|
95
|
+
|
96
|
+
# example - find records
|
97
|
+
|
98
|
+
```bash
|
99
|
+
$ rusdc find nr "name like 'foo%'" name,description --format mlr
|
100
|
+
name description
|
101
|
+
foo1 foo QS
|
102
|
+
foo2 foo TEST
|
103
|
+
```
|
104
|
+
|
105
|
+
more examples under [find examples-Wikipage](https://github.com/ogaida/usd/wiki/find-examples) or in the [change_log](https://github.com/ogaida/usd/blob/master/change_log.md)
|
data/bin/rusdc
CHANGED
@@ -89,6 +89,7 @@ class Rusdc < Thor
|
|
89
89
|
option :nice_time, :type => :boolean, :default => true,:banner => "[true|false]"
|
90
90
|
option :debug, :type => :boolean, :default => false,:banner => "[true|false]"
|
91
91
|
def find(object, wc="", fields="@COMMON_NAME")
|
92
|
+
exitcode=0
|
92
93
|
unless (fields =~ /^[\w\_,@]+$/)
|
93
94
|
puts "fields-problem: there must be only letters, numbers, comma, the @-sign or underscore, nothing else!"
|
94
95
|
else
|
@@ -96,6 +97,7 @@ class Rusdc < Thor
|
|
96
97
|
mlr_array = []
|
97
98
|
con.debug = options[:debug]
|
98
99
|
e = con.search(object,{'fields' => fields,"wc" => wc})
|
100
|
+
exitcode=1 if e.count == 0
|
99
101
|
fields_array=fields.split(/,/)
|
100
102
|
e.each do |elem|
|
101
103
|
# init all requested keys with empty strings, better for mlr format and needed for fields-order
|
@@ -105,7 +107,7 @@ class Rusdc < Thor
|
|
105
107
|
elem.keys.each do |elem_key|
|
106
108
|
if options[:nice_time]
|
107
109
|
if elem_key =~ /(date|last_mod|warranty_start|warranty_end|time_stamp)$/
|
108
|
-
elem[elem_key]=Time.at(elem[elem_key]).to_s
|
110
|
+
elem[elem_key]=Time.at(elem[elem_key]).to_s if elem[elem_key] != "" # not empty
|
109
111
|
end
|
110
112
|
end
|
111
113
|
if fields_array.include?(elem_key)
|
@@ -125,9 +127,11 @@ class Rusdc < Thor
|
|
125
127
|
case options[:format]
|
126
128
|
when "json"
|
127
129
|
puts mlr
|
130
|
+
exit exitcode
|
128
131
|
when "yaml"
|
129
132
|
# keys not sorted, maybe a todo
|
130
133
|
puts e.to_yaml
|
134
|
+
exit exitcode
|
131
135
|
when "mlr"
|
132
136
|
# hierfuer muss mlr verfuegbar sein
|
133
137
|
file = Tempfile.new('json')
|
@@ -136,8 +140,10 @@ class Rusdc < Thor
|
|
136
140
|
file.close
|
137
141
|
puts `#{cmd}`
|
138
142
|
file.unlink
|
143
|
+
exit exitcode
|
139
144
|
else
|
140
145
|
puts "das Format #{options[:format]} ist nicht hinterlegt. Es gibt nur json, yaml oder mlr."
|
146
|
+
exit 2
|
141
147
|
end
|
142
148
|
end # fields check
|
143
149
|
end
|
@@ -166,7 +172,7 @@ class Rusdc < Thor
|
|
166
172
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
167
173
|
att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
168
174
|
att_nr.each do |att|
|
169
|
-
attmnt = loadcon.request("/caisd-rest/attmnt
|
175
|
+
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
170
176
|
filename = attmnt["orig_file_name"]
|
171
177
|
puts "save #{filename}"
|
172
178
|
f = File.open(filename, 'w')
|
@@ -180,7 +186,7 @@ class Rusdc < Thor
|
|
180
186
|
def get_attachment_of_ci(ciname, filename)
|
181
187
|
att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
|
182
188
|
att_nr.each do |att|
|
183
|
-
attmnt = loadcon.request("/caisd-rest/attmnt
|
189
|
+
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
184
190
|
if attmnt["orig_file_name"] == filename
|
185
191
|
puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
|
186
192
|
end
|
@@ -192,13 +198,18 @@ class Rusdc < Thor
|
|
192
198
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
193
199
|
att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
194
200
|
att_nr.each do |att|
|
195
|
-
attmnt = loadcon.request("/caisd-rest/attmnt
|
201
|
+
attmnt = loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]
|
196
202
|
if attmnt["orig_file_name"] == filename
|
197
203
|
puts loadcon.request("/caisd-rest/attmnt/#{attmnt["@id"]}/file-resource",{:unchanged => true})
|
198
204
|
end
|
199
205
|
end
|
200
206
|
end
|
201
207
|
|
208
|
+
desc "in_add_2_chg <changeorder> <incident>", "add incident to changeorder"
|
209
|
+
def in_add_2_chg(chg, incident)
|
210
|
+
invoke('update_ref_attr',['in', incident, 'change', chg])
|
211
|
+
end
|
212
|
+
|
202
213
|
desc "in_list_child_ins <in>", "list all child-incidents of one incident"
|
203
214
|
def in_list_child_ins(incident)
|
204
215
|
invoke('find',['cr', "parent.ref_num = '#{incident}'", "ref_num"], {:format => "mlr"})
|
@@ -208,7 +219,7 @@ class Rusdc < Thor
|
|
208
219
|
def list_attachments_of_ci(ciname)
|
209
220
|
att_nr = loadcon.search("lrel_attachments_nr",{'fields' => "attmnt","wc" => "nr.name = '#{ciname}'"})
|
210
221
|
att_nr.each do |att|
|
211
|
-
puts loadcon.request("/caisd-rest/attmnt
|
222
|
+
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
212
223
|
end
|
213
224
|
end
|
214
225
|
|
@@ -217,7 +228,7 @@ class Rusdc < Thor
|
|
217
228
|
chg_id=loadcon.request("/caisd-rest/chg/COMMON_NAME-#{coname}")["chg"]["@id"]
|
218
229
|
att_nr = loadcon.search("lrel_attachments_changes",{'fields' => "attmnt","wc" => "chg = #{chg_id}"})
|
219
230
|
att_nr.each do |att|
|
220
|
-
puts loadcon.request("/caisd-rest/attmnt
|
231
|
+
puts loadcon.request("/caisd-rest/attmnt/#{att["attmnt"]["@id"]}")["attmnt"]["orig_file_name"]
|
221
232
|
end
|
222
233
|
end
|
223
234
|
|
@@ -239,6 +250,29 @@ class Rusdc < Thor
|
|
239
250
|
puts loadcon.create({:type => "json", :data => json})
|
240
251
|
end
|
241
252
|
|
253
|
+
# $ rusdc find lrel_oenv_orgref "nr.name like 'servername1'" org
|
254
|
+
# [{
|
255
|
+
# "org": "Orname1"
|
256
|
+
# }]
|
257
|
+
|
258
|
+
desc "nr_add_org <nr> <org>", "add an Organisation to a ConfigurationItem"
|
259
|
+
def nr_add_org(nr, org)
|
260
|
+
template = ERB.new <<-EOF
|
261
|
+
{
|
262
|
+
"lrel_oenv_orgref": {
|
263
|
+
"nr": {
|
264
|
+
"@id": "<%= uid_nr %>"
|
265
|
+
},
|
266
|
+
"org": {
|
267
|
+
"@id": "<%= uid_org %>"
|
268
|
+
}
|
269
|
+
}
|
270
|
+
}
|
271
|
+
EOF
|
272
|
+
json = template.result_with_hash(:uid_org => loadcon.request("/caisd-rest/org/COMMON_NAME-#{org}")["org"]["@id"], :uid_nr => loadcon.request("/caisd-rest/nr/COMMON_NAME-#{nr}")["nr"]["@id"])
|
273
|
+
puts loadcon.create({:type => "json", :data => json})
|
274
|
+
end
|
275
|
+
|
242
276
|
desc "nr_changes <nr> [inactive-too]", "list all open changeorders of one CI"
|
243
277
|
option :inactive_too, :type => :boolean, :default => false
|
244
278
|
def nr_changes(nr)
|
@@ -375,7 +409,7 @@ class Rusdc < Thor
|
|
375
409
|
puts loadcon.update({:type => "json", :data => json})
|
376
410
|
end
|
377
411
|
|
378
|
-
desc "update_ref_attr_by_id <obj> <id> <key> <
|
412
|
+
desc "update_ref_attr_by_id <obj> <id> <key> <value_id>", "updates a referenced attribute of one object_id by value-id"
|
379
413
|
def update_ref_attr_by_id(obj, id, k, v)
|
380
414
|
template = ERB.new <<-EOF
|
381
415
|
{
|
data/change_log.md
CHANGED
@@ -1,4 +1,106 @@
|
|
1
|
-
# changelog
|
1
|
+
# rusdc changelog
|
2
|
+
|
3
|
+
## 0.2.5.3
|
4
|
+
|
5
|
+
- neu function : `rusdc nr_add_org <nr> <org> # add an Organisation to a ConfigurationItem`
|
6
|
+
|
7
|
+
#### fixes:
|
8
|
+
|
9
|
+
- rusdc - line 110: more robust when querying date fields
|
10
|
+
|
11
|
+
## 0.2.4.2
|
12
|
+
|
13
|
+
the same fixes as in 0.2.4.1 for:
|
14
|
+
|
15
|
+
```
|
16
|
+
rusdc list_attachments_of_ci <ci_name>
|
17
|
+
rusdc list_attachments_of_co <co_name>
|
18
|
+
```
|
19
|
+
|
20
|
+
## 0.2.4.1
|
21
|
+
|
22
|
+
### fixes
|
23
|
+
|
24
|
+
- `rusdc get_attachment_of_ci` : attachment with spaces in path could not be downloaded
|
25
|
+
|
26
|
+
## 0.2.4
|
27
|
+
|
28
|
+
- find function has exitcode > 0 if no records has been found
|
29
|
+
|
30
|
+
```
|
31
|
+
$ rusdc find nr "name = 'not_here'" || echo 'i am not here, please create me'
|
32
|
+
[]
|
33
|
+
i am not here, please create me
|
34
|
+
$ rusdc find cnt "last_name = 'Gaida'" && echo 'i am here, you may update me'
|
35
|
+
[{
|
36
|
+
"@COMMON_NAME": "Gaida, Oliver "
|
37
|
+
}]
|
38
|
+
i am here, you may update me
|
39
|
+
```
|
40
|
+
|
41
|
+
### fixes
|
42
|
+
|
43
|
+
- `rusdc get_all_attachments_of_co` : attachment with spaces in path could not be downloaded
|
44
|
+
|
45
|
+
## 0.2.3
|
46
|
+
|
47
|
+
- new function `in_add_2_chg` - add incident to changeorder
|
48
|
+
|
49
|
+
Usage:
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
rusdc in_add_2_chg <changeorder> <incident>
|
54
|
+
```
|
55
|
+
|
56
|
+
Example:
|
57
|
+
|
58
|
+
```
|
59
|
+
$ rusdc find in "change.chg_ref_num = 'CO000001'" --format mlr
|
60
|
+
@COMMON_NAME
|
61
|
+
I000001
|
62
|
+
I000002
|
63
|
+
$ rusdc in_add_2_chg CO000001 I000003
|
64
|
+
$ rusdc find in "change.chg_ref_num = 'CO000001'" --format mlr
|
65
|
+
@COMMON_NAME
|
66
|
+
I000001
|
67
|
+
I000002
|
68
|
+
I000003
|
69
|
+
```
|
70
|
+
|
71
|
+
## 0.2.2
|
72
|
+
|
73
|
+
- extented function `update_attr`, now you may use a where-clause instead of a `common_name` to filter the object(s) to update
|
74
|
+
|
75
|
+
Example 1:
|
76
|
+
|
77
|
+
update many CIs with one statement...b
|
78
|
+
|
79
|
+
```bash
|
80
|
+
$ rusdc find nr "name like 'server[12]'" name,description --format mlr
|
81
|
+
name description
|
82
|
+
server1 vorher
|
83
|
+
server2 vorher
|
84
|
+
$ rusdc update_attr nr "name like 'server[12]'" description "new description"
|
85
|
+
$ rusdc find nr "name like 'server[12]'" name,description --format mlr
|
86
|
+
name description
|
87
|
+
server1 new description
|
88
|
+
server2 new description
|
89
|
+
```
|
90
|
+
|
91
|
+
Example 2:
|
92
|
+
|
93
|
+
update a CI which has a special attribute value:
|
94
|
+
|
95
|
+
```bash
|
96
|
+
$ rusdc find nr "serial_number = 'ABC123ABC987'" name,serial_number,warranty_end --format mlr
|
97
|
+
name serial_number warranty_end
|
98
|
+
server1 ABC123ABC987 2020-11-30 00:00:00 +0100
|
99
|
+
$ rusdc update_attr nr "serial_number = 'ABC123ABC987'" warranty_end "01.02.2022"
|
100
|
+
$ rusdc find nr "serial_number = 'ABC123ABC987'" name,serial_number,warranty_end --format mlr
|
101
|
+
name serial_number warranty_end
|
102
|
+
server1 ABC123ABC987 2022-02-01 00:00:00 +0100
|
103
|
+
```
|
2
104
|
|
3
105
|
## 0.2.1
|
4
106
|
|
data/usd.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'usd'
|
3
|
-
spec.version = '0.2.
|
4
|
-
spec.date = '
|
3
|
+
spec.version = '0.2.5.3'
|
4
|
+
spec.date = '2020-07-15'
|
5
5
|
spec.summary = "SDM REST-API-Calls"
|
6
6
|
spec.description = "a Ruby class and a commandlinetool for SDM REST-API-Calls"
|
7
7
|
spec.authors = ["Oliver Gaida"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Gaida
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|