depot3 3.0.8 → 3.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +22 -2
  3. data/README.md +9 -12
  4. data/bin/d3 +7 -1
  5. data/bin/d3admin +6 -4
  6. data/bin/d3helper +16 -10
  7. data/lib/d3/admin/add.rb +5 -1
  8. data/lib/d3/admin/auth.rb +1 -1
  9. data/lib/d3/admin/edit.rb +1 -0
  10. data/lib/d3/admin/help.rb +1 -0
  11. data/lib/d3/admin/interactive.rb +1 -0
  12. data/lib/d3/admin/options.rb +1 -0
  13. data/lib/d3/admin/prefs.rb +1 -0
  14. data/lib/d3/admin/report.rb +3 -0
  15. data/lib/d3/admin/state.rb +1 -0
  16. data/lib/d3/admin/validate.rb +1 -0
  17. data/lib/d3/admin.rb +6 -1
  18. data/lib/d3/basename.rb +1 -0
  19. data/lib/d3/client/auth.rb +1 -0
  20. data/lib/d3/client/class_methods.rb +11 -5
  21. data/lib/d3/client/class_variables.rb +1 -0
  22. data/lib/d3/client/cli.rb +7 -1
  23. data/lib/d3/client/environment.rb +1 -0
  24. data/lib/d3/client/help.rb +1 -0
  25. data/lib/d3/client/lists.rb +9 -4
  26. data/lib/d3/client/receipt.rb +5 -1
  27. data/lib/d3/client.rb +1 -0
  28. data/lib/d3/configuration.rb +1 -0
  29. data/lib/d3/constants.rb +6 -0
  30. data/lib/d3/database.rb +1 -0
  31. data/lib/d3/exceptions.rb +1 -0
  32. data/lib/d3/log.rb +1 -0
  33. data/lib/d3/package/aliases.rb +1 -0
  34. data/lib/d3/package/attributes.rb +3 -0
  35. data/lib/d3/package/class_methods.rb +2 -1
  36. data/lib/d3/package/class_variables.rb +1 -0
  37. data/lib/d3/package/client_actions.rb +1 -0
  38. data/lib/d3/package/constants.rb +1 -0
  39. data/lib/d3/package/constructor.rb +2 -0
  40. data/lib/d3/package/getters.rb +1 -0
  41. data/lib/d3/package/mixins.rb +1 -0
  42. data/lib/d3/package/private_methods.rb +1 -0
  43. data/lib/d3/package/questions.rb +1 -0
  44. data/lib/d3/package/server_actions.rb +1 -0
  45. data/lib/d3/package/setters.rb +1 -0
  46. data/lib/d3/package/validate.rb +2 -1
  47. data/lib/d3/package.rb +3 -1
  48. data/lib/d3/puppytime/pending_puppy.rb +14 -14
  49. data/lib/d3/puppytime/puppy_queue.rb +9 -1
  50. data/lib/d3/puppytime.rb +4 -5
  51. data/lib/d3/state.rb +29 -13
  52. data/lib/d3/utility.rb +12 -6
  53. data/lib/d3/version.rb +2 -1
  54. data/lib/d3.rb +13 -9
  55. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f2b0abc1414a252659c6d595bf3283bf1b7a8e2
4
- data.tar.gz: 1a01a64aa7a219af0899dae23b8626d646d00ee1
3
+ metadata.gz: c3958145701408de91742321b631220d28616638
4
+ data.tar.gz: 46cfaa84e02925dc7d3ea47d7616cb395ab4e2ab
5
5
  SHA512:
6
- metadata.gz: eb799803790a7b79b80db8e52beecdf9b768af16eb36592aaa746cdfa9307cc7e3a1263ce817749aa7b9935c90d614743f986801c929646ff0f023300fa01017
7
- data.tar.gz: a6cf663b32cdec3a3746586e904aa49cd57f4427187432510a1a56e5c7c32653e989b972870c62c6a5978075fa8cef0afe1a8e1f35b30e3c75d223189118ec63
6
+ metadata.gz: 3e37917a62941a884946bea3e32425d1a1731098c2f6d0b03aa6373e9375b1173bb4aaaa2dc2877e8739b28359513ce7ed8a8127540d4ec6ad57b96de4fd3f22
7
+ data.tar.gz: bde22daae9f593443f68c4a71375e5e3624acebc38a639cded1159bc7440e014aa5d04ef9fbacca7cac0c10d8cb27eaeb12a3a98135eb32227a022254b061ae1
data/CHANGES.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Change History
2
2
 
3
- ## v3.0.0 - 2016-04-04
3
+ ## v3.0.9 - 2016-04-11
4
4
 
