puppet-classroom-manager 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af0e7af7ee77ab29d61058fa57eba4af51f44d2c
4
- data.tar.gz: fb770cff71763c9288217fde895d8f9cc70ed641
3
+ metadata.gz: 79fd3d3fa437580cfd5c850e7a1c3b2300ab952a
4
+ data.tar.gz: 0ff0471bd323d9b7f02b1a1ed91675b8cc0b7a4d
5
5
  SHA512:
6
- metadata.gz: 544f54aca8ad9b49f131c15d4491411656048de94b33b1e072ff64883b0f314d5fcd571164d73f95e760fc87b69b07ef0b8c52e8df8b7db965d89b30653a6403
7
- data.tar.gz: 624df6da7f0eaea5877211766fd02c2b76d89805146525b8e4334daf30653d8686f417867e1192256115ec75d80528b81969d3067a4af5fb74b129441956e068
6
+ metadata.gz: 7d239af624e0ab698c0df470deba2afb803d0b8ffef0657fe67c407fa4db763641b5ed0f48c5a015c2c02fa9bd821c20429a261832c5d819d3baeacd042f258c
7
+ data.tar.gz: af092cb9e071d9bb0d136b396214a6cb6930a63d85f12f10160c792a866e42e3a8525bfcc52913e452f88ff374da35c412f7031908075b87cfc90802e67d7200
data/CHANGELOG.md ADDED
@@ -0,0 +1,18 @@
1
+ ## v0.0.4
2
+ * Corrected page & submit behaviour
3
+ * Allowed for paging even when the classroom isn't yet configured
4
+
5
+ ## v0.0.3
6
+ * Use proper logger variable
7
+ * Warn when the pagerduty key doesn't exist
8
+ * Use curl instead of ping to validate forge connectivity
9
+ * Allow end user to specify desired contact info when paging
10
+ * Improve troubleshooting tasks
11
+
12
+ ## v0.0.2
13
+ * Added page task
14
+ * Reduced arbitrary verbosity
15
+ * Corrected dependencies
16
+
17
+ ## v0.0.1
18
+ * initial release
data/bin/classroom CHANGED
@@ -35,7 +35,7 @@ optparse = OptionParser.new { |opts|
35
35
 
36
36
  opts.on("-v", "--version", "Print out the version") do
37
37
  require 'classroom/version'
38
- puts Courseware::VERSION
38
+ puts Classroom::VERSION
39
39
  exit
40
40
  end
41
41
 
@@ -4,7 +4,7 @@ class Classroom
4
4
  require 'rest-client'
5
5
 
6
6
  begin
7
- config = JSON.parse(File.read('/opt/pltraining/etc/classroom.json'))
7
+ config = showoff_config
8
8
  pd_key = File.read('/opt/pltraining/etc/pagerduty.key').strip
9
9
  raise 'Missing PagerDuty key' if pd_key.empty?
10
10
  rescue => e
@@ -3,20 +3,20 @@ class Classroom
3
3
  require 'fileutils'
4
4
  require 'aws-sdk'
5
5
 
6
- if puppetlabs_instructor?
6
+ config = showoff_config
7
+ event_id = config['event_id']
8
+ course = config['course']
9
+
10
+ print 'Enter your Puppet email address: '
11
+ email = STDIN.gets.strip
12
+
13
+ if email =~ /@puppet(labs)?.com$/
7
14
  puts "Please go to your learn dashboard and ensure that attendance is accurate"
8
15
  puts "and then close this class delivery to mark it as complete."
9
16
  puts " -- #{@config[:learndot]}"
10
17
  puts
11
18
  end
12
19
 
13
- presentation = showoff_working_directory()
14
-
15
- data = JSON.parse(File.read("#{presentation}/stats/metadata.json")) rescue {}
16
- event_id = data['event_id'] || Time.now.to_i
17
- course = data['course'] || 'none'
18
- email = data['email'] || 'none'
19
-
20
20
  begin
21
21
  # depends on root's credentials as managed by bootstrap
22
22
  s3 = Aws::S3::Resource.new(region:'us-west-2')
@@ -25,16 +25,18 @@ class Classroom
25
25
  system("puppet module list > /var/log/puppetlabs/classroom-modules")
26
26
 
27
27
  filename = "classroom-perflogs-#{course}-#{email}-#{event_id}.tar.gz"
28
- system("tar -cf /var/cache/#{filename} /var/log/puppetlabs/")
29
- obj = s3.bucket(PERF_BUCKET).object(filename)
30
- obj.upload_file("/var/cache/#{filename}")
31
- FileUtils.rm(filename)
28
+ fullpath = "/var/cache/#{filename}"
29
+ system("tar -cf #{fullpath} /var/log/puppetlabs/")
30
+ obj = s3.bucket('classroom-performance').object(filename)
31
+ obj.upload_file(fullpath)
32
+ FileUtils.rm(fullpath)
32
33
 
33
34
  filename = "classroom-stats-#{course}-#{email}-#{event_id}.tar.gz"
34
- system("tar -cf /var/cache/#{filename} #{presentation}/stats/")
35
- obj = s3.bucket(STATS_BUCKET).object(filename)
36
- obj.upload_file("/var/cache/#{filename}")
37
- FileUtils.rm(filename)
35
+ fullpath = "/var/cache/#{filename}"
36
+ system("tar -cf #{fullpath} #{presentation}/stats/")
37
+ obj = s3.bucket('classroom-statistics').object(filename)
38
+ obj.upload_file(fullpath)
39
+ FileUtils.rm(fullpath)
38
40
 
39
41
  rescue LoadError, StandardError => e
40
42
  $logger.warn "S3 upload failed. No network?"
@@ -43,30 +45,12 @@ class Classroom
43
45
  end
44
46
 
45
47
  # clean up for next delivery
46
- system("puppet resource service showoff-courseware ensure=stopped")
48
+ system("puppet resource service showoff-courseware ensure=stopped > /dev/null")
47
49
  FileUtils.rm_rf("#{presentation}/stats")
48
50
  FileUtils.rm_f("#{presentation}/courseware.yaml")
49
51
  FileUtils.rm_f("#{presentation}/_files/share/nearby_events.html")
50
- system("puppet resource service showoff-courseware ensure=running")
51
-
52
- end
53
-
54
- def puppetlabs_instructor?
55
- # TODO: how do?
56
- false
57
- end
52
+ system("puppet resource service showoff-courseware ensure=running > /dev/null")
58
53
 
59
- def showoff_working_directory
60
- # get the path of the currently configured showoff presentation
61
- data = {}
62
- path = '/usr/lib/systemd/system/showoff-courseware.service'
63
- File.read(path).each_line do |line|
64
- setting = line.split('=')
65
- next unless setting.size == 2
66
-
67
- data[setting.first] = setting.last
68
- end
69
- data['WorkingDirectory']
70
54
  end
71
55
 
72
56
  end
@@ -1,3 +1,3 @@
1
1
  class Classroom
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
data/lib/classroom.rb CHANGED
@@ -42,6 +42,34 @@ class Classroom
42
42
  end
43
43
  end
44
44
 
45
+ def showoff_config
46
+ presentation = showoff_working_directory()
47
+ data = JSON.parse(File.read("#{presentation}/stats/metadata.json")) rescue {}
48
+
49
+ data['event_id'] ||= Time.now.to_i
50
+ data['course'] ||= File.basename(presentation.strip)
51
+ data
52
+ end
53
+
54
+ def showoff_working_directory
55
+ begin
56
+ # get the path of the currently configured showoff presentation
57
+ data = {}
58
+ path = '/usr/lib/systemd/system/showoff-courseware.service'
59
+ File.read(path).each_line do |line|
60
+ setting = line.split('=')
61
+ next unless setting.size == 2
62
+
63
+ data[setting.first] = setting.last
64
+ end
65
+ data['WorkingDirectory'].strip
66
+ rescue Errno::ENOENT => e
67
+ $logger.warn 'Cannot find classroom Showoff presentation'
68
+ $logger.debug e.message
69
+ 'unconfigured'
70
+ end
71
+ end
72
+
45
73
  def help
46
74
  require 'classroom/help'
47
75
  puts Classroom::HELP
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-classroom-manager
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
  - Ben Ford
@@ -107,6 +107,7 @@ executables:
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - CHANGELOG.md
110
111
  - LICENSE
111
112
  - README.md
112
113
  - bin/classroom