3434Fedora = 1
3535CentOS = 2
3636Ubuntu = 3
37+ RHEL6 = 4
3738
3839IPV4 = 4
3940IPV6 = 6
4243
4344if os .path .exists ("/etc/fedora-release" ): distro = Fedora
4445elif os .path .exists ("/etc/centos-release" ): distro = CentOS
45- elif os .path .exists ("/etc/redhat-release" ) and not os .path .exists ("/etc/fedora-release" ): distro = CentOS
46+ elif os .path .exists ("/etc/redhat-release" ):
47+ version = file ("/etc/redhat-release" ).readline ()
48+ if version .find ("Red Hat Enterprise Linux Server release 6" ) != - 1 :
49+ distro = RHEL6
50+ elif version .find ("Centos release" ) != - 1 :
51+ distro = CentOS
4652elif os .path .exists ("/etc/legal" ) and "Ubuntu" in file ("/etc/legal" ).read (- 1 ): distro = Ubuntu
4753else : distro = Unknown
48-
4954logFileName = None
5055# ================== LIBRARY UTILITY CODE=============
5156def setLogFile (logFile ):
@@ -264,7 +269,7 @@ def check_hostname():
264269
265270#check function
266271def check_kvm ():
267- if distro in (Fedora ,CentOS ):
272+ if distro in (Fedora ,CentOS , RHEL6 ):
268273 if os .path .exists ("/dev/kvm" ): return True
269274 raise CheckFailed ("KVM is not correctly installed on this system, or support for it is not enabled in the BIOS" )
270275 else :
@@ -284,7 +289,7 @@ def check_cgroups():
284289
285290#check function
286291def check_selinux ():
287- if distro not in [Fedora ,CentOS ]: return # no selinux outside of those
292+ if distro not in [Fedora ,CentOS , RHEL6 ]: return # no selinux outside of those
288293 enforcing = False
289294 try :
290295 output = getenforce ().stdout .strip ()
@@ -365,7 +370,7 @@ def __init__(self,brname, pubNic, prvNic):
365370 self .runtime_state_changed = False
366371 self .was_nm_service_running = None
367372 self .was_net_service_running = None
368- if distro in (Fedora , CentOS ):
373+ if distro in (Fedora , CentOS , RHEL6 ):
369374 self .nmservice = 'NetworkManager'
370375 self .netservice = 'network'
371376 else :
@@ -376,7 +381,7 @@ def __init__(self,brname, pubNic, prvNic):
376381 def done (self ):
377382 try :
378383 alreadysetup = False
379- if distro in (Fedora ,CentOS ):
384+ if distro in (Fedora ,CentOS , RHEL6 ):
380385 if self .pubNic != None :
381386 alreadysetup = alreadysetup or augtool ._print ("/files/etc/sysconfig/network-scripts/ifcfg-%s" % self .pubNic ).stdout .strip ()
382387 if self .prvNic != None :
@@ -463,30 +468,30 @@ def execute(self):
463468
464469 self .old_net_device = dev
465470
466- if distro in (Fedora , CentOS ):
471+ if distro in (Fedora , CentOS , RHEL6 ):
467472 inconfigfile = "/" .join (augtool .match ("/files/etc/sysconfig/network-scripts/*/DEVICE" ,dev ).stdout .strip ().split ("/" )[:- 1 ])
468473 if not inconfigfile : raise TaskFailed ("Device %s has not been set up in /etc/sysconfig/network-scripts" % dev )
469474 pathtoconfigfile = inconfigfile [6 :]
470475
471- if distro in (Fedora , CentOS ):
476+ if distro in (Fedora , CentOS , RHEL6 ):
472477 automatic = augtool .match ("%s/ONBOOT" % inconfigfile ,"yes" ).stdout .strip ()
473478 else :
474479 automatic = augtool .match ("/files/etc/network/interfaces/auto/*/" ,dev ).stdout .strip ()
475480 if not automatic :
476481 if distro is Fedora : raise TaskFailed ("Device %s has not been set up in %s as automatic on boot" % dev ,pathtoconfigfile )
477482 else : raise TaskFailed ("Device %s has not been set up in /etc/network/interfaces as automatic on boot" % dev )
478483
479- if distro not in (Fedora , CentOS ):
484+ if distro not in (Fedora , CentOS , RHEL6 ):
480485 inconfigfile = augtool .match ("/files/etc/network/interfaces/iface" ,dev ).stdout .strip ()
481486 if not inconfigfile : raise TaskFailed ("Device %s has not been set up in /etc/network/interfaces" % dev )
482487
483- if distro in (Fedora , CentOS ):
488+ if distro in (Fedora , CentOS , RHEL6 ):
484489 isstatic = augtool .match (inconfigfile + "/BOOTPROTO" ,"none" ).stdout .strip ()
485490 if not isstatic : isstatic = augtool .match (inconfigfile + "/BOOTPROTO" ,"static" ).stdout .strip ()
486491 else :
487492 isstatic = augtool .match (inconfigfile + "/method" ,"static" ).stdout .strip ()
488493 if not isstatic :
489- if distro in (Fedora , CentOS ): raise TaskFailed ("Device %s has not been set up as a static device in %s" % (dev ,pathtoconfigfile ))
494+ if distro in (Fedora , CentOS , RHEL6 ): raise TaskFailed ("Device %s has not been set up as a static device in %s" % (dev ,pathtoconfigfile ))
490495 else : raise TaskFailed ("Device %s has not been set up as a static device in /etc/network/interfaces" % dev )
491496
492497 if is_service_running (self .nmservice ):
@@ -503,7 +508,7 @@ def execute(self):
503508
504509 yield "Creating Cloud bridging device and making device %s member of this bridge" % dev
505510
506- if distro in (Fedora , CentOS ):
511+ if distro in (Fedora , CentOS , RHEL6 ):
507512 ifcfgtext = file (pathtoconfigfile ).read ()
508513 newf = "/etc/sysconfig/network-scripts/ifcfg-%s" % self .brname
509514 #def restore():
@@ -687,7 +692,7 @@ class SetupLibvirt(ConfigTask):
687692 cfgline = "export CGROUP_DAEMON='cpu:/virt'"
688693 def done (self ):
689694 try :
690- if distro in (Fedora ,CentOS ): libvirtfile = "/etc/sysconfig/libvirtd"
695+ if distro in (Fedora ,CentOS , RHEL6 ): libvirtfile = "/etc/sysconfig/libvirtd"
691696 elif distro is Ubuntu : libvirtfile = "/etc/default/libvirt-bin"
692697 else : raise AssertionError , "We should not reach this"
693698 return self .cfgline in file (libvirtfile ,"r" ).read (- 1 )
@@ -696,14 +701,14 @@ def done(self):
696701 raise
697702
698703 def execute (self ):
699- if distro in (Fedora ,CentOS ): libvirtfile = "/etc/sysconfig/libvirtd"
704+ if distro in (Fedora ,CentOS , RHEL6 ): libvirtfile = "/etc/sysconfig/libvirtd"
700705 elif distro is Ubuntu : libvirtfile = "/etc/default/libvirt-bin"
701706 else : raise AssertionError , "We should not reach this"
702707 libvirtbin = file (libvirtfile ,"r" ).read (- 1 )
703708 libvirtbin = libvirtbin + "\n " + self .cfgline + "\n "
704709 file (libvirtfile ,"w" ).write (libvirtbin )
705710
706- if distro in (CentOS , Fedora ): svc = "libvirtd"
711+ if distro in (CentOS , Fedora , RHEL6 ): svc = "libvirtd"
707712 else : svc = "libvirt-bin"
708713 stop_service (svc )
709714 enable_service (svc )
@@ -731,7 +736,7 @@ def execute(self):
731736 startswith = stanza .split ("=" )[0 ] + '='
732737 replace_or_add_line ("/etc/libvirt/libvirtd.conf" ,startswith ,stanza )
733738
734- if distro is Fedora :
739+ if distro in ( Fedora , RHEL6 ) :
735740 replace_or_add_line ("/etc/sysconfig/libvirtd" ,"LIBVIRTD_ARGS=" ,"LIBVIRTD_ARGS=-l" )
736741
737742 elif distro is Ubuntu :
@@ -743,7 +748,7 @@ def execute(self):
743748 else :
744749 raise AssertionError ("Unsupported distribution" )
745750
746- if distro in (CentOS , Fedora ): svc = "libvirtd"
751+ if distro in (CentOS , Fedora , RHEL6 ): svc = "libvirtd"
747752 else : svc = "libvirt-bin"
748753 stop_service (svc )
749754 enable_service (svc )
@@ -753,14 +758,14 @@ class SetupRequiredServices(ConfigTask):
753758 name = "required services setup"
754759
755760 def done (self ):
756- if distro is Fedora : nfsrelated = "rpcbind nfslock"
761+ if distro in ( Fedora , RHEL6 ) : nfsrelated = "rpcbind nfslock"
757762 elif distro is CentOS : nfsrelated = "portmap nfslock"
758763 else : return True
759764 return all ( [ is_service_running (svc ) for svc in nfsrelated .split () ] )
760765
761766 def execute (self ):
762767
763- if distro is Fedora : nfsrelated = "rpcbind nfslock"
768+ if distro in ( Fedora , RHEL6 ) : nfsrelated = "rpcbind nfslock"
764769 elif distro is CentOS : nfsrelated = "portmap nfslock"
765770 else : raise AssertionError ("Unsupported distribution" )
766771
@@ -772,7 +777,7 @@ class SetupFirewall(ConfigTask):
772777
773778 def done (self ):
774779
775- if distro in (Fedora , CentOS ):
780+ if distro in (Fedora , CentOS , RHEL6 ):
776781 if not os .path .exists ("/etc/sysconfig/iptables" ): return True
777782 if ":on" not in chkconfig ("--list" ,"iptables" ).stdout : return True
778783 else :
@@ -784,7 +789,7 @@ def done(self):
784789
785790 def execute (self ):
786791 ports = "22 1798 16509" .split ()
787- if distro in (Fedora , CentOS ):
792+ if distro in (Fedora , CentOS , RHEL6 ):
788793 for p in ports : iptables ("-I" ,"INPUT" ,"1" ,"-p" ,"tcp" ,"--dport" ,p ,'-j' ,'ACCEPT' )
789794 o = service .iptables .save () ; print o .stdout + o .stderr
790795 else :
@@ -800,7 +805,7 @@ def __init__(self,brname):
800805
801806 def done (self ):
802807
803- if distro in (Fedora , CentOS ):
808+ if distro in (Fedora , CentOS , RHEL6 ):
804809 if not os .path .exists ("/etc/sysconfig/iptables" ): return True
805810 if ":on" not in chkconfig ("--list" ,"iptables" ).stdout : return True
806811 rule = "FORWARD -i %s -o %s -j ACCEPT" % (self .brname ,self .brname )
@@ -817,7 +822,7 @@ def execute(self):
817822
818823 yield "Permitting traffic in the bridge interface, migration port and for VNC ports"
819824
820- if distro in (Fedora , CentOS ):
825+ if distro in (Fedora , CentOS , RHEL6 ):
821826
822827 for rule in (
823828 "-I FORWARD -i %s -o %s -j ACCEPT" % (self .brname ,self .brname ),
@@ -856,7 +861,7 @@ def config_tasks(brname, pubNic, prvNic):
856861 SetupFirewall (),
857862 SetupFirewall2 (brname ),
858863 )
859- elif distro in (Ubuntu ,Fedora ):
864+ elif distro in (Ubuntu ,Fedora , RHEL6 ):
860865 config_tasks = (
861866 SetupNetworking (brname , pubNic , prvNic ),
862867 SetupCgConfig (),
@@ -929,7 +934,7 @@ def prompt_for_hostpods(zonespods):
929934def device_exist (devName ):
930935 try :
931936 alreadysetup = False
932- if distro in (Fedora ,CentOS ):
937+ if distro in (Fedora ,CentOS , RHEL6 ):
933938 alreadysetup = augtool ._print ("/files/etc/sysconfig/network-scripts/ifcfg-%s" % devName ).stdout .strip ()
934939 else :
935940 alreadysetup = augtool .match ("/files/etc/network/interfaces/iface" ,devName ).stdout .strip ()
0 commit comments