5
- Planned initial open source release
5
+ - d3: better text feedback during manual installs.
6
+ - Package.all_filenames: limit list to d3 packages, not all JSS packages.
7
+ - Client::Receript.add\_receipt: log "replaced" only when really replacing.
8
+ - d3helper: clean up rcpt import, add pkg ids, admin name.
9
+ - README: better contact info
10
+ - lots of comment changes for YARD parsing fix
11
+ - Package::Validate.check\_for\_exlusions: bugfix
12
+ - Added D3::DEBUG_FILE support for d3, d3admin, & d3helper. Used getting debug logging/output when d3 command is embedded in other tools. If the file /tmp/d3debug-on exists, it's the same using the --debug option
13
+ - d3: actions that don't need server connections can be done witout root: list-installed, list-manual, list-pilot, list-frozen, list-queue
14
+
15
+ ## v3.0.8 - 2016-04-01
16
+
17
+ - Fix: pre- and post-install script failures no longer cause fatal exceptions, halting sync. Instead the error is reported, the package skipped, and the sync continues.
18
+
19
+ ## v3.0.7 - 2016-04-01
20
+
21
+ Initial open source release
22
+
23
+ ## v3.0.6 - 2016-03-28
24
+
25
+ Pixar internal release of v3.
data/README.md CHANGED
@@ -4,8 +4,7 @@ d3 is a package deployment and patch management system for OS X that enhances th
4
4
  [Casper Suite](http://www.jamfsoftware.com/products/casper-suite/), an enterprise-level management system for Apple devices from [JAMF Software](http://www.jamfsoftware.com/). It was created by [Pixar Animation Studios](http://www.pixar.com/).
5
5
 
6
6
 
7
-
8
- d3 adds these, capabilities and more, to Casper's package handling:
7
+ d3 adds these capabilities and more to Casper's package handling:
9
8
 
10
9
  * Automatic software updates on clients when new versions are released on the server
11
10
  * Pre-release piloting of new packages
@@ -15,21 +14,22 @@ d3 adds these, capabilities and more, to Casper's package handling:
15
14
  * Both the client and admin tools are command-line only and fully scriptable
16
15
  * Admin command-line options allow integration with developer workflows and package-retrieval tools
17
16
 
18
- d3 is written in Ruby and available as a rubygem called ['depot3'](https://rubygems.org/gems/depot3). It interfaces with Casper mostly via it's REST API using [ruby-jss](https://github.com/PixarAnimationStudios/ruby-jss), a ruby module that provides simple and powerful access to the API. It also uses Casper's backend MySQL database directly to provide enhanced features.
17
+ d3 is written in Ruby and available as a rubygem called ['depot3'](https://rubygems.org/gems/depot3). It interfaces with Casper via its REST API using [ruby-jss](https://github.com/PixarAnimationStudios/ruby-jss), a ruby module that provides simple and powerful access to the API. It also uses Casper's backend MySQL database directly to provide enhanced features.
19
18
 
19
+ ## DOCUMENTATION
20
20
 
21
- Please see the [wiki](https://github.com/PixarAnimationStudios/depot3/wiki) for full documentation
21
+ Full user/administrator documentation is available at the [GitHub project's wiki page](https://github.com/PixarAnimationStudios/depot3/wiki).
22
22
 
23
- The developer documentation for the D3 ruby module is at [http://www.rubydoc.info/gems/depot3](http://www.rubydoc.info/gems/depot3)
23
+ The developer documentation for the D3 ruby module is at [http://www.rubydoc.info/gems/depot3](http://www.rubydoc.info/gems/depot3).
24
24
 
25
- Also check out [ruby-jss](https://github.com/PixarAnimationStudios/ruby-jss), which is used by d3, but is useful for working with the Casper REST API in any project.
25
+ Also check out [ruby-jss](https://github.com/PixarAnimationStudios/ruby-jss), which is used by d3, but is useful for working with the Casper REST API in any project.
26
26
 
27
27
 
28
28
  ## CONTACT
29
29
 
30
- [Email the developer](mailto:d3@pixar.com)
30
+ [Email](mailto:d3@pixar.com)
31
31
 
32
- [Macadmins Slack Channel](https://macadmins.slack.com/messages/#d3/)
32
+ [Macadmins Slack Channel](https://macadmins.slack.com/messages/#d3/)(@glenfarclas17)
33
33
 
34
34
  ## LICENSE
35
35
 
@@ -41,10 +41,7 @@ compliance with the Apache License and the following modification to it:
41
41
 
42
42
  Section 6. Trademarks. is deleted and replaced with:
43
43
 
44
- 6\. Trademarks. This License does not grant permission to use the trade
45
- names, trademarks, service marks, or product names of the Licensor
46
- and its affiliates, except as required to comply with Section 4(c) of
47
- the License and to reproduce the content of the NOTICE file.
44
+ > 6\. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor and its affiliates, except as required to comply with Section 4(c) of the License and to reproduce the content of the NOTICE file.
48
45
 
49
46
  You may obtain a copy of the Apache License at
50
47
 
data/bin/d3 CHANGED
@@ -59,6 +59,9 @@ class App
59
59
  # the following d3 commands need a connection to the server
60
60
  ACTIONS_NEEDING_SERVER = D3::Client::ACTIONS.select{|k,v| v[:needs_connection] }
61
61
 
62
+ # these actions can be done w/o being root, by default, actions need root
63
+ ACTIONS_OK_WO_ROOT = D3::Client::ACTIONS.select{|k,v| v[:needs_root] == false }
64
+
62
65
  ### set up
63
66
  ###
64
67
  def initialize(args)
@@ -89,7 +92,7 @@ class App
89
92
 
90
93
  # otherwise, yell if we need to be root.
91
94
  else
92
- raise D3::PermissionError, "You must be root to use d3." unless [:help, :version].include? @action
95
+ raise D3::PermissionError, "You must be root to do that with d3." unless ACTIONS_OK_WO_ROOT.include? @action
93
96
  end #if root
94
97
 
95
98
  # bail if the jamf binary isn't installed
@@ -149,6 +152,9 @@ class App
149
152
  ###
150
153
  def parse_cli
151
154
 
155
+ # Debugging file? if so, always set debug.
156
+ ARGV << "--debug" if D3::DEBUG_FILE.exist?
157
+
152
158
  # when finished, this leaves the d3 command and its arg in ARGV
153
159
  opts = GetoptLong.new( *D3::Client::OPTIONS.values.map{|opt| opt[:cli]} )
154
160
 
data/bin/d3admin CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/ruby
2
-
3
2
  ### Copyright 2016 Pixar
4
3
  ###
5
4
  ### Licensed under the Apache License, Version 2.0 (the "Apache License")
@@ -135,6 +134,9 @@ class App
135
134
  ###
136
135
  def parse_commandline
137
136
 
137
+ # Debugging file? if so, always set debug.
138
+ ARGV << "--debug" if D3::DEBUG_FILE.exist?
139
+
138
140
  # this holds everything that comes from the commandline
139
141
  # or from prompting the user
140
142
  @options = OpenStruct.new
@@ -245,7 +247,7 @@ class App
245
247
  else
246
248
  raise ArgumentError, "--reboot must be 'y' or 'n'"
247
249
  end
248
-
250
+
249
251
  when '--remove-first'
250
252
  # dft is no, so if arg is empty or /^n(o)$/i, it should be nil,
251
253
  # otherwise must be /^y(es)$/i
@@ -256,7 +258,7 @@ class App
256
258
  else
257
259
  raise ArgumentError, "--remove-first must be 'y' or 'n'"
258
260
  end
259
-
261
+
260
262
  when '--removable'
261
263
  # dft is yes, so if arg is empty or /^y(es)$/i, it should be nil,
262
264
  # otherwise must be /^n(o)$/i
@@ -267,7 +269,7 @@ class App
267
269
  else
268
270
  raise ArgumentError, "--removable must be 'y' or 'n'"
269
271
  end
270
-
272
+
271
273
  when '--oses'
272
274
  @options.oses = arg
273
275
  when '--expiration'
data/bin/d3helper CHANGED
@@ -72,7 +72,11 @@ class App
72
72
  ### and set up the infrasctructure. No actual processing/error checking
73
73
  ### until the run method is called.
74
74
  ###
75
- def initialize(args)
75
+ def initialize
76
+
77
+ # Debugging file? if so, always set debug.
78
+ ARGV << "--debug" if D3::DEBUG_FILE.exist?
79
+
76
80
  opts = GetoptLong.new(
77
81
  [ '--help', '-h', '-H', GetoptLong::NO_ARGUMENT ],
78
82
  [ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
@@ -275,18 +279,18 @@ Watch a parade of cute puppies while these items are installed:
275
279
  # this is an array of current d3 receipt ids
276
280
  d3_rcpt_ids = D3::Client::Receipt.all.values.map{|r| r.id}
277
281
 
278
- now = Time.now
279
-
280
282
  JSS::Client.receipts.each do |jss_rcpt|
281
283
 
282
284
 
283
- # jss_rcpt is a Pathname object, the rcpt name is the paths basename
285
+ # jss_rcpt is a Pathname object, the rcpt name is the path's basename
284
286
  jss_rcpt_name = jss_rcpt.basename.to_s
285
287
 
286
288
  # do we have a match?
287
289
  pkg_id = d3_pkg_filenames[jss_rcpt_name]
288
- # if not, the filename might end with .zip, but the rcpt name doesnt
290
+
291
+ # if not, the filename might end with .zip, but the rcpt name doesn't
289
292
  pkg_id ||= d3_pkg_filenames[jss_rcpt_name + ".zip"]
293
+
290
294
  # if still not, this jss recipt doesn't point to a d3 package.
291
295
  next unless pkg_id
292
296
 
@@ -297,6 +301,7 @@ Watch a parade of cute puppies while these items are installed:
297
301
  # If we're here, we need to import the receipt, so get the matching D3
298
302
  # package and make a receipt from it.
299
303
  D3.log "Importing Casper Receipt #{jss_rcpt_name}", :warn
304
+
300
305
  begin
301
306
  d3_pkg = D3::Package.new id: pkg_id
302
307
 
@@ -312,11 +317,11 @@ Watch a parade of cute puppies while these items are installed:
312
317
  :basename => d3_pkg.basename,
313
318
  :version => d3_pkg.version,
314
319
  :revision => d3_pkg.revision,
315
- :admin => D3::AUTO_INSTALL_ADMIN,
320
+ :admin => "imported-from-casper",
316
321
  :id => d3_pkg.id,
317
322
  :status => d3_pkg.status ,
318
323
  :jamf_rcpt_file => jss_rcpt,
319
- :apple_pkg_ids => nil,
324
+ :apple_pkg_ids => d3_pkg.apple_receipt_data.map{|rd| rd[:apple_pkg_id]},
320
325
  :installed_at => jss_rcpt.mtime,
321
326
  :removable => d3_pkg.removable,
322
327
  :expiration => d3_pkg.expiration,
@@ -326,14 +331,15 @@ Watch a parade of cute puppies while these items are installed:
326
331
  :post_remove_script_id => d3_pkg.post_remove_script_id
327
332
  )
328
333
  D3::Client::Receipt.add_receipt d3_rcpt, :replace
329
- D3.log "Done. Imported Casper Receipt #{jss_rcpt_name}", :warn
330
334
  rescue
331
335
  D3.log "ERROR importing Casper Receipt #{jss_rcpt_name}: #{$!}", :error
332
336
  end
333
337
 
334
- D3.log "Done importing Casper Receipts for packages in d3", :warn
335
338
 
336
339
  end #JSS::Client.receipts.each do |jss_rcpt|
340
+ D3.log "Done importing Casper Receipts for packages in d3", :warn
341
+
342
+
337
343
  end #import_receipts
338
344
 
339
345
  end # class App
@@ -344,7 +350,7 @@ end # class App
344
350
  ############
345
351
  begin
346
352
  app = nil
347
- app = App.new(ARGV)
353
+ app = App.new
348
354
  app.run
349
355
  exit 0
350
356
  rescue
data/lib/d3/admin/add.rb CHANGED
@@ -22,9 +22,13 @@
22
22
  ###
23
23
  ###
24
24
 
25
-
25
+ ###
26
26
  module D3
27
27
  module Admin
28
+
29
+ ### The Admin::Add modile contains constants and methods related to
30
+ ### adding packages to d3 via d3admin.
31
+ ###
28
32
  module Add
29
33
  extend self
30
34
 
data/lib/d3/admin/auth.rb CHANGED
@@ -22,7 +22,7 @@
22
22
  ###
23
23
  ###
24
24
 
25
-
25
+ ###
26
26
  module D3
27
27
  module Admin
28
28
 
data/lib/d3/admin/edit.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  module Admin
28
29
  module Edit
data/lib/d3/admin/help.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  module Admin
28
29
  # This just exists to get the very lengthy help texts out of the d3admin and
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  module Admin
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  module Admin
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  module Admin
@@ -22,6 +22,9 @@
22
22
  ###
23
23
  ###
24
24
 
25
+
26
+
27
+ ###
25
28
  module D3
26
29
  module Admin
27
30
  module Report
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  module Admin
@@ -22,6 +22,7 @@
22
22
  ###
23
23
  ###
24
24
 
25
+ ###
25
26
  module D3
26
27
  module Admin
27
28
 
data/lib/d3/admin.rb CHANGED
@@ -23,8 +23,12 @@
23
23
  ###
24
24
 
25
25
 
26
-
26
+ ###
27
27
  module D3
28
+
29
+ ### D3::Admin provides the inner-workings of the d3admin command.
30
+ ### See the various submodules, and d3admin itself, for details.
31
+ ###
28
32
  module Admin
29
33
 
30
34
  end # module Admin
@@ -40,3 +44,4 @@ require "d3/admin/options"
40
44
  require "d3/admin/prefs"
41
45
  require "d3/admin/report"
42
46
  require "d3/admin/validate"
47
+
data/lib/d3/basename.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  ###
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  class Client < JSS::Client
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Client < JSS::Client
28
29
 
@@ -75,11 +76,16 @@ module D3
75
76
  end # unless options.force
76
77
 
77
78
  if curr_rcpt
78
- D3.log("Un-freezing #{curr_rcpt.edition} by installing #{desired_pkg.edition} manually", :warn) if curr_rcpt.frozen?
79
- D3.log("Updating #{curr_rcpt.edition}(#{curr_rcpt.status}) by installing #{desired_pkg.edition} manually", :warn) unless curr_rcpt.live?
80
- end # if curr rcpt
79
+ D3.log("Un-freezing #{curr_rcpt.edition} by installing #{desired_pkg.edition}", :warn) if curr_rcpt.frozen?
81
80
 
82
- installing = desired_pkg.live? ? "currently live #{desired_pkg.basename}" : "#{desired_pkg.edition} (#{desired_pkg.status})"
81
+ if desired_pkg.id == curr_rcpt.id
82
+ D3.log("Re-installing #{desired_pkg.edition}(#{desired_pkg.status})", :warn)
83
+ elsif desired_pkg.id < curr_rcpt.id
84
+ D3.log("Rolling back #{curr_rcpt.edition}(#{curr_rcpt.status}) to #{desired_pkg.edition}(#{desired_pkg.status})", :warn)
85
+ else
86
+ D3.log("Updating #{curr_rcpt.edition}(#{curr_rcpt.status}) to #{desired_pkg.edition}(#{desired_pkg.status})", :warn)
87
+ end
88
+ end # if curr rcpt
83
89
 
84
90
  desired_pkg.install(
85
91
  :force => options.force,
@@ -92,7 +98,7 @@ module D3
92
98
 
93
99
  self.freeze_receipts([desired_pkg.basename]) if options.freeze_on_install
94
100
 
95
- D3.log "Finished installing #{installing}", :info
101
+ D3.log "Finished installing #{desired_pkg.edition}(#{desired_pkg.status})", :info
96
102
 
97
103
  rescue JSS::MissingDataError, JSS::NoSuchItemError, JSS::InvalidDataError, D3::InstallError
98
104
  D3.log "Skipping installation of #{pkg_to_search}:\n #{$!}", :error
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Client < JSS::Client
28
29
 
data/lib/d3/client/cli.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Client < JSS::Client
28
29
 
@@ -74,22 +75,27 @@ module D3
74
75
  list_installed: {
75
76
  :aka => :li,
76
77
  :help => "list all installed d3 pkgs on this machine",
78
+ :needs_root => false
77
79
  },
78
80
  list_manual: {
79
81
  :aka => :lm,
80
82
  :help => "list all d3 pkgs on this machine not auto-installed",
83
+ :needs_root => false
81
84
  },
82
85
  list_pilots: {
83
86
  :aka => :lp,
84
87
  :help => "list pkgs currently in pilot on this machine",
88
+ :needs_root => false
85
89
  },
86
90
  list_frozen: {
87
91
  :aka => :lf,
88
92
  :help => "list pkgs currently frozen on this machine",
93
+ :needs_root => false
89
94
  },
90
95
  list_puppies: {
91
96
  :aka => :lq,
92
97
  :help => "list any queued pkgs awaiting puppytime at logout",
98
+ :needs_root => false
93
99
  },
94
100
  list_details: {
95
101
  :aka => :ld,
@@ -100,7 +106,7 @@ module D3
100
106
  list_files: {
101
107
  :aka => :ls,
102
108
  :help => "list the files installed by the given editions",
103
- :arg => :"basename or edition",
109
+ :arg => :"basename or edition" ,
104
110
  :needs_connection => true
105
111
  },
106
112
  query_file: {
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  class Client < JSS::Client
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Client < JSS::Client
28
29
  module Help
@@ -23,12 +23,17 @@
23
23
  ###
24
24
 
25
25
 
26
- ### client/lists.rb
27
- ###
28
- ### Methods related to the display of lists via the d3 client tool
29
- ###
30
26
 
27
+
28
+ ###
31
29
  module D3
30
+
31
+ ### client/lists.rb
32
+ ###
33
+ ### Methods related to the display of lists via the d3 client tool
34
+ ###
35
+
36
+
32
37
  class Client < JSS::Client
33
38
 
34
39
  ### list installed d3 items.
@@ -22,6 +22,9 @@
22
22
  ###
23
23
  ###
24
24
 
25
+
26
+
27
+ ###
25
28
  module D3
26
29
  class Client < JSS::Client
27
30
 
@@ -288,9 +291,10 @@ module D3
288
291
  end # if
289
292
  end # unless replace
290
293
 
294
+ replacing = @@installed_rcpts[receipt.basename] ? true : false
291
295
  @@installed_rcpts[receipt.basename] = receipt
292
296
  self.save_receipts
293
- D3.log "#{replace ? "Replaced" : "Added"} receipt for #{receipt.edition}", :info
297
+ D3.log "#{replacing ? "Replaced" : "Added"} receipt for #{receipt.edition}", :info
294
298
 
295
299
  ensure
296
300
  # always release the rw lock even after an error
data/lib/d3/client.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  ### This class represents a d3 client, a computer managed
@@ -22,6 +22,7 @@
22
22
  ###
23
23
  ###
24
24
 
25
+
25
26
  ###
26
27
  module D3
27
28
 
data/lib/d3/constants.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  #####################################
@@ -57,4 +58,9 @@ module D3
57
58
  # reports can take a long time to generate, lets set the timeout to a long time.
58
59
  REPORT_CONNECTION_TIMEOUT = 3600
59
60
 
61
+ # when this file exists, d3, d3admin are set to debug mode. This is
62
+ # useful when you have a d3 command embedded in some other tool, but need to get
63
+ # debug logging.
64
+ DEBUG_FILE = Pathname.new "/tmp/d3debug-on"
65
+
60
66
  end # module
data/lib/d3/database.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  module Database
data/lib/d3/exceptions.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  class InstallError < RuntimeError ; end
data/lib/d3/log.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
  ### Log a message to the d3 log, possibly sending it to stderr as well.
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,8 +23,11 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
28
+
27
29
  class Package < JSS::Package
30
+
28
31
  ################# Instance Attributes #################
29
32
 
30
33
  ### Note - I was tempted to set these up programmatically
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -207,7 +208,7 @@ module D3
207
208
  @@filenames = nil if refresh
208
209
  return @@filenames if @@filenames
209
210
  @@filenames = {}
210
- qr = JSS::DB_CNX.db.query "SELECT package_id, file_name FROM packages"
211
+ qr = JSS::DB_CNX.db.query "SELECT package_id, file_name FROM packages WHERE package_id IN (SELECT package_id FROM #{D3::Package::P_TABLE[:table_name]})"
211
212
  qr.each_hash{|p| @@filenames[p["package_id"].to_i] = p["file_name"]}
212
213
  qr.free
213
214
  @@filenames
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,8 +23,10 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
29
+
28
30
  ################# Constructor #################
29
31
 
30
32
  ### Existing d3 pkgs are looked up by providing :id, :name,
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  class Package < JSS::Package
28
29
 
@@ -65,7 +66,7 @@ module D3
65
66
  ###
66
67
  def check_for_exclusions
67
68
  excl_grps = D3::Client.computer_groups & @excluded_groups
68
- raise D3::InstallError, "This machine is excluded for #{desired_pkg.edition}. Use --force if needed." unless excl_grps.empty?
69
+ raise D3::InstallError, "This machine is excluded for #{edition}. Use --force if needed." unless excl_grps.empty?
69
70
  return true
70
71
  end # check for exclusions
71
72
 
data/lib/d3/package.rb CHANGED
@@ -22,9 +22,11 @@
22
22
  ###
23
23
  ###
24
24
 
25
+
26
+
27
+ ###
25
28
  module D3
26
29
 
27
- ###
28
30
  ### Package - A JSS::Package that can be installed and maintained by d3
29
31
  ###
30
32
  class Package < JSS::Package
@@ -23,22 +23,14 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
28
+
27
29
  module PuppyTime
28
30
 
29
31
  ###
30
32
  ### PendingPuppy - a d3 pkg awaiting installation during puppytime.
31
33
  ###
32
- ### We don't need much data about the pkg to be installed
33
- ### These are required in the args:
34
- ### :basename
35
- ### :version
36
- ### :revision
37
- ### :admin
38
- ### :status
39
- ### These are optional:
40
- ### :force - use force when installing
41
- ###
42
34
  class PendingPuppy
43
35
 
44
36
  ################# Mixin Modules #################
@@ -60,8 +52,15 @@ module D3
60
52
 
61
53
  ################# Constructor #################
62
54
 
63
- ###
64
- ###
55
+ ### We don't need much data about the pkg to be installed
56
+ ### These are required in the args:
57
+ ### :basename
58
+ ### :version
59
+ ### :revision
60
+ ### :admin
61
+ ### :status
62
+ ### These are optional:
63
+ ### :force - use force when installing
65
64
  ###
66
65
  def initialize (args = {})
67
66
  raise JSS::MissingDataError, "Puppies need a :basename" unless args[:basename]
@@ -85,6 +84,9 @@ module D3
85
84
  end # init
86
85
 
87
86
  ### Install this puppy
87
+ ###
88
+ ### @return [void]
89
+ ###
88
90
  def install
89
91
 
90
92
  begin # for ensure
@@ -101,8 +103,6 @@ module D3
101
103
  end
102
104
  end # install
103
105
 
104
-
105
-
106
106
  end #class PendingPuppy
107
107
  end # module puppytime
108
108
  end #module D3
@@ -23,9 +23,12 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
  module PuppyTime
29
+
28
30
  ### PuppyQ - the current queue of pending puppy installs.
31
+ ###
29
32
  ### This class only has one real value: A hash of
30
33
  ### PendingPuppy objects, keyed by basename.
31
34
  ### But, PendingPuppies can be added and removed
@@ -45,6 +48,7 @@ module D3
45
48
 
46
49
  ################# Class Methods #################
47
50
 
51
+
48
52
  ################# Attributes #################
49
53
 
50
54
  # the queue of PendingPuppy objects
@@ -77,11 +81,13 @@ module D3
77
81
 
78
82
  ### Save the current q out to disk
79
83
  ###
84
+ ### @return [void]
85
+ ###
80
86
  def save_q
81
87
  D3.log "Saving puppy queue", :debug
82
88
  if @q.empty?
83
89
  D3.log "Puppy queue is empty, deleting from disk", :debug
84
- QUEUE_FILE.delete
90
+ QUEUE_FILE.delete if QUEUE_FILE.exist?
85
91
  else
86
92
  QUEUE_FILE.jss_save YAML.dump(@q)
87
93
  D3.log "Puppy queue saved to disk", :debug
@@ -89,6 +95,8 @@ module D3
89
95
 
90
96
  end # save_q
91
97
 
98
+ ### An array of basenames for all pending puppies.
99
+ ###
92
100
  ### @return [Array<String>] the basenames of the pending puppies
93
101
  ###
94
102
  def pups
data/lib/d3/puppytime.rb CHANGED
@@ -25,13 +25,12 @@
25
25
  require 'd3/puppytime/pending_puppy'
26
26
  require 'd3/puppytime/puppy_queue'
27
27
 
28
-
29
-
28
+ ###
30
29
  module D3
31
30
 
32
- # Constants and methods for PuppyTime, which installs the pkgs listed in the
33
- # PuppyQueue at logout.
34
- #
31
+ ### Constants and methods for PuppyTime, which installs the pkgs listed in the
32
+ ### PuppyQueue at logout.
33
+ ###
35
34
  module PuppyTime
36
35
 
37
36
  ################# Module Constants #################
data/lib/d3/state.rb CHANGED
@@ -23,22 +23,25 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
- # this will be set to true when we finish loading
29
- @@loaded = false
30
-
29
+ ### is the module fully loaded?
30
+ ###
31
+ ### @return [Boolean]
32
+ ###
31
33
  def self.loaded?
32
34
  @@loaded
33
35
  end
34
36
 
35
- # This stores the current level of log messages
36
- # sent to stdout. See
37
- # D3::Log.level to set the level for messages
38
- # sent to the log.
39
- # @return [Integer]
37
+ ### This stores the current level of log messages sent to stdout. See
38
+ ### D3::Log.level to set the level for messages sent to the log.
39
+ ###
40
40
  @@verbosity = D3::Log::DFT_VERBOSITY
41
41
 
42
+ ### The current verbosity level
43
+ ### @return [Integer]
44
+ ###
42
45
  def self.verbosity
43
46
  @@verbosity
44
47
  end
@@ -63,23 +66,35 @@ module D3
63
66
  end
64
67
 
65
68
 
66
- # have we been asked to be forceful, and perform
67
- # unnatural acts?
68
- # Force is used in many different was in many places
69
- # so we'll store it here and anything can access it
70
- # using D3::force, D3::unforce, and D3::forced?
69
+ ### Have we been asked to be forceful, and perform
70
+ ### unnatural acts?
71
+ ### Force is used in many different was in many places
72
+ ### so we'll store it here and anything can access it
73
+ ### using D3::force, D3::unforce, and D3::forced?
71
74
  @@force = false
72
75
 
76
+ ### Turn on force, module-wide
77
+ ###
78
+ ### @return [void]
79
+ ###
73
80
  def self.force
74
81
  @@force = true
75
82
  D3::Client.set_env :force
76
83
  end
77
84
 
85
+ ### Turn off force, module-wide
86
+ ###
87
+ ### @return [void]
88
+ ###
78
89
  def self.unforce
79
90
  @@force = false
80
91
  D3::Client.unset_env :force
81
92
  end
82
93
 
94
+ ### Is force turned on, module-wide?
95
+ ###
96
+ ### @return [Boolean]
97
+ ###
83
98
  def self.forced?
84
99
  @@force
85
100
  end
@@ -95,6 +110,7 @@ module D3
95
110
  ### what hosts and usernames
96
111
  ###
97
112
  def self.connected?
113
+ return false unless loaded?
98
114
  return false unless JSS::API.connected? and JSS::DB_CNX.connected?
99
115
  return {
100
116
  :api => (JSS::API.cnx.options[:user] + "@" + JSS::API.cnx.options[:server]),
data/lib/d3/utility.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
28
 
28
29
 
@@ -37,10 +38,11 @@ module D3
37
38
  return false
38
39
  end #
39
40
 
40
- ### Try to figure out the login name of the admin
41
- ### running this code
41
+ ### Try to figure out the login name of the admin running this code
42
+ ###
43
+ ### @return [String] an admin name.
42
44
  ###
43
- def self.admin (refresh = false)
45
+ def self.admin
44
46
 
45
47
  no_good = self.badmins
46
48
 
@@ -59,8 +61,7 @@ module D3
59
61
  return admin
60
62
  end # get admin name
61
63
 
62
- ### The list of names not allowed as the --admin option in
63
- ### d3 and d3admin
64
+ ### The list of names not allowed as the --admin option in d3
64
65
  ###
65
66
  ### This just combines DISALLOWED_ADMINS and
66
67
  ### D3::CONFIG.client_prohibited_admin_names
@@ -83,15 +84,19 @@ module D3
83
84
  ### @return [boolean] Did the policy run?
84
85
  ###
85
86
  def self.run_policy (policy, type, verbose = false)
87
+
86
88
  D3.log "Running #{type} policy", :info
89
+
87
90
  # if numeric, and there's a policy with that id
88
91
  if policy =~ /^\d+$/ and polname = JSS::Policy.map_all_ids_to(:name)[policy]
89
92
  D3.log "Executing #{type} policy '#{polname}', id: #{policy}", :debug
90
93
  pol_to_run = "-id #{policy}"
94
+
91
95
  # if there's a policy with that name
92
96
  elsif polid = JSS::Policy.map_all_ids_to(:name).invert[policy]
93
97
  D3.log "Executing #{type} policy '#{policy}', id: #{polid}", :debug
94
98
  pol_to_run = "-id #{polid}"
99
+
95
100
  # else assume its a trigger
96
101
  else
97
102
  D3.log "Executing #{type} policy with trigger '#{policy}'", :debug
@@ -115,6 +120,7 @@ module D3
115
120
 
116
121
  ### Get the ids of all scripts used by all policies
117
122
  ### This is a hash of PolicyName => Array of Script id's
123
+ ###
118
124
  ### @return [Hash{String => Array<Integer>}]
119
125
  ###
120
126
  def self.policy_scripts
@@ -272,7 +278,7 @@ module D3
272
278
  ### This enhances Plist::parse_xml taking file paths, as well as XML Strings
273
279
  ### and reading the files regardless of binary/XML format.
274
280
  ###
275
- ### see JSS::parse_plsit
281
+ ### see JSS::parse_plist
276
282
  ### TODO - make all calls to this go directly to JSS.parse_plist
277
283
  ###
278
284
  ### @param plist[Pathname, String] the plist XML, or the path to a plist file
data/lib/d3/version.rb CHANGED
@@ -23,6 +23,7 @@
23
23
  ###
24
24
 
25
25
 
26
+ ###
26
27
  module D3
27
- VERSION = '3.0.8'
28
+ VERSION = '3.0.9'
28
29
  end # module
data/lib/d3.rb CHANGED
@@ -19,16 +19,24 @@
19
19
  ### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20
20
  ### KIND, either express or implied. See the Apache License for the specific
21
21
  ### language governing permissions and limitations under the Apache License.
22
- ###
23
- ###
22
+
23
+
24
+
25
+ ### The D3 module provides the foundation, and the guts, of d3. Most of the work
26
+ ### of the executables (d3, d3admin, d3helper, puppytime) is performed here. It
27
+ ### in turn, is built upon the JSS module, provided by the ruby-jss gem, for API
28
+ ### and MySQL access to the JSS.
29
+ module D3
30
+ # Set to true after all files are required
31
+ @@loaded = false
32
+ end
24
33
 
25
34
  #####################################
26
35
  # Required Libraries, etc
27
36
  #####################################
28
37
 
29
38
  ###################
30
- # gems
31
-
39
+ # Gems
32
40
  require 'jss'
33
41
  require 'keychain'
34
42
 
@@ -66,14 +74,10 @@ require 'd3/client'
66
74
  require 'd3/puppytime'
67
75
 
68
76
 
77
+ ###
69
78
  module D3
70
-
71
- ### we're loaded!
72
79
  @@loaded = true
73
-
74
- # Start logging
75
80
  D3.log "D3 module loaded, logging started", :debug
76
-
77
81
  end # module D3
78
82
 
79
83
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depot3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.8
4
+ version: 3.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lasell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-02 00:00:00.000000000 Z
11
+ date: 2016-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-keychain