Merge lp:~mvo/snappy/15.04-modprobe-config into lp:~snappy-dev/snappy/15.04-deprecated

Proposed by Michael Vogt
Status: Merged
Approved by: Michael Vogt
Approved revision: 470
Merged at revision: 473
Proposed branch: lp:~mvo/snappy/15.04-modprobe-config
Merge into: lp:~snappy-dev/snappy/15.04-deprecated
Diff against target: 232 lines (+77/-0)
2 files modified
coreconfig/config.go (+33/-0)
coreconfig/config_test.go (+44/-0)
To merge this branch: bzr merge lp:~mvo/snappy/15.04-modprobe-config
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
John Lenton (community) Approve
Review via email: mp+270411@code.launchpad.net

Commit message

Add support for ubuntu-core.modprobe configuration.

Description of the change

This branch adds support for configuring ubuntu-core.modprobe which will be applied to /etc/modprobe.d/ubuntu-core-conf

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

missing the commit message!

Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :
Download full text (7.3 KiB)

The attempt to merge lp:~mvo/snappy/15.04-modprobe-config into lp:snappy/15.04 failed. Below is the output from the failed tests.

Checking formatting
Installing godeps
Install golint
Obtaining dependencies
update github.com/blakesmith/ar failed; trying to fetch newer version
update github.com/cheggaaa/pb failed; trying to fetch newer version
github.com/blakesmith/ar now at c9a977dd0cc1392b023382c7bfa5a22af8d3b730
update github.com/jessevdk/go-flags failed; trying to fetch newer version
github.com/cheggaaa/pb now at e8c7cc515bfde3e267957a3b110080ceed51354e
update github.com/mvo5/uboot-go failed; trying to fetch newer version
github.com/jessevdk/go-flags now at 15347ef417a300349807983f15af9e65cd2e1b3a
github.com/mvo5/uboot-go now at 361f6ebcbb54f389d15dc9faefa000e996ba3e37
update gopkg.in/check.v1 failed; trying to fetch newer version
update gopkg.in/yaml.v2 failed; trying to fetch newer version
gopkg.in/check.v1 now at 64131543e7896d5bcc6bd5a76287eb75ea96c673
update code.google.com/p/go.crypto failed; trying to fetch newer version
gopkg.in/yaml.v2 now at 49c95bdc21843256fb6c4e0d370a05f24a0bf213
update github.com/juju/loggo failed; trying to fetch newer version
code.google.com/p/go.crypto now at 69e2a90ed92d03812364aeb947b7068dc42e561e
update github.com/mvo5/goconfigparser failed; trying to fetch newer version
github.com/juju/loggo now at 4c7cbce140ca070eeb59a28f4bf9507e511711f9
github.com/mvo5/goconfigparser now at 26426272dda20cc76aa1fa44286dc743d2972fe8
Building
Running tests from /tmp/tmp.y7ug5Q2hWa/src/launchpad.net/snappy
=== RUN Test
OK: 10 passed
--- PASS: Test (0.50 seconds)
PASS
coverage: 79.3% of statements
ok launchpad.net/snappy/clickdeb 0.509s coverage: 79.3% of statements
=== RUN Test
OK: 6 passed
--- PASS: Test (0.54 seconds)
PASS
coverage: 12.5% of statements
ok launchpad.net/snappy/cmd/snappy 0.551s coverage: 12.5% of statements
=== RUN Test
OK: 26 passed
--- PASS: Test (0.06 seconds)
PASS
coverage: 96.7% of statements
ok launchpad.net/snappy/coreconfig 0.061s coverage: 96.7% of statements
=== RUN Test
OK: 33 passed
--- PASS: Test (13.92 seconds)
PASS
coverage: 74.0% of statements
ok launchpad.net/snappy/helpers 13.931s coverage: 74.0% of statements
=== RUN Test
OK: 7 passed
--- PASS: Test (0.04 seconds)
PASS
coverage: 92.5% of statements
ok launchpad.net/snappy/logger 0.046s coverage: 92.5% of statements
=== RUN Test
OK: 4 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.net/snappy/oauth 0.006s coverage: 100.0% of statements
=== RUN Test
OK: 40 passed
--- PASS: Test (1.02 seconds)
PASS
coverage: 80.3% of statements
ok launchpad.net/snappy/partition 1.039s coverage: 80.3% of statements
=== RUN Test
OK: 12 passed
--- PASS: Test (0.64 seconds)
PASS
coverage: 87.8% of statements
ok launchpad.net/snappy/policy 0.650s coverage: 87.8% of statements
=== RUN Test
OK: 3 passed
--- PASS: Test (0.04 seconds)
PASS
coverage: 84.8% of statements
ok launchpad.net/snappy/priv 0.054s coverage: 84.8% of statements
=== RUN Test
OK: 4 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 50.0% of statements
ok launchpad.net/snappy/progress 0.013s coverage: 50.0% of statements
=== RUN Test
OK...

