Remove bootstrap network 62/4362/2
authorTodd Malsbary <todd.malsbary@intel.com>
Tue, 15 Jun 2021 19:17:58 +0000 (12:17 -0700)
committerTodd Malsbary <todd.malsbary@intel.com>
Wed, 1 Sep 2021 21:36:44 +0000 (14:36 -0700)
Issue-ID: ICN-598
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Change-Id: Ia44c08ad3c47467cfc47cf055f6dc6daa6b02a84

18 files changed:
Makefile
README.md
cmd/bpa-operator/deploy/operator.yaml
cmd/bpa-operator/e2etest/bpa_vm_verifier.sh
cmd/bpa-operator/e2etest/test_bmh_provisioning_cr.yaml
cmd/bpa-operator/pkg/controller/provisioning/provisioning_controller.go
cmd/bpa-operator/pkg/controller/provisioning/provisioning_controller_test.go
deploy/metal3-vm/03_launch_mgmt_cluster.sh
deploy/metal3/scripts/01_metal3.sh
deploy/metal3/scripts/nodes.json.sample
env/lib/common.sh
env/metal3/02_configure.sh
env/metal3/03_launch_prereq.sh
env/metal3/04_dhcp.yaml [deleted file]
env/metal3/06_host_cleanup.sh
figure-1.odg
figure-1.png
user_config.sh

index a501621..2f21037 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,12 +39,6 @@ bmh_clean:
 bmh_clean_host:
        pushd $(BMDIR) && ./06_host_cleanup.sh && popd
 
 bmh_clean_host:
        pushd $(BMDIR) && ./06_host_cleanup.sh && popd
 
-dhcp_start:
-       pushd $(BMDIR) && ./03_launch_prereq.sh --dhcp-start && popd
-
-dhcp_reset:
-       pushd $(BMDIR) && ./03_launch_prereq.sh --dhcp-reset && popd
-
 clean_packages:
        pushd $(BOOTLOADER_ENV) && \
        ./02_clean_bootloader_package_req.sh --only-packages && popd
 clean_packages:
        pushd $(BOOTLOADER_ENV) && \
        ./02_clean_bootloader_package_req.sh --only-packages && popd
@@ -144,10 +138,8 @@ prerequisite:
 bm_verifer: package_prerequisite \
         kud_bm_deploy_mini \
         bmh_all \
 bm_verifer: package_prerequisite \
         kud_bm_deploy_mini \
         bmh_all \
-       dhcp_start \
        bpa_op_bmh_verifier \
        bpa_rest_api_verifier \
        bpa_op_bmh_verifier \
        bpa_rest_api_verifier \
-       dhcp_reset \
        clean_all
 
 verify_all: prerequisite \
        clean_all
 
 verify_all: prerequisite \
index b3b2307..a178995 100644 (file)
--- a/README.md
+++ b/README.md
@@ -82,7 +82,7 @@ No prerequisites for ICN blueprint.
 (Tested as below)
 Hostname | CPU Model | Memory | Storage | 1GbE: NIC#, VLAN, (Connected extreme 480 switch) | 10GbE: NIC# VLAN, Network (Connected with IZ1 switch)
 ---------|-----------|--------|---------|--------------------------------------------------|------------------------------------------------------
 (Tested as below)
 Hostname | CPU Model | Memory | Storage | 1GbE: NIC#, VLAN, (Connected extreme 480 switch) | 10GbE: NIC# VLAN, Network (Connected with IZ1 switch)
 ---------|-----------|--------|---------|--------------------------------------------------|------------------------------------------------------
-jump0 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 112
+jump0 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 |
 
 #### Jump Server Software Requirements
 ICN supports Ubuntu 18.04. The ICN blueprint installs all required
 
 #### Jump Server Software Requirements
 ICN supports Ubuntu 18.04. The ICN blueprint installs all required
@@ -104,9 +104,9 @@ Net C to provision the bare metal servers to do the OS provisioning.
 (Tested as below)
 Hostname | CPU Model | Memory | Storage | 1GbE: NIC#, VLAN, (Connected extreme 480 switch) | 10GbE: NIC# VLAN, Network (Connected with IZ1 switch)
 ---------|-----------|--------|---------|--------------------------------------------------|------------------------------------------------------
 (Tested as below)
 Hostname | CPU Model | Memory | Storage | 1GbE: NIC#, VLAN, (Connected extreme 480 switch) | 10GbE: NIC# VLAN, Network (Connected with IZ1 switch)
 ---------|-----------|--------|---------|--------------------------------------------------|------------------------------------------------------
-node1 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 112<br/>eno4: VLAN 113
-node2 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 112<br/>eno4: VLAN 113
-node3 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 112<br/>eno4: VLAN 113
+node1 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 113
+node2 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 113
+node3 | Intel 2xE5-2699 | 64GB | 3TB (Sata)<br/>180 (SSD) | eth0: VLAN 110<br/>eno1: VLAN 110<br/>eno2: VLAN 111 | eno3: VLAN 113
 
 #### Compute Server Software Requirements
 The Local Controller will install all the software in compute servers
 
 #### Compute Server Software Requirements
 The Local Controller will install all the software in compute servers
