Пример #1
0
    def test_cleanup_puppet_config_modified(self):
        """Test the cleanup of puppet-tripleo generated config file

        Usecase: When os-net-config is run first time after the deprecation
        of NeutronSriovNumVFs and ifup-local has contents other than invoking
        allocate_vfs.
        """

        content = '#!/bin/bash\n'\
                  '/etc/sysconfig/allocate_vfs $1\n'\
                  '/usr/sbin/ifup eth0'
        mod_content = '#!/bin/bash\n'\
                      '/usr/sbin/ifup eth0'
        f = open(sriov_config._IFUP_LOCAL_FILE, "w+")
        f.write(content)
        f.close()

        sriov_config.cleanup_puppet_config()
        self.assertEqual(False,
                         os.path.exists(sriov_config._RESET_SRIOV_RULES_FILE))
        self.assertEqual(False,
                         os.path.exists(sriov_config._ALLOCATE_VFS_FILE))
        self.assertEqual(True,
                         os.path.exists(sriov_config._IFUP_LOCAL_FILE))

        f = open(sriov_config._IFUP_LOCAL_FILE, "r")
        self.assertEqual(mod_content, f.read())
Пример #2
0
    def test_cleanup_puppet_config_new(self):
        """Test the cleanup of puppet-tripleo generated config file.

        Usecase: When os-net-config is run on fresh deployments, all these
        files will not exist.
        """

        sriov_config.cleanup_puppet_config()
        self.assertEqual(False,
                         os.path.exists(sriov_config._RESET_SRIOV_RULES_FILE))
        self.assertEqual(False,
                         os.path.exists(sriov_config._ALLOCATE_VFS_FILE))
        self.assertEqual(False,
                         os.path.exists(sriov_config._IFUP_LOCAL_FILE))
Пример #3
0
    def test_cleanup_puppet_config_deprecation(self):
        """Test the cleanup of puppet-tripleo generated config file.

        Usecase: The ifup-local has the default content generated by
        puppet-tripleo
        """

        content = '#!/bin/bash\n'\
                  '/etc/sysconfig/allocate_vfs $1'
        f = open(sriov_config._RESET_SRIOV_RULES_FILE, "w+")
        f.close()
        f = open(sriov_config._ALLOCATE_VFS_FILE, "w+")
        f.close()
        f = open(sriov_config._IFUP_LOCAL_FILE, "w+")
        f.write(content)
        f.close()

        sriov_config.cleanup_puppet_config()
        self.assertEqual(False,
                         os.path.exists(sriov_config._RESET_SRIOV_RULES_FILE))
        self.assertEqual(False,
                         os.path.exists(sriov_config._ALLOCATE_VFS_FILE))
        self.assertEqual(False,
                         os.path.exists(sriov_config._IFUP_LOCAL_FILE))