From 41fcc401d8c20281086205e31e995ff1d98d7d02 Mon Sep 17 00:00:00 2001
From: Ruby Loo <ruby.loo@intel.com>
Date: Wed, 20 Sep 2017 20:24:41 +0000
Subject: [PATCH] Revert "Change pxe dhcp options name to codes."

This reverts commit c377f5cbbd034e16b68a3fc30e138b03badc9c94.

Rajini Karthik discovered that this broke the hardware builds (dell and
oneview, maybe others) -- it caused a TFTP timeout issue. Builds started
failing after it merged (approximately Sep15th midnight) and the builds
on stable/ocata and stable/pike are passing. Rajini reverted this patch
on the Dell CI temporarily and the tests passed.

Change-Id: Id1ef4441511a36f8fc6d639f4bb1dd52cd630445
---
 ironic/common/pxe_utils.py                    | 23 +++++++------------
 ironic/tests/unit/common/test_pxe_utils.py    | 22 +++++++++---------
 ...-dhcp-option-numbers-8b0b0efae912ff5f.yaml |  5 ----
 3 files changed, 19 insertions(+), 31 deletions(-)
 delete mode 100644 releasenotes/notes/use-dhcp-option-numbers-8b0b0efae912ff5f.yaml

diff --git a/ironic/common/pxe_utils.py b/ironic/common/pxe_utils.py
index 57ceb0a473..0ed9a21ff7 100644
--- a/ironic/common/pxe_utils.py
+++ b/ironic/common/pxe_utils.py
@@ -33,12 +33,6 @@ LOG = logging.getLogger(__name__)
 
 PXE_CFG_DIR_NAME = 'pxelinux.cfg'
 
-DHCP_TFTP_SERVER_NAME = '66'  # rfc2132
-DHCP_BOOTFILE_NAME = '67'  # rfc2132
-DHCP_TFTP_SERVER_ADDRESS = '150'  # rfc5859
-DHCP_IPXE_ENCAP_OPTS = '175'  # Tentatively Assigned
-DHCP_TFTP_PATH_PREFIX = '210'  # rfc5071
-
 
 def get_root_dir():
     """Returns the directory where the config files and images will live."""
@@ -323,31 +317,30 @@ def dhcp_options_for_instance(task):
         if dhcp_provider_name == 'neutron':
             # Neutron use dnsmasq as default DHCP agent, add extra config
             # to neutron "dhcp-match=set:ipxe,175" and use below option