@@ -136,7 +136,7 @@ below. This example only shows 2 servers, statically configured on the
 baremetal network. If you want to increase servers, just add another
 array.  If the baremetal network provides a DHCP server with gateway
 and DNS server information, just change the baremetal type to "ipv4".
 baremetal network. If you want to increase servers, just add another
 array.  If the baremetal network provides a DHCP server with gateway
 and DNS server information, just change the baremetal type to "ipv4".
-ICN provides DHCP servers for the provisioning and bootstrap networks.
+ICN provides DHCP servers for the provisioning network.
 
 `node.json.sample`
 ``` json
 
 `node.json.sample`
 ``` json
@@ -165,11 +165,6 @@ ICN provides DHCP servers for the provisioning and bootstrap networks.
           "ethernet_mac_address": "00:1e:67:fe:f4:1a",
           "type": "phy"
         },
           "ethernet_mac_address": "00:1e:67:fe:f4:1a",
           "type": "phy"
         },
-        {
-          "id": "bootstrap_nic",
-          "ethernet_mac_address": "00:1e:67:f8:6a:40",
-          "type": "phy"
-        },
         {
           "id": "sriov_nic",
           "ethernet_mac_address": "00:1e:67:f8:6a:41",
         {
           "id": "sriov_nic",
           "ethernet_mac_address": "00:1e:67:f8:6a:41",
@@ -190,11 +185,6 @@ ICN provides DHCP servers for the provisioning and bootstrap networks.
           "link": "provisioning_nic",
           "type": "ipv4_dhcp"
         },
           "link": "provisioning_nic",
           "type": "ipv4_dhcp"
         },
-        {
-          "id": "bootstrap",
-          "link": "bootstrap_nic",
-          "type": "ipv4_dhcp"
-        },
         {
           "id": "sriov",
           "link": "sriov_nic",
         {
           "id": "sriov",
           "link": "sriov_nic",
@@ -224,11 +214,6 @@ ICN provides DHCP servers for the provisioning and bootstrap networks.
           "ethernet_mac_address": "00:1e:67:f1:5b:90",
           "type": "phy"
         },
           "ethernet_mac_address": "00:1e:67:f1:5b:90",
           "type": "phy"
         },
-        {
-          "id": "bootstrap_nic",
-          "ethernet_mac_address": "00:1e:67:f8:69:80",
-          "type": "phy"
-        },
         {
           "id": "provisioning_nic",
           "ethernet_mac_address": "00:1e:67:f1:5b:91",
         {
           "id": "provisioning_nic",
           "ethernet_mac_address": "00:1e:67:f1:5b:91",
@@ -254,11 +239,6 @@ ICN provides DHCP servers for the provisioning and bootstrap networks.
           "link": "provisioning_nic",
           "type": "ipv4_dhcp"
         },
           "link": "provisioning_nic",
           "type": "ipv4_dhcp"
         },
