puppet-classroom-manager 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/bin/classroom +1 -1
- data/lib/classroom/page.rb +1 -1
- data/lib/classroom/submit.rb +20 -36
- data/lib/classroom/version.rb +1 -1
- data/lib/classroom.rb +28 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79fd3d3fa437580cfd5c850e7a1c3b2300ab952a
|
4
|
+
data.tar.gz: 0ff0471bd323d9b7f02b1a1ed91675b8cc0b7a4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/classroom/page.rb
CHANGED
@@ -4,7 +4,7 @@ class Classroom
|
|
4
4
|
require 'rest-client'
|
5
5
|
|
6
6
|
begin
|
7
|
-
config =
|
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
|
data/lib/classroom/submit.rb
CHANGED
@@ -3,20 +3,20 @@ class Classroom
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'aws-sdk'
|
5
5
|
|
6
|
-
|
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
|
-
|
29
|
-
|
30
|
-
obj.
|
31
|
-
|
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
|
-
|
35
|
-
|
36
|
-
obj.
|
37
|
-
|
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
|
data/lib/classroom/version.rb
CHANGED
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.
|
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
|