-            dhcp_opts.append({'opt_name': "tag:!ipxe,%s" % DHCP_BOOTFILE_NAME,
+            dhcp_opts.append({'opt_name': 'tag:!ipxe,bootfile-name',
                               'opt_value': boot_file})
-            dhcp_opts.append({'opt_name': "tag:ipxe,%s" % DHCP_BOOTFILE_NAME,
+            dhcp_opts.append({'opt_name': 'tag:ipxe,bootfile-name',
                               'opt_value': ipxe_script_url})
         else:
             # !175 == non-iPXE.
             # http://ipxe.org/howto/dhcpd#ipxe-specific_options
-            dhcp_opts.append({'opt_name': "!%s,%s" % (DHCP_IPXE_ENCAP_OPTS,
-                              DHCP_BOOTFILE_NAME),
+            dhcp_opts.append({'opt_name': '!175,bootfile-name',
                               'opt_value': boot_file})
-            dhcp_opts.append({'opt_name': DHCP_BOOTFILE_NAME,
+            dhcp_opts.append({'opt_name': 'bootfile-name',
                               'opt_value': ipxe_script_url})
     else:
-        dhcp_opts.append({'opt_name': DHCP_BOOTFILE_NAME,
+        dhcp_opts.append({'opt_name': 'bootfile-name',
                           'opt_value': boot_file})
         # 210 == tftp server path-prefix or tftp root, will be used to find
         # pxelinux.cfg directory. The pxelinux.0 loader infers this information
         # from it's own path, but Petitboot needs it to be specified by this
         # option since it doesn't use pxelinux.0 loader.
-        dhcp_opts.append({'opt_name': DHCP_TFTP_PATH_PREFIX,
+        dhcp_opts.append({'opt_name': '210',
                           'opt_value': get_tftp_path_prefix()})
 
-    dhcp_opts.append({'opt_name': DHCP_TFTP_SERVER_NAME,
+    dhcp_opts.append({'opt_name': 'server-ip-address',
                       'opt_value': CONF.pxe.tftp_server})
-    dhcp_opts.append({'opt_name': DHCP_TFTP_SERVER_ADDRESS,
+    dhcp_opts.append({'opt_name': 'tftp-server',
                       'opt_value': CONF.pxe.tftp_server})
 
     # Append the IP version for all the configuration options
diff --git a/ironic/tests/unit/common/test_pxe_utils.py b/ironic/tests/unit/common/test_pxe_utils.py
index 30ba5d350c..80c9fd4ef8 100644
--- a/ironic/tests/unit/common/test_pxe_utils.py
+++ b/ironic/tests/unit/common/test_pxe_utils.py
@@ -621,16 +621,16 @@ class TestPXEUtils(db_base.DbTestCase):
         self.config(tftp_server='192.0.2.1', group='pxe')
         self.config(pxe_bootfile_name='fake-bootfile', group='pxe')
         self.config(tftp_root='/tftp-path/', group='pxe')
-        expected_info = [{'opt_name': '67',
+        expected_info = [{'opt_name': 'bootfile-name',
                           'opt_value': 'fake-bootfile',
                           'ip_version': ip_version},
                          {'opt_name': '210',
                           'opt_value': '/tftp-path/',
                           'ip_version': ip_version},
-                         {'opt_name': '66',
+                         {'opt_name': 'server-ip-address',
                           'opt_value': '192.0.2.1',
                           'ip_version': ip_version},
-                         {'opt_name': '150',
+                         {'opt_name': 'tftp-server',
                           'opt_value': '192.0.2.1',
                           'ip_version': ip_version},
                          ]
@@ -689,16 +689,16 @@ class TestPXEUtils(db_base.DbTestCase):
 
         self.config(dhcp_provider='isc', group='dhcp')
         expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe'
-        expected_info = [{'opt_name': '!175,67',
+        expected_info = [{'opt_name': '!175,bootfile-name',
                           'opt_value': boot_file,
                           'ip_version': 4},
-                         {'opt_name': '66',
+                         {'opt_name': 'server-ip-address',
                           'opt_value': '192.0.2.1',
                           'ip_version': 4},
-                         {'opt_name': '150',
+                         {'opt_name': 'tftp-server',
                           'opt_value': '192.0.2.1',
                           'ip_version': 4},
-                         {'opt_name': '67',
+                         {'opt_name': 'bootfile-name',
                           'opt_value': expected_boot_script_url,
                           'ip_version': 4}]
 
@@ -707,16 +707,16 @@ class TestPXEUtils(db_base.DbTestCase):
 
         self.config(dhcp_provider='neutron', group='dhcp')
         expected_boot_script_url = 'http://192.0.3.2:1234/boot.ipxe'
-        expected_info = [{'opt_name': 'tag:!ipxe,67',
+        expected_info = [{'opt_name': 'tag:!ipxe,bootfile-name',
                           'opt_value': boot_file,
                           'ip_version': 4},
-                         {'opt_name': '66',
+                         {'opt_name': 'server-ip-address',
                           'opt_value': '192.0.2.1',
                           'ip_version': 4},
-                         {'opt_name': '150',
+                         {'opt_name': 'tftp-server',
                           'opt_value': '192.0.2.1',
                           'ip_version': 4},
-                         {'opt_name': 'tag:ipxe,67',
+                         {'opt_name': 'tag:ipxe,bootfile-name',
                           'opt_value': expected_boot_script_url,
                           'ip_version': 4}]
 
diff --git a/releasenotes/notes/use-dhcp-option-numbers-8b0b0efae912ff5f.yaml b/releasenotes/notes/use-dhcp-option-numbers-8b0b0efae912ff5f.yaml
deleted file mode 100644
index 02410a1f4f..0000000000
--- a/releasenotes/notes/use-dhcp-option-numbers-8b0b0efae912ff5f.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
----
-fixes:
-  - |
-    Fixes compatibility with Neutron DHCP backends other than dnsmasq by using
-    standard DHCP option codes instead of dnsmasq-specific option names.