Merge ~ltrager/maas:lp1727551 into maas:master

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 662194a9a318bbcb36e01d71390e72cfbf0f8f1e
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1727551
Merge into: maas:master
Diff against target: 222 lines (+67/-22)
3 files modified
src/metadataserver/builtin_scripts/hooks.py (+8/-4)
src/metadataserver/migrations/builtin/0014_rename_dhcp_unconfigured_ifaces.py (+27/-0)
src/provisioningserver/refresh/node_info_scripts.py (+32/-18)
Reviewer Review Type Date Requested Status
Newell Jensen (community) Approve
Blake Rouse (community) Approve
Review via email: mp+332874@code.launchpad.net

Commit message

LP: #1727551 - Rename ScriptResults named 00-maas-06-dhcp-unconfigured-ifaces to 00-maas-05-dhcp-unconfigured-ifaces

00-maas-06-dhcp-unconfigured-ifaces was previously renamed
00-maas-05-dhcp-unconfigured-ifaces. This only effected future runs of the
script, previous results still had the same name. This caused both the old and
new version to be shown in the UI. This adds a migration to rename
ScriptResults using the old name.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Was reviewing as well. LGTM.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/metadataserver/builtin_scripts/hooks.py b/src/metadataserver/builtin_scripts/hooks.py
2index f7aac91..b14ad13 100644
3--- a/src/metadataserver/builtin_scripts/hooks.py
4+++ b/src/metadataserver/builtin_scripts/hooks.py
5@@ -27,11 +27,15 @@ from maasserver.models.switch import Switch
6 from maasserver.models.tag import Tag
7 from maasserver.utils.orm import get_one
8 from provisioningserver.refresh.node_info_scripts import (
9+ BLOCK_DEVICES_OUTPUT_NAME,
10+ CPUINFO_OUTPUT_NAME,
11 GET_FRUID_DATA_OUTPUT_NAME,
12 IPADDR_OUTPUT_NAME,
13 LIST_MODALIASES_OUTPUT_NAME,
14 LSHW_OUTPUT_NAME,
15 NODE_INFO_SCRIPTS,
16+ SRIOV_OUTPUT_NAME,
17+ VIRTUALITY_OUTPUT_NAME,
18 )
19 from provisioningserver.utils.ipaddr import parse_ip_addr
20
21@@ -688,15 +692,15 @@ def retag_node_for_hardware_by_modalias(
22
23 # Register the post processing hooks.
24 NODE_INFO_SCRIPTS[LSHW_OUTPUT_NAME]['hook'] = update_hardware_details
25-NODE_INFO_SCRIPTS['00-maas-01-cpuinfo']['hook'] = parse_cpuinfo
26-NODE_INFO_SCRIPTS['00-maas-02-virtuality']['hook'] = set_virtual_tag
27+NODE_INFO_SCRIPTS[CPUINFO_OUTPUT_NAME]['hook'] = parse_cpuinfo
28+NODE_INFO_SCRIPTS[VIRTUALITY_OUTPUT_NAME]['hook'] = set_virtual_tag
29 NODE_INFO_SCRIPTS[GET_FRUID_DATA_OUTPUT_NAME]['hook'] = (
30 update_node_fruid_metadata)
31-NODE_INFO_SCRIPTS['00-maas-07-block-devices']['hook'] = (
32+NODE_INFO_SCRIPTS[BLOCK_DEVICES_OUTPUT_NAME]['hook'] = (
33 update_node_physical_block_devices)
34 NODE_INFO_SCRIPTS[IPADDR_OUTPUT_NAME]['hook'] = (
35 update_node_network_information)
36-NODE_INFO_SCRIPTS['99-maas-04-network-interfaces-with-sriov']['hook'] = (
37+NODE_INFO_SCRIPTS[SRIOV_OUTPUT_NAME]['hook'] = (
38 update_node_network_interface_tags)
39 NODE_INFO_SCRIPTS[LIST_MODALIASES_OUTPUT_NAME]['hook'] = (
40 create_metadata_by_modalias)
41diff --git a/src/metadataserver/migrations/builtin/0014_rename_dhcp_unconfigured_ifaces.py b/src/metadataserver/migrations/builtin/0014_rename_dhcp_unconfigured_ifaces.py
42new file mode 100644
43index 0000000..5e4ec34
44--- /dev/null
45+++ b/src/metadataserver/migrations/builtin/0014_rename_dhcp_unconfigured_ifaces.py
46@@ -0,0 +1,27 @@
47+# -*- coding: utf-8 -*-
48+from __future__ import unicode_literals
49+
50+from django.db import (
51+ migrations,
52+ models,
53+)
54+
55+
56+def rename_dhcp_unconfigured_ifaces(apps, schema_editor):
57+ # Fixes LP: 1727551
58+ ScriptResult = apps.get_model('metadataserver', 'ScriptResult')
59+ for script_result in ScriptResult.objects.filter(
60+ script_name='00-maas-06-dhcp-unconfigured-ifaces'):
61+ script_result.script_name = '00-maas-05-dhcp-unconfigured-ifaces'
62+ script_result.save()
63+
64+
65+class Migration(migrations.Migration):
66+
67+ dependencies = [
68+ ('metadataserver', '0013_scriptresult_physicalblockdevice'),
69+ ]
70+
71+ operations = [
72+ migrations.RunPython(rename_dhcp_unconfigured_ifaces),
73+ ]
74diff --git a/src/provisioningserver/refresh/node_info_scripts.py b/src/provisioningserver/refresh/node_info_scripts.py
75index ace1ea5..b913cc1 100644
76--- a/src/provisioningserver/refresh/node_info_scripts.py
77+++ b/src/provisioningserver/refresh/node_info_scripts.py
78@@ -4,12 +4,21 @@
79 """Builtin node info scripts."""
80
81 __all__ = [
82+ 'BLOCK_DEVICES_OUTPUT_NAME',
83+ 'CPUINFO_OUTPUT_NAME',
84+ 'DHCP_EXPLORE_OUTPUT_NAME',
85 'GET_FRUID_DATA_OUTPUT_NAME',
86 'IPADDR_OUTPUT_NAME',
87- 'NODE_INFO_SCRIPTS',
88+ 'IPADDR_OUTPUT_NAME',
89 'LIST_MODALIASES_OUTPUT_NAME',
90+ 'LLDP_INSTALL_OUTPUT_NAME',
91 'LLDP_OUTPUT_NAME',
92 'LSHW_OUTPUT_NAME',
93+ 'NODE_INFO_SCRIPTS',
94+ 'SERIAL_PORTS_OUTPUT_NAME',
95+ 'SRIOV_OUTPUT_NAME',
96+ 'SUPPORT_INFO_OUTPUT_NAME',
97+ 'VIRTUALITY_OUTPUT_NAME',
98 ]
99
100 from collections import OrderedDict
101@@ -19,14 +28,23 @@ import json
102 import os
103 from textwrap import dedent
104
105-# Name of the file where the node info scripts store lshw output.
106+# The name of the script, used throughout MAAS for data processing. Any script
107+# which is renamed will require a migration otherwise the user will see both
108+# the old name and new name as two seperate scripts. See
109+# 0014_rename_dhcp_unconfigured_ifaces.py
110+SUPPORT_INFO_OUTPUT_NAME = '00-maas-00-support-info'
111 LSHW_OUTPUT_NAME = '00-maas-01-lshw'
112-
113-# Name of the file where the node info scripts store LLDP output.
114+CPUINFO_OUTPUT_NAME = '00-maas-01-cpuinfo'
115+VIRTUALITY_OUTPUT_NAME = '00-maas-02-virtuality'
116+LLDP_INSTALL_OUTPUT_NAME = '00-maas-03-install-lldpd'
117+LIST_MODALIASES_OUTPUT_NAME = '00-maas-04-list-modaliases'
118+DHCP_EXPLORE_OUTPUT_NAME = '00-maas-05-dhcp-unconfigured-ifaces'
119+GET_FRUID_DATA_OUTPUT_NAME = '00-maas-06-get-fruid-api-data'
120+BLOCK_DEVICES_OUTPUT_NAME = '00-maas-07-block-devices'
121+SERIAL_PORTS_OUTPUT_NAME = '00-maas-08-serial-ports'
122 LLDP_OUTPUT_NAME = '99-maas-02-capture-lldp'
123-
124-# Name of the file where the node info scripts store ip addr output.
125 IPADDR_OUTPUT_NAME = '99-maas-03-network-interfaces'
126+SRIOV_OUTPUT_NAME = '99-maas-04-network-interfaces-with-sriov'
127
128
129 def make_function_call_script(function, *args, **kwargs):
130@@ -393,14 +411,12 @@ def lldpd_capture(reference_file, time_delay):
131 check_call(("lldpctl", "-f", "xml"))
132
133
134-LIST_MODALIASES_OUTPUT_NAME = '00-maas-04-list-modaliases'
135 LIST_MODALIASES_SCRIPT = dedent("""\
136 #!/bin/bash
137 find /sys -name modalias -print0 | xargs -0 cat | sort -u
138 """)
139
140
141-GET_FRUID_DATA_OUTPUT_NAME = '00-maas-06-get-fruid-api-data'
142 GET_FRUID_DATA_SCRIPT = dedent("""\
143 #!/bin/bash
144 # Do not fail commissioning if this fails.
145@@ -414,7 +430,6 @@ GET_FRUID_DATA_SCRIPT = dedent("""\
146 fi
147 done
148 """)
149-GET_FRUID_DATA_PACKAGES = {'apt': ['curl']}
150
151
152 def gather_physical_block_devices(dev_disk_byid='/dev/disk/by-id/'):
153@@ -601,7 +616,7 @@ def null_hook(node, output, exit_status):
154 # maasserver/status_monitor.py adds 1 minute to the timeout of all scripts for
155 # cleanup and signaling.
156 NODE_INFO_SCRIPTS = OrderedDict([
157- ('00-maas-00-support-info', {
158+ (SUPPORT_INFO_OUTPUT_NAME, {
159 'content': SUPPORT_SCRIPT.encode('ascii'),
160 'hook': null_hook,
161 'timeout': timedelta(minutes=5),
162@@ -613,19 +628,19 @@ NODE_INFO_SCRIPTS = OrderedDict([
163 'timeout': timedelta(minutes=5),
164 'run_on_controller': True,
165 }),
166- ('00-maas-01-cpuinfo', {
167+ (CPUINFO_OUTPUT_NAME, {
168 'content': CPUINFO_SCRIPT.encode('ascii'),
169 'hook': null_hook,
170 'timeout': timedelta(seconds=10),
171 'run_on_controller': True,
172 }),
173- ('00-maas-02-virtuality', {
174+ (VIRTUALITY_OUTPUT_NAME, {
175 'content': VIRTUALITY_SCRIPT.encode('ascii'),
176 'hook': null_hook,
177 'timeout': timedelta(seconds=10),
178 'run_on_controller': True,
179 }),
180- ('00-maas-03-install-lldpd', {
181+ (LLDP_INSTALL_OUTPUT_NAME, {
182 'content': make_function_call_script(
183 lldpd_install, config_file="/etc/default/lldpd"),
184 'hook': null_hook,
185@@ -639,7 +654,7 @@ NODE_INFO_SCRIPTS = OrderedDict([
186 'timeout': timedelta(seconds=10),
187 'run_on_controller': True,
188 }),
189- ('00-maas-05-dhcp-unconfigured-ifaces', {
190+ (DHCP_EXPLORE_OUTPUT_NAME, {
191 'content': make_function_call_script(dhcp_explore),
192 'hook': null_hook,
193 'timeout': timedelta(minutes=5),
194@@ -648,17 +663,16 @@ NODE_INFO_SCRIPTS = OrderedDict([
195 (GET_FRUID_DATA_OUTPUT_NAME, {
196 'content': GET_FRUID_DATA_SCRIPT.encode('ascii'),
197 'hook': null_hook,
198- 'packages': GET_FRUID_DATA_PACKAGES,
199 'timeout': timedelta(seconds=10),
200 'run_on_controller': False,
201 }),
202- ('00-maas-07-block-devices', {
203+ (BLOCK_DEVICES_OUTPUT_NAME, {
204 'content': make_function_call_script(gather_physical_block_devices),
205 'hook': null_hook,
206 'timeout': timedelta(minutes=5),
207 'run_on_controller': True,
208 }),
209- ('00-maas-08-serial-ports', {
210+ (SERIAL_PORTS_OUTPUT_NAME, {
211 'content': SERIAL_PORTS_SCRIPT.encode('ascii'),
212 'hook': null_hook,
213 'timeout': timedelta(seconds=10),
214@@ -677,7 +691,7 @@ NODE_INFO_SCRIPTS = OrderedDict([
215 'timeout': timedelta(seconds=10),
216 'run_on_controller': False,
217 }),
218- ('99-maas-04-network-interfaces-with-sriov', {
219+ (SRIOV_OUTPUT_NAME, {
220 'content': SRIOV_SCRIPT.encode('ascii'),
221 'hook': null_hook,
222 'timeout': timedelta(seconds=10),

Subscribers

People subscribed via source and target branches