-        {
-          "id": "bootstrap",
-          "link": "bootstrap_nic",
-          "type": "ipv4_dhcp"
-        },
         {
           "id": "sriov",
           "link": "sriov_nic",
         {
           "id": "sriov",
           "link": "sriov_nic",
@@ -320,13 +300,6 @@ The user will find the network configuration file named as
 ``` shell
 #!/bin/bash
 
 ``` shell
 #!/bin/bash
 
-#Local Controller - Bootstrap cluster DHCP connection
-#BS_DHCP_INTERFACE defines the interfaces, to which ICN DHCP deployment will bind
-export BS_DHCP_INTERFACE="eno3"
-
-#BS_DHCP_INTERFACE_IP defines the IPAM for the ICN DHCP to be managed.
-export BS_DHCP_INTERFACE_IP="172.31.1.1/24"
-
 #Edge Location Provider Network configuration
 #Net A - Provider Network
 #If provider having specific Gateway and DNS server details in the edge location,
 #Edge Location Provider Network configuration
 #Net A - Provider Network
 #If provider having specific Gateway and DNS server details in the edge location,
index 0ce498c..2170148 100644 (file)
@@ -20,8 +20,6 @@ spec:
           image: akraino.org/icn/bpa-operator:latest
           imagePullPolicy: IfNotPresent
           volumeMounts:
           image: akraino.org/icn/bpa-operator:latest
           imagePullPolicy: IfNotPresent
           volumeMounts:
-          - name: dhcp-shared
-            mountPath: /var/lib/dhcp/
           - name: icn-cluster
             mountPath: /multi-cluster
           command:
           - name: icn-cluster
             mountPath: /multi-cluster
           command:
@@ -40,9 +38,6 @@ spec:
             - name: OPERATOR_NAME
               value: "bpa-operator"
       volumes:
             - name: OPERATOR_NAME
               value: "bpa-operator"
       volumes:
-      - name: dhcp-shared
-        hostPath:
-          path: /opt/icn/dhcp/
       - name: icn-cluster
         hostPath:
           path: /opt/kud/multi-cluster
       - name: icn-cluster
         hostPath:
           path: /opt/kud/multi-cluster
index 7c8b4c4..98e4223 100755 (executable)
@@ -6,53 +6,6 @@ ADDONS_NAMESPACE=kud
 NUM_MASTERS=${NUM_MASTERS:-"1"}
 NUM_WORKERS=${NUM_WORKERS:-"1"}
 
 NUM_MASTERS=${NUM_MASTERS:-"1"}
 NUM_WORKERS=${NUM_WORKERS:-"1"}
 
-# Create Fake DHCP File
-mkdir -p /opt/icn/dhcp
-cat <<EOF > /opt/icn/dhcp/dhcpd.leases
-# The format of this file is documented in the dhcpd.leases(5) manual page.
-# This lease file was written by isc-dhcp-4.3.5
-
-# authoring-byte-order entry is generated, DO NOT DELETE
-authoring-byte-order little-endian;
-
-EOF
-for ((master=0;master<NUM_MASTERS;++master)); do
-    lease=$(virsh net-dhcp-leases baremetal |grep "master-${master}")
-    mac=$(echo $lease | cut -d " " -f 3)
-    ip=$(echo $lease | cut -d " " -f 5)
-    ip="${ip%%/*}"
-    cat <<EOF >> /opt/icn/dhcp/dhcpd.leases
-lease ${ip} {
-  starts 4 2019/08/08 22:32:49;
-  ends 4 2019/08/08 23:52:49;
-  cltt 4 2019/08/08 22:32:49;
-  binding state active;
-  next binding state free;
-  rewind binding state free;
-  hardware ethernet ${mac};
-  client-hostname "master-${master}";
-}
-EOF
-done
-for ((worker=0;worker<NUM_WORKERS;++worker)); do
-    lease=$(virsh net-dhcp-leases baremetal |grep "worker-${worker}")
-    mac=$(echo $lease | cut -d " " -f 3)
-    ip=$(echo $lease | cut -d " " -f 5)
-    ip="${ip%%/*}"
-    cat <<EOF >> /opt/icn/dhcp/dhcpd.leases
-lease ${ip} {
-  starts 4 2019/08/08 22:32:49;
-  ends 4 2019/08/08 23:52:49;
-  cltt 4 2019/08/08 22:32:49;
-  binding state active;
-  next binding state free;
-  rewind binding state free;
-  hardware ethernet ${mac};
-  client-hostname "worker-${worker}";
-}
-EOF
-done
-
 # Create provisioning CR file for testing
 cat <<EOF > e2etest/e2e_test_provisioning_cr.yaml
 apiVersion: bpa.akraino.org/v1alpha1
 # Create provisioning CR file for testing
 cat <<EOF > e2etest/e2e_test_provisioning_cr.yaml
 apiVersion: bpa.akraino.org/v1alpha1
@@ -66,8 +19,7 @@ spec:
   masters:
 EOF
 for ((master=0;master<NUM_MASTERS;++master)); do
   masters:
 EOF
 for ((master=0;master<NUM_MASTERS;++master)); do
-    lease=$(virsh net-dhcp-leases baremetal |grep "master-${master}")
-    mac=$(echo $lease | cut -d " " -f 3)
+    mac=$(virsh domiflist "master_${master}" | awk '/provisioning/ {print $5}')
     cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
     - master-${master}:
         mac-address: ${mac}
     cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
     - master-${master}:
         mac-address: ${mac}
@@ -77,8 +29,7 @@ cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
   workers:
 EOF
 for ((worker=0;worker<NUM_WORKERS;++worker)); do
   workers:
 EOF
 for ((worker=0;worker<NUM_WORKERS;++worker)); do
-    lease=$(virsh net-dhcp-leases baremetal |grep "worker-${worker}")
-    mac=$(echo $lease | cut -d " " -f 3)
+    mac=$(virsh domiflist "worker_${worker}" | awk '/provisioning/ {print $5}')
     cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
     - worker-${worker}:
         mac-address: ${mac}
     cat <<EOF >> e2etest/e2e_test_provisioning_cr.yaml
     - worker-${worker}:
         mac-address: ${mac}
@@ -242,5 +193,4 @@ kubectl delete --ignore-not-found=true configmap ${CLUSTER_NAME}-configmap
 rm e2etest/e2e_test_provisioning_cr.yaml
 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
 rm -rf /opt/kud/multi-cluster/addons
 rm e2etest/e2e_test_provisioning_cr.yaml
 rm -rf /opt/kud/multi-cluster/${CLUSTER_NAME}
 rm -rf /opt/kud/multi-cluster/addons
-rm /opt/icn/dhcp/dhcpd.leases
 make delete
 make delete
index 11bf1d2..aca3766 100644 (file)
@@ -8,9 +8,9 @@ metadata:
 spec:
   masters:
     - pod11-node3:
 spec:
   masters:
     - pod11-node3:
-        mac-address: 00:1e:67:f8:69:80
+        mac-address: 00:1e:67:f1:5b:91
   workers:
     - pod11-node2:
   workers:
     - pod11-node2:
-        mac-address: 00:1e:67:f8:6a:40
+        mac-address: 00:1e:67:fe:f4:1a
   KUDPlugins:
     - emco
   KUDPlugins:
     - emco
index 6fbe40a..0ad5a47 100644 (file)
@@ -7,7 +7,6 @@ import (
        "fmt"
        "io/ioutil"
        "os"
        "fmt"
        "io/ioutil"
        "os"
-       "regexp"
        "strings"
        "time"
 
        "strings"
        "time"
 
@@ -197,7 +196,6 @@ func (r *ReconcileProvisioning) Reconcile(request reconcile.Request) (reconcile.
                var masterString string
                var workerString string
 
                var masterString string
                var workerString string
 
-               dhcpLeaseFile := "/var/lib/dhcp/dhcpd.leases"
                multiClusterDir := "/multi-cluster"
 
                //Create Directory for the specific cluster
                multiClusterDir := "/multi-cluster"
 
                //Create Directory for the specific cluster
@@ -240,7 +238,7 @@ func (r *ReconcileProvisioning) Reconcile(request reconcile.Request) (reconcile.
                                                fmt.Printf("BareMetalHost CR %s has NIC with MAC Address %s\n", bmhCR, masterMAC)
 
                                                //Get IP address of master
                                                fmt.Printf("BareMetalHost CR %s has NIC with MAC Address %s\n", bmhCR, masterMAC)
 
                                                //Get IP address of master
-                                               hostIPaddress, err = getHostIPaddress(masterMAC, dhcpLeaseFile)
+                                               hostIPaddress, err = getHostIPaddress(bareMetalHostList, masterMAC)
                                                if err != nil || hostIPaddress == "" {
                                                        err = fmt.Errorf("IP address not found for host with MAC address %s \n", masterMAC)
                                                        return reconcile.Result{}, err
                                                if err != nil || hostIPaddress == "" {
                                                        err = fmt.Errorf("IP address not found for host with MAC address %s \n", masterMAC)
                                                        return reconcile.Result{}, err
@@ -323,7 +321,7 @@ func (r *ReconcileProvisioning) Reconcile(request reconcile.Request) (reconcile.
                                                                                        fmt.Printf("Host %s matches that macAddress\n", bmhCR)
 
                                                                                        //Get IP address of worker
                                                                                        fmt.Printf("Host %s matches that macAddress\n", bmhCR)
 
                                                                                        //Get IP address of worker
-                                                                                       hostIPaddress, err = getHostIPaddress(workerMAC, dhcpLeaseFile)
+                                                                                       hostIPaddress, err = getHostIPaddress(bareMetalHostList, workerMAC)
                                                                                        if err != nil {
                                                                                                fmt.Errorf("IP address not found for host with MAC address %s \n", workerMAC)
                                                                                                return reconcile.Result{}, err
                                                                                        if err != nil {
                                                                                                fmt.Errorf("IP address not found for host with MAC address %s \n", workerMAC)
                                                                                                return reconcile.Result{}, err
@@ -523,49 +521,35 @@ func checkMACaddress(bareMetalHostList *unstructured.UnstructuredList, macAddres
 
 }
 
 
 }
 
-//Function to get the IP address of a host from the DHCP file
-func getHostIPaddress(macAddress string, dhcpLeaseFilePath string) (string, error) {
+//Function to get the IP address of a host from the BareMetalHost resource
+func getHostIPaddress(bareMetalHostList *unstructured.UnstructuredList, macAddress string) (string, error) {
 
 
-       //Read the dhcp lease file
-       dhcpFile, err := ioutil.ReadFile(dhcpLeaseFilePath)
-       if err != nil {
-               fmt.Printf("Failed to read lease file\n")
-               return "", err
-       }
-
-       dhcpLeases := string(dhcpFile)
-
-       //Regex to use to search dhcpLeases
-       reg := "lease.*{|ethernet.*|\n. binding state.*"
-       re, err := regexp.Compile(reg)
-       if err != nil {
-               fmt.Printf("Could not create Regexp object, Error %v occured\n", err)
-               return "", err
-       }
-
-       //Get String containing leased Ip addresses and Corressponding MAC addresses
-       out := re.FindAllString(dhcpLeases, -1)
-       outString := strings.Join(out, " ")
-       stringReplacer := strings.NewReplacer("lease", "", "ethernet ", "", ";", "",
-               " binding state", "", "{", "")
-       replaced := stringReplacer.Replace(outString)
-       ipMacList := strings.Fields(replaced)
-
-       //Get IP addresses corresponding to Input MAC Address
-       for idx := len(ipMacList) - 1; idx >= 0; idx-- {
-               item := ipMacList[idx]
-               if item == macAddress {
-
-                       leaseState := ipMacList[idx-1]
-                       if leaseState != "active" {
-                               err := fmt.Errorf("No active ip address lease found for MAC address %s \n", macAddress)
-                               fmt.Printf("%v\n", err)
-                               return "", err
+       for _, bareMetalHost := range bareMetalHostList.Items {
+               status, ok := bareMetalHost.Object["status"].(map[string]interface{})
+               if !ok {
+                       continue
+               }
+               hardware, ok := status["hardware"].(map[string]interface{})
+               if !ok {
+                       continue
+               }
+               nics, ok := hardware["nics"].([]interface{})
+               if !ok {
+                       continue
+               }
+               for _, nic := range nics {
+                       n, ok := nic.(map[string]interface{})
+                       if !ok {
+                               continue
+                       }
+                       ip, ok := n["ip"].(string)
+                       if !ok {
+                               continue
+                       }
+                       if macAddress == n["mac"] {
+                               return ip, nil
                        }
                        }
-                       ipAdd := ipMacList[idx-2]
-                       return ipAdd, nil
                }
                }
-
        }
        return "", nil
 }
        }
        return "", nil
 }
index b305aaa..6bd18b1 100644 (file)
@@ -1,7 +1,6 @@
 package provisioning
 
 import (
 package provisioning
 
 import (
-       "io/ioutil"
        "os"
        "testing"
 
        "os"
        "testing"
 
@@ -23,20 +22,12 @@ func TestProvisioningController(t *testing.T) {
        logf.SetLogger(logf.ZapLogger(true))
        bpaName1 := "bpa-test-cr"
        bpaName2 := "bpa-test-2"
        logf.SetLogger(logf.ZapLogger(true))
        bpaName1 := "bpa-test-cr"
        bpaName2 := "bpa-test-2"
-       bpaName3 := "bpa-test-3"
        namespace := "default"
        clusterName := "test-cluster"
        clusterName2 := "test-cluster-2"
        clusterName3 := "test-cluster-3"
        macAddress1 := "08:00:27:00:ab:2c"
        macAddress2 := "08:00:27:00:ab:3d"
        namespace := "default"
        clusterName := "test-cluster"
        clusterName2 := "test-cluster-2"
        clusterName3 := "test-cluster-3"
        macAddress1 := "08:00:27:00:ab:2c"
        macAddress2 := "08:00:27:00:ab:3d"
-       macAddress3 := "08:00:27:00:ab:1c"
-
-       // Create Fake DHCP file
-       err := createFakeDHCP()
-       if err != nil {
-               t.Fatalf("Cannot create Fake DHCP file for testing\n")
-       }
 
        // Create Fake baremetalhost
        bmhList := newBMList()
 
        // Create Fake baremetalhost
        bmhList := newBMList()
@@ -44,15 +35,14 @@ func TestProvisioningController(t *testing.T) {
        // Create Fake Provisioning CR
        provisioning := newBPA(bpaName1, namespace, clusterName, macAddress1)
        provisioning2 := newBPA(bpaName2, namespace, clusterName2, macAddress2)
        // Create Fake Provisioning CR
        provisioning := newBPA(bpaName1, namespace, clusterName, macAddress1)
        provisioning2 := newBPA(bpaName2, namespace, clusterName2, macAddress2)
-       provisioning3 := newBPA(bpaName3, namespace, clusterName3, macAddress3)
 
        // Objects to track in the fake Client
 
        // Objects to track in the fake Client
-       objs := []runtime.Object{provisioning, provisioning2, provisioning3}
+       objs := []runtime.Object{provisioning, provisioning2}
 
        // Register operator types with the runtime scheme
        sc := scheme.Scheme
 
 
        // Register operator types with the runtime scheme
        sc := scheme.Scheme
 
-       sc.AddKnownTypes(bpav1alpha1.SchemeGroupVersion, provisioning, provisioning2, provisioning3)
+       sc.AddKnownTypes(bpav1alpha1.SchemeGroupVersion, provisioning, provisioning2)
 
        // Create Fake Clients and Clientset
        fakeClient := fake.NewFakeClient(objs...)
 
        // Create Fake Clients and Clientset
        fakeClient := fake.NewFakeClient(objs...)
@@ -63,7 +53,7 @@ func TestProvisioningController(t *testing.T) {
 
        // Mock request to simulate Reconcile() being called on an event for a watched resource
        req := simulateRequest(provisioning)
 
        // Mock request to simulate Reconcile() being called on an event for a watched resource
        req := simulateRequest(provisioning)
-       _, err = r.Reconcile(req)
+       _, err := r.Reconcile(req)
        if err != nil {
                t.Fatalf("reconcile: (%v)", err)
        }
        if err != nil {
                t.Fatalf("reconcile: (%v)", err)
        }
@@ -90,19 +80,7 @@ func TestProvisioningController(t *testing.T) {
                t.Fatalf("Failed, Unexpected error occured %v\n", err)
        }
 
                t.Fatalf("Failed, Unexpected error occured %v\n", err)
        }
 
-       // Test 4: Check that the right error is produced when MAC address is not found in the DHCP lease file
-       req = simulateRequest(provisioning3)
-       _, err = r.Reconcile(req)
-       expectedErr = "IP address not found for host with MAC address " + macAddress3 + " \n"
-       if err.Error() != expectedErr {
-               t.Fatalf("Failed, Unexpected error occured %v\n", err)
-       }
-
-       // Delete Fake DHCP file and cluster directories
-       err = os.Remove("/var/lib/dhcp/dhcpd.leases")
-       if err != nil {
-               t.Logf("\nUnable to delete fake DHCP file\n")
-       }
+       // Delete cluster directories
        err = os.RemoveAll("/multi-cluster/" + clusterName)
        if err != nil {
                t.Logf("\nUnable to delete cluster directory %s\n", clusterName)
        err = os.RemoveAll("/multi-cluster/" + clusterName)
        if err != nil {
                t.Logf("\nUnable to delete cluster directory %s\n", clusterName)
@@ -172,7 +150,7 @@ func newBMList() *unstructured.UnstructuredList {
        }
 
        nicMap1 := map[string]interface{}{
        }
 
        nicMap1 := map[string]interface{}{
-               "ip":        "",
+               "ip":        "192.168.50.63",
                "mac":       "08:00:27:00:ab:2c",
                "model":     "0x8086 0x1572",
                "name":      "eth3",
                "mac":       "08:00:27:00:ab:2c",
                "model":     "0x8086 0x1572",
                "name":      "eth3",
@@ -182,7 +160,7 @@ func newBMList() *unstructured.UnstructuredList {
        }
 
        nicMap2 := map[string]interface{}{
        }
 
        nicMap2 := map[string]interface{}{
-               "ip":        "",
+               "ip":        "192.168.60.73",
                "mac":       "08:00:27:00:ab:1c",
                "model":     "0x8086 0x1572",
                "name":      "eth4",
                "mac":       "08:00:27:00:ab:1c",
                "model":     "0x8086 0x1572",
                "name":      "eth4",
@@ -192,13 +170,15 @@ func newBMList() *unstructured.UnstructuredList {
        }
 
        specMap := map[string]interface{}{
        }
 
        specMap := map[string]interface{}{
-               "status": map[string]interface{}{
-                       "errorMessage": "",
-                       "hardware": map[string]interface{}{
-                               "nics": map[string]interface{}{
-                                       "nic1": nicMap1,
-                                       "nic2": nicMap2,
-                               },
+               "bootMACAddress": "08:00:27:00:ab:2c",
+       }
+
+       statusMap := map[string]interface{}{
+               "errorMessage": "",
+               "hardware": map[string]interface{}{
+                       "nics": []interface{}{
+                               nicMap1,
+                               nicMap2,
                        },
                },
        }
                        },
                },
        }
@@ -208,6 +188,7 @@ func newBMList() *unstructured.UnstructuredList {
                "kind":       "BareMetalHost",
                "metadata":   metaData,
                "spec":       specMap,
                "kind":       "BareMetalHost",
                "metadata":   metaData,
                "spec":       specMap,
+               "status":     statusMap,
        }
        itemU := unstructured.Unstructured{
                Object: itemMap,
        }
        itemU := unstructured.Unstructured{
                Object: itemMap,
@@ -222,25 +203,3 @@ func newBMList() *unstructured.UnstructuredList {
 
        return bmhList
 }
 
        return bmhList
 }
-
-// Create DHCP file for testing
-func createFakeDHCP() error {
-
-       dhcpData := []byte(`lease 192.168.50.63 {
-  starts 4 2019/08/08 22:32:49;
-  ends 4 2019/08/08 23:52:49;
-  cltt 4 2019/08/08 22:32:49;
-  binding state active;
-  next binding state free;
-  rewind binding state free;
-  hardware ethernet 08:00:27:00:ab:2c;
-  client-hostname "fake-test-bmh"";
-}`)
-       err := ioutil.WriteFile("/var/lib/dhcp/dhcpd.leases", dhcpData, 0777)
-
-       if err != nil {
-               return err
-       }
-
-       return nil
-}
index d8907b3..b72a30b 100755 (executable)
@@ -84,9 +84,31 @@ function create_userdata {
     fi
 
     cat $HOME/.ssh/id_rsa.pub >> $name-userdata.yaml
     fi
 
     cat $HOME/.ssh/id_rsa.pub >> $name-userdata.yaml
+    cloud_init_scripts >> $name-userdata.yaml
     printf "\n" >> $name-userdata.yaml
 }
 
     printf "\n" >> $name-userdata.yaml
 }
 
+function cloud_init_scripts {
+    # set_dhcp_indentifier.sh:
+    #   The IP address assigned to the provisioning NIC will change
+    #   due to IPA using the MAC address as the client ID and systemd
+    #   using a different ID.  Tell systemd to use the MAC as the
+    #   client ID.  We can't do this in the network data as only the
+    #   JSON format is supported by metal3, and the JSON format does
+    #   not support the dhcp-identifier field.
+    cat << 'EOF'
+write_files:
+- path: /var/lib/cloud/scripts/per-instance/set_dhcp_identifier.sh
+  owner: root:root
+  permissions: '0777'
+  content: |
+    #!/usr/bin/env bash
+    set -eux -o pipefail
+    sed -i -e '/dhcp4: true$/!b' -e 'h;s/\S.*/dhcp-identifier: mac/;H;g' /etc/netplan/50-cloud-init.yaml
+    netplan apply
+EOF
+}
+
 function apply_userdata_credential {
     name="$1"
     cat <<EOF > ./$name-user-data-credential.yaml
 function apply_userdata_credential {
     name="$1"
     cat <<EOF > ./$name-user-data-credential.yaml
index 2ad233c..bd7be78 100755 (executable)
@@ -159,10 +159,26 @@ function remove_baremetal_operator {
 }
 
 function cloud_init_scripts {
 }
 
 function cloud_init_scripts {
-    # The "intel_iommu=on iommu=pt" kernel command line is necessary
-    # for QAT support.
+    # set_dhcp_indentifier.sh:
+    #   The IP address assigned to the provisioning NIC will change
+    #   due to IPA using the MAC address as the client ID and systemd
+    #   using a different ID.  Tell systemd to use the MAC as the
+    #   client ID.  We can't do this in the network data as only the
+    #   JSON format is supported by metal3, and the JSON format does
+    #   not support the dhcp-identifier field.
+    # set_kernel_cmdline.sh:
+    #   The "intel_iommu=on iommu=pt" kernel command line is necessary
+    #   for QAT support.
     cat << 'EOF'
 write_files:
     cat << 'EOF'
 write_files:
+- path: /var/lib/cloud/scripts/per-instance/set_dhcp_identifier.sh
+  owner: root:root
+  permissions: '0777'
+  content: |
+    #!/usr/bin/env bash
+    set -eux -o pipefail
+    sed -i -e '/dhcp4: true$/!b' -e 'h;s/\S.*/dhcp-identifier: mac/;H;g' /etc/netplan/50-cloud-init.yaml
+    netplan apply
 - path: /var/lib/cloud/scripts/per-instance/set_kernel_cmdline.sh
   owner: root:root
   permissions: '0777'
 - path: /var/lib/cloud/scripts/per-instance/set_kernel_cmdline.sh
   owner: root:root
   permissions: '0777'
index faaabfb..43010b9 100644 (file)
             "ethernet_mac_address": "00:1e:67:fe:f4:19",
             "type": "phy"
           },
             "ethernet_mac_address": "00:1e:67:fe:f4:19",
             "type": "phy"
           },
-          {
-            "id": "bootstrap_nic",
-            "ethernet_mac_address": "00:1e:67:f8:6a:40",
-            "type": "phy"
-          },
           {
             "id": "provisioning_nic",
             "ethernet_mac_address": "00:1e:67:fe:f4:1a",
           {
             "id": "provisioning_nic",
             "ethernet_mac_address": "00:1e:67:fe:f4:1a",
             "link": "provisioning_nic",
             "type": "ipv4_dhcp"
           },
             "link": "provisioning_nic",
             "type": "ipv4_dhcp"
           },
-          {
-            "id": "bootstrap",
-            "link": "bootstrap_nic",
-            "type": "ipv4_dhcp"
-          },
           {
             "id": "sriov",
             "link": "sriov_nic",
           {
             "id": "sriov",
             "link": "sriov_nic",
             "ethernet_mac_address": "00:1e:67:f1:5b:90",
             "type": "phy"
           },
             "ethernet_mac_address": "00:1e:67:f1:5b:90",
             "type": "phy"
           },
-          {
-            "id": "bootstrap_nic",
-            "ethernet_mac_address": "00:1e:67:f8:69:80",
-            "type": "phy"
-          },
           {
             "id": "provisioning_nic",
             "ethernet_mac_address": "00:1e:67:f1:5b:91",
           {
             "id": "provisioning_nic",
             "ethernet_mac_address": "00:1e:67:f1:5b:91",
             "link": "provisioning_nic",
             "type": "ipv4_dhcp"
           },
             "link": "provisioning_nic",
             "type": "ipv4_dhcp"
           },
-          {
-            "id": "bootstrap",
-            "link": "bootstrap_nic",
-            "type": "ipv4_dhcp"
-          },
           {
             "id": "sriov",
             "link": "sriov_nic",
           {
             "id": "sriov",
             "link": "sriov_nic",
index 400dbd0..0e4c752 100755 (executable)
@@ -17,11 +17,6 @@ KUBE_VERSION=${KUBE_VERSION:-"v1.15.0"}
 POD_NETWORK_CIDR=${POD_NETWORK_CIDR:-"10.244.0.0/16"}
 PODMAN_CNI_CONFLIST=${PODMAN_CNI_CONFLIST:-"https://raw.githubusercontent.com/containers/libpod/v1.4.4/cni/87-podman-bridge.conflist"}
 
 POD_NETWORK_CIDR=${POD_NETWORK_CIDR:-"10.244.0.0/16"}
 PODMAN_CNI_CONFLIST=${PODMAN_CNI_CONFLIST:-"https://raw.githubusercontent.com/containers/libpod/v1.4.4/cni/87-podman-bridge.conflist"}
 
-#Bootstrap K8s cluster
-BS_DHCP_INTERFACE=${BS_DHCP_INTERFACE:-}
-BS_DHCP_INTERFACE_IP=${BS_DHCP_INTERFACE_IP:-}
-BS_DHCP_DIR=${BS_DHCP_DIR:-$DOWNLOAD_PATH/dhcp}
-
 #Ironic variables
 IRONIC_IMAGE=${IRONIC_IMAGE:-"integratedcloudnative/ironic:v1.0-icn"}
 IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"integratedcloudnative/ironic-inspector:v1.0-icn"}
 #Ironic variables
 IRONIC_IMAGE=${IRONIC_IMAGE:-"integratedcloudnative/ironic:v1.0-icn"}
 IRONIC_INSPECTOR_IMAGE=${IRONIC_INSPECTOR_IMAGE:-"integratedcloudnative/ironic-inspector:v1.0-icn"}
index d2842d2..20077d2 100755 (executable)
@@ -26,13 +26,6 @@ function check_interface_ip {
     fi
 }
 
     fi
 }
 
-function configure_dhcp_bridge {
-    brctl addbr dhcp0
-    ip link set dhcp0 up
-    brctl addif dhcp0 $BS_DHCP_INTERFACE
-    ip addr add dev dhcp0 $BS_DHCP_INTERFACE_IP
-}
-
 function configure_ironic_bridge {
     brctl addbr provisioning
     ip link set provisioning up
 function configure_ironic_bridge {
     brctl addbr provisioning
     ip link set provisioning up
@@ -160,7 +153,6 @@ function configure {
     #configure_kubeadm $1
     #configure_kubelet
     configure_ironic $1
     #configure_kubeadm $1
     #configure_kubelet
     configure_ironic $1
-    configure_dhcp_bridge
     configure_ironic_bridge
     configure_ironic_interfaces
 }
     configure_ironic_bridge
     configure_ironic_interfaces
 }
index 7559f2f..b2bba22 100755 (executable)
@@ -140,26 +140,6 @@ function install_k8s_single_node {
     fi
 }
 
     fi
 }
 
-function install_dhcp {
-    if [ ! -d $BS_DHCP_DIR ]; then
-        mkdir -p $BS_DHCP_DIR
-    fi
-
-    #make sure the dhcp conf sample are configured
-    if [ ! -f $BS_DHCP_DIR/dhcpd.conf ]; then
-        cp $PWD/05_dhcp.conf.sample $BS_DHCP_DIR/dhcpd.conf
-    fi
-
-    kubectl create -f $PWD/04_dhcp.yaml
-}
-
-function reset_dhcp {
-    kubectl delete --ignore-not-found=true -f $PWD/04_dhcp.yaml
-    if [ -d $BS_DHCP_DIR ]; then
-        rm -rf $BS_DHCP_DIR
-    fi
-}
-
 function create_ironic_env {
     cat <<EOF > ${PWD}/ironic.env
 PROVISIONING_INTERFACE=provisioning
 function create_ironic_env {
     cat <<EOF > ${PWD}/ironic.env
 PROVISIONING_INTERFACE=provisioning
@@ -193,14 +173,6 @@ if [ "$#" -eq 0 ]; then
     install online
 elif [ "$1" == "-o" ]; then
     install offline
     install online
 elif [ "$1" == "-o" ]; then
     install offline
-elif [ "$1" == "--dhcp-start" ]; then
-    install_dhcp
-    echo "wait for 320s for nodes to be assigned"
-    sleep 6m
-elif [ "$1" == "--dhcp-reset" ]; then
-    reset_dhcp
-    echo "wait for 320s for nodes to be re-assigned"
-    sleep 6m
 else
     exit 1
 fi
 else
     exit 1
 fi
diff --git a/env/metal3/04_dhcp.yaml b/env/metal3/04_dhcp.yaml
deleted file mode 100644 (file)
index ddce1f1..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
-  name: bootstrap-cluster-dhcp
-spec:
-  replicas: 1
-  selector:
-    matchLabels:
-      name: bootstrap-cluster-dhcp
-  template:
-    metadata:
-      labels:
-        name: bootstrap-cluster-dhcp
-    spec:
-      hostNetwork: true
-      containers:
-        - name: dhcp
-          image: networkboot/dhcpd
-          securityContext:
-            privileged: true
-          command: ["/entrypoint.sh"]
-          args: ["dhcp0"]
-          volumeMounts:
-            - mountPath: /data
-              name: dhcp-data-volume
-      volumes:
-        - name: dhcp-data-volume
-          hostPath:
-            path: /opt/icn/dhcp/
index 3f29be5..b7ed5fd 100755 (executable)
@@ -14,7 +14,4 @@ done
 ip link set provisioning down || true
 brctl delbr provisioning || true
 
 ip link set provisioning down || true
 brctl delbr provisioning || true
 
-ip link set dhcp0 down || true
-brctl delbr dhcp0 || true
-
 rm -rf ${IRONIC_DATA_DIR}
 rm -rf ${IRONIC_DATA_DIR}
index bc7f5ab..33e3d7a 100644 (file)
Binary files a/figure-1.odg and b/figure-1.odg differ
index bd748fb..04232e1 100644 (file)
Binary files a/figure-1.png and b/figure-1.png differ
index ac63063..5add4a9 100644 (file)
@@ -1,9 +1,5 @@
 #!/usr/bin/env bash
 
 #!/usr/bin/env bash
 
-#Local controller - Bootstrap cluster DHCP connection
-export BS_DHCP_INTERFACE="eno3"
-export BS_DHCP_INTERFACE_IP="172.31.1.1/24"
-
 #Ironic Metal3 settings for provisioning network
 export IRONIC_INTERFACE="enp4s0f3"
 
 #Ironic Metal3 settings for provisioning network
 export IRONIC_INTERFACE="enp4s0f3"