@@ -681,29 +681,6 @@ class rhcos4(rhcos):
681681
682682
683683class sles (LinuxDist ):
684- def _get_network_file_path (self ):
685- return '/etc/sysconfig/network/'
686-
687- def _get_cfg_str (self , device , broadcast_v4 , gateway_v4 , ip_v4 ,
688- netmask_v4 , address_read , subchannels , dns_v4 , mtu ):
689- cfg_str = "BOOTPROTO=\' static\' \n "
690- cfg_str += "IPADDR=\' %s\' \n " % ip_v4
691- cfg_str += "NETMASK=\' %s\' \n " % netmask_v4
692- cfg_str += "BROADCAST=\' %s\' \n " % broadcast_v4
693- cfg_str += "STARTMODE=\' onboot\' \n "
694- cfg_str += ("NAME=\' OSA Express Network card (%s)\' \n " %
695- address_read )
696- cfg_str += "MTU=\' %s\' \n " % mtu
697- if (dns_v4 is not None ) and (len (dns_v4 ) > 0 ):
698- self .dns_v4 = dns_v4
699- else :
700- self .dns_v4 = None
701- return cfg_str
702-
703- def _get_route_str (self , gateway_v4 ):
704- route_str = 'default %s - -\n ' % gateway_v4
705- return route_str
706-
707684 def _get_cmd_str (self , address_read , address_write , address_data ):
708685 cmd_str = 'qeth_configure -l 0.0.%s ' % address_read .lower ()
709686 cmd_str += '0.0.%(write)s 0.0.%(data)s 1\n ' % {'write' :
@@ -717,12 +694,6 @@ def _get_cmd_str(self, address_read, address_write, address_data):
717694 def _get_dns_filename (self ):
718695 return '/etc/resolv.conf'
719696
720- def _get_device_filename (self , vdev ):
721- return 'ifcfg-eth' + str (vdev ).zfill (4 )
722-
723- def _get_all_device_filename (self ):
724- return 'ifcfg-eth*'
725-
726697 def _get_device_name (self , vdev ):
727698 return 'eth' + str (vdev ).zfill (4 )
728699
@@ -830,8 +801,17 @@ def get_zipl_script_lines(self, image, ramdisk, root, fcp, wwpn, lun):
830801 % {'image' : image , 'ramdisk' : ramdisk , 'root' : root ,
831802 'fcp' : fcp , 'wwpn' : wwpn , 'lun' : lun }]
832803
804+ def create_active_net_interf_cmd (self ):
805+ return 'systemctl start zvmguestconfigure.service'
806+
833807 def _enable_network_interface (self , device , ip , broadcast ):
834- return ''
808+ if len (broadcast ) > 0 :
809+ activeIP_str = 'ip addr add %s broadcast %s dev %s\n ' % (ip ,
810+ broadcast , device )
811+ else :
812+ activeIP_str = 'ip addr add %s dev %s\n ' % (ip , device )
813+ activeIP_str += 'ip link set dev %s up\n ' % device
814+ return activeIP_str
835815
836816 def _get_clean_command (self ):
837817 files = os .path .join (self ._get_network_file_path (),
@@ -889,6 +869,35 @@ def get_volume_detach_configuration_cmds(self, fcp_list, target_wwpns,
889869
890870
891871class sles12 (sles ):
872+ def _get_network_file_path (self ):
873+ return '/etc/sysconfig/network/'
874+
875+ def _get_device_filename (self , vdev ):
876+ return 'ifcfg-eth' + str (vdev ).zfill (4 )
877+
878+ def _get_all_device_filename (self ):
879+ return 'ifcfg-eth*'
880+
881+ def _get_cfg_str (self , device , broadcast_v4 , gateway_v4 , ip_v4 ,
882+ netmask_v4 , address_read , subchannels , dns_v4 , mtu ):
883+ cfg_str = "BOOTPROTO=\' static\' \n "
884+ cfg_str += "IPADDR=\' %s\' \n " % ip_v4
885+ cfg_str += "NETMASK=\' %s\' \n " % netmask_v4
886+ cfg_str += "BROADCAST=\' %s\' \n " % broadcast_v4
887+ cfg_str += "STARTMODE=\' onboot\' \n "
888+ cfg_str += ("NAME=\' OSA Express Network card (%s)\' \n " %
889+ address_read )
890+ cfg_str += "MTU=\' %s\' \n " % mtu
891+ if (dns_v4 is not None ) and (len (dns_v4 ) > 0 ):
892+ self .dns_v4 = dns_v4
893+ else :
894+ self .dns_v4 = None
895+ return cfg_str
896+
897+ def _get_route_str (self , gateway_v4 ):
898+ route_str = 'default %s - -\n ' % gateway_v4
899+ return route_str
900+
892901 def get_znetconfig_contents (self ):
893902 remove_route = 'rm -f %s/ifroute-eth*' % self ._get_network_file_path ()
894903 return '\n ' .join (('cio_ignore -R' ,
@@ -924,18 +933,6 @@ def get_zipl_script_lines(self, image, ramdisk, root, fcp, wwpn, lun):
924933 % {'image' : image , 'ramdisk' : ramdisk , 'root' : root ,
925934 'fcp' : fcp , 'wwpn' : wwpn , 'lun' : lun }]
926935
927- def create_active_net_interf_cmd (self ):
928- return 'systemctl start zvmguestconfigure.service'
929-
930- def _enable_network_interface (self , device , ip , broadcast ):
931- if len (broadcast ) > 0 :
932- activeIP_str = 'ip addr add %s broadcast %s dev %s\n ' % (ip ,
933- broadcast , device )
934- else :
935- activeIP_str = 'ip addr add %s dev %s\n ' % (ip , device )
936- activeIP_str += 'ip link set dev %s up\n ' % device
937- return activeIP_str
938-
939936
940937class sles15 (sles12 ):
941938 def get_znetconfig_contents (self ):
@@ -977,8 +974,42 @@ def get_znetconfig_contents(self):
977974
978975
979976class sles16 (sles ):
980- # TODO: ADD MODERN DISTRIBUTIONS
981- pass
977+ def _get_network_file_path (self ):
978+ return '/etc/NetworkManager/system-connections/'
979+
980+ def _get_cfg_str (self , device , broadcast_v4 , gateway_v4 , ip_v4 ,
981+ netmask_v4 , address_read , subchannels , dns_v4 , mtu ):
982+ # TODO: SUPPORT FIXED ADDRESS AND OTHER PARAMETERS
983+ return '\n ' .join (('[connection]' ,
984+ 'id=' + device ,
985+ 'type=ethernet' ,
986+ 'name=' + device ,
987+ ''
988+ '[ipv4]'
989+ 'method=auto'
990+ '' ,
991+ '[ipv6]' ,
992+ 'method=auto' ))
993+
994+ def _get_route_str (self , gateway_v4 ):
995+ return ''
996+
997+ def _get_device_filename (self , vdev ):
998+ return 'eth' + str (vdev ).zfill (4 ) + '.nmconnection'
999+
1000+ def _get_all_device_filename (self ):
1001+ return 'eth*.nmconnection'
1002+
1003+ def get_znetconfig_contents (self ):
1004+ return '\n ' .join (('cio_ignore -R' ,
1005+ 'znetconf -R -n' ,
1006+ 'sleep 2' ,
1007+ 'udevadm trigger' ,
1008+ 'udevadm settle' ,
1009+ 'sleep 2' ,
1010+ 'znetconf -A' ,
1011+ 'cio_ignore -u' ,
1012+ 'nmcli connection reload' ))
9821013
9831014
9841015class ubuntu (LinuxDist ):
0 commit comments