Commit bfe6df69 authored by beierl's avatar beierl
Browse files

Network in cloud-init


Moves network config from charm to cloud-init so that it will
persist across reboots.

Signed-off-by: default avatarbeierl <mbeierl@vmware.com>
parent 96f2f84b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -27,4 +27,3 @@ osm vnfd-create vEPC_vnfd.tar.gz || exit 1
osm nsd-create vEPC_nsd.tar.gz || exit 1

osm ns-create --ns_name EPC1 --nsd_name vEPC_nsd --ssh_keys ~/.ssh/id_rsa.pub --config_file params.yaml --vim_account vnfob
ssh://git@osm.etsi.org:29419/beierl/vnf-onboarding-guidelines.git
+4 −6
Original line number Diff line number Diff line
@@ -35,12 +35,10 @@ def install_hsscharm():
def configure_hss():
    spgw_ip = action_get('spgw-ip')
    hss_ip = action_get('hss-ip')
    cmd1 = "sudo ip link set ens4 up && sudo dhclient ens4"
    charms.sshproxy._run(cmd1)
    cmd2= 'sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(hss_ip)
    charms.sshproxy._run(cmd2)
    cmd3= 'sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(spgw_ip)
    charms.sshproxy._run(cmd3)
    cmd = 'sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(hss_ip)
    charms.sshproxy._run(cmd)
    cmd = 'sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/hss.conf'.format(spgw_ip)
    charms.sshproxy._run(cmd)
    remove_flag('actions.configure-hss')

@when('actions.restart-hss')
+4 −10
Original line number Diff line number Diff line
@@ -20,16 +20,10 @@ import charms.sshproxy
def configure_spgw():
    hss_ip = action_get('hss-ip')
    spgw_ip = action_get('spgw-ip')
    cmd1 = "sudo ip link set ens4 up && sudo dhclient ens4"
    charms.sshproxy._run(cmd1)
    cmd2 = "sudo ip link set ens5 up && sudo dhclient ens5"
    charms.sshproxy._run(cmd2)
    cmd3 = "sudo ip link set ens6 up && sudo dhclient ens6"
    charms.sshproxy._run(cmd3)
    cmd3='sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(hss_ip)
    charms.sshproxy._run(cmd3)
    cmd4='sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(spgw_ip)
    charms.sshproxy._run(cmd4)    
    cmd = 'sudo sed -i "\'s/$hss_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(hss_ip)
    charms.sshproxy._run(cmd)
    cmd = 'sudo sed -i "\'s/$spgw_ip/{}/g\'" /etc/nextepc/freeDiameter/mme.conf'.format(spgw_ip)
    charms.sshproxy._run(cmd)
    remove_flag('actions.configure-spgw')

@when('actions.restart-spgw')
+13 −0
Original line number Diff line number Diff line
@@ -3,3 +3,16 @@ hostname: nextepc-hss
password: {{ password }}
chpasswd: { expire: False }
ssh_pwauth: True

write_files:
-   owner: root:root
    content: |
        network:
            version: 2
            ethernets:
                ens4:
                    dhcp4: true
    path: /etc/netplan/51-additional-interfaces.yaml
runcmd:
-   /sbin/ip link set ens4 up
-   /usr/sbin/netplan apply
+19 −0
Original line number Diff line number Diff line
@@ -3,3 +3,22 @@ hostname: nextepc-spgw
password: {{ password }}
chpasswd: { expire: False }
ssh_pwauth: True

write_files:
-   owner: root:root
    content: |
        network:
            version: 2
            ethernets:
                ens4:
                    dhcp4: true
                ens5:
                    dhcp4: true
                ens6:
                    dhcp4: true
    path: /etc/netplan/51-additional-interfaces.yaml
runcmd:
-   /sbin/ip link set ens4 up
-   /sbin/ip link set ens5 up
-   /sbin/ip link set ens6 up
-   /usr/sbin/netplan apply