Read more...

lp:~mvo/snappy/15.04-modprobe-config updated
470. By Michael Vogt

coreconfig/config.go: fix go vet

Revision history for this message
Michael Vogt (mvo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'coreconfig/config.go'
2--- coreconfig/config.go 2015-04-14 16:46:57 +0000
3+++ coreconfig/config.go 2015-09-11 16:00:39 +0000
4@@ -40,6 +40,10 @@
5 autopilotTimerDisabled string = "disabled"
6 )
7
8+var (
9+ modprobePath = "/etc/modprobe.d/ubuntu-core.conf"
10+)
11+
12 // ErrInvalidUnitStatus signals that a unit is not returning a status
13 // of "enabled" or "disabled".
14 var ErrInvalidUnitStatus = errors.New("invalid unit status")
15@@ -48,6 +52,7 @@
16 Autopilot *bool `yaml:"autopilot,omitempty"`
17 Timezone *string `yaml:"timezone,omitempty"`
18 Hostname *string `yaml:"hostname,omitempty"`
19+ Modprobe *string `yaml:"modprobe,omitempty"`
20 }
21
22 type coreConfig struct {
23@@ -73,11 +78,16 @@
24 if err != nil {
25 return nil, err
26 }
27+ modprobe, err := getModprobe()
28+ if err != nil {
29+ return nil, err
30+ }
31
32 config := &systemConfig{
33 Autopilot: &autopilot,
34 Timezone: &tz,
35 Hostname: &hostname,
36+ Modprobe: &modprobe,
37 }
38
39 return config, nil
40@@ -151,6 +161,14 @@
41 if err := setHostname(*newConfig.Hostname); err != nil {
42 return "", err
43 }
44+ case "Modprobe":
45+ if *oldConfig.Modprobe == *newConfig.Modprobe {
46+ continue
47+ }
48+
49+ if err := setModprobe(*newConfig.Modprobe); err != nil {
50+ return "", err
51+ }
52 }
53 }
54
55@@ -184,6 +202,21 @@
56 return ioutil.WriteFile(tzFile(), []byte(timezone), 0644)
57 }
58
59+// getModprobe returns the current modprobe config
60+var getModprobe = func() (string, error) {
61+ modprobe, err := ioutil.ReadFile(modprobePath)
62+ if err != nil && !os.IsNotExist(err) {
63+ return "", err
64+ }
65+
66+ return string(modprobe), nil
67+}
68+
69+// setModprobe sets the specified modprobe config
70+var setModprobe = func(modprobe string) error {
71+ return ioutil.WriteFile(modprobePath, []byte(modprobe), 0644)
72+}
73+
74 // for testing purposes
75 var (
76 cmdAutopilotEnabled = []string{"is-enabled", autopilotTimer}
77
78=== modified file 'coreconfig/config_test.go'
79--- coreconfig/config_test.go 2015-08-02 12:21:07 +0000
80+++ coreconfig/config_test.go 2015-09-11 16:00:39 +0000
81@@ -46,6 +46,7 @@
82 originalCmdAutopilotEnabled = cmdAutopilotEnabled
83 originalCmdSystemctl = cmdSystemctl
84 originalHostnamePath = hostnamePath
85+ originalModprobePath = modprobePath
86 )
87
88 type ConfigTestSuite struct {
89@@ -90,6 +91,7 @@
90 cmdStopAutopilot = originalCmdStopAutopilot
91 cmdAutopilotEnabled = originalCmdAutopilotEnabled
92 cmdSystemctl = originalCmdSystemctl
93+ modprobePath = originalModprobePath
94 }
95
96 // TestGet is a broad test, close enough to be an integration test for
97@@ -101,6 +103,7 @@
98 autopilot: false
99 timezone: America/Argentina/Cordoba
100 hostname: testhost
101+ modprobe: ""
102 `
103
104 rawConfig, err := Get()
105@@ -116,6 +119,7 @@
106 autopilot: true
107 timezone: America/Argentina/Mendoza
108 hostname: testhost
109+ modprobe: ""
110 `
111
112 cmdAutopilotEnabled = []string{"-c", "echo enabled"}
113@@ -132,6 +136,7 @@
114 autopilot: false
115 timezone: America/Argentina/Mendoza
116 hostname: testhost
117+ modprobe: ""
118 `
119
120 rawConfig, err := Set(expected)
121@@ -147,6 +152,7 @@
122 autopilot: true
123 timezone: America/Argentina/Cordoba
124 hostname: testhost
125+ modprobe: ""
126 `
127
128 enabled := false
129@@ -165,6 +171,7 @@
130 autopilot: false
131 timezone: America/Argentina/Cordoba
132 hostname: NEWtesthost
133+ modprobe: ""
134 `
135
136 rawConfig, err := Set(expected)
137@@ -178,6 +185,7 @@
138 autopilot: false
139 timezone America/Argentina/Mendoza
140 hostname: testhost
141+ modprobe: ""
142 `
143
144 rawConfig, err := Set(input)
145@@ -191,6 +199,7 @@
146 autopilot: false
147 timezone: America/Argentina/Cordoba
148 hostname: testhost
149+ modprobe: ""
150 `
151
152 rawConfig, err := Set(input)
153@@ -204,12 +213,14 @@
154 autopilot: false
155 timezone: America/Argentina/Cordoba
156 hostname: testhost
157+ modprobe: ""
158 `
159
160 input := `config:
161 ubuntu-core:
162 autopilot: false
163 timezone: America/Argentina/Cordoba
164+ modprobe: ""
165 `
166
167 rawConfig, err := Set(input)
168@@ -247,6 +258,7 @@
169 autopilot: false
170 timezone: America/Argentina/Mendoza
171 hostname: testhost
172+ modprobe: ""
173 `
174
175 rawConfig, err := Set(input)
176@@ -268,6 +280,7 @@
177 autopilot: true
178 timezone: America/Argentina/Mendoza
179 hostname: testhost
180+ modprobe: ""
181 `
182
183 enabled := false
184@@ -285,6 +298,7 @@
185 autopilot: false
186 timezone: America/Argentina/Cordoba
187 hostname: NEWtesthost
188+ modprobe: ""
189 `
190
191 setHostname = func(string) error { return errors.New("this is bad") }
192@@ -300,6 +314,7 @@
193 autopilot: false
194 timezone: America/Argentina/Cordoba
195 hostname: NEWtesthost
196+ modprobe: ""
197 `
198
199 getHostname = func() (string, error) { return "", errors.New("this is bad") }
200@@ -396,3 +411,32 @@
201 err := setHostname("newhostname")
202 c.Assert(err, DeepEquals, expectedErr)
203 }
204+
205+func (cts *ConfigTestSuite) TestModprobe(c *C) {
206+ modprobePath = filepath.Join(c.MkDir(), "test.conf")
207+
208+ err := setModprobe("blacklist floppy")
209+ c.Assert(err, IsNil)
210+
211+ modprobe, err := getModprobe()
212+ c.Assert(err, IsNil)
213+ c.Assert(modprobe, Equals, "blacklist floppy")
214+}
215+
216+func (cts *ConfigTestSuite) TestModprobeYaml(c *C) {
217+ modprobePath = filepath.Join(c.MkDir(), "test.conf")
218+
219+ input := `config:
220+ ubuntu-core:
221+ modprobe: |
222+ blacklist floppy
223+ softdep mlx4_core post: mlx4_en
224+`
225+ _, err := Set(input)
226+ c.Assert(err, IsNil)
227+
228+ // ensure its really there
229+ content, err := ioutil.ReadFile(modprobePath)
230+ c.Assert(err, IsNil)
231+ c.Assert(string(content), Equals, "blacklist floppy\nsoftdep mlx4_core post: mlx4_en\n")
232+}

Subscribers

People subscribed via source and target branches