Example #1
0
 def ifnames(self):
     """Return the ifnames of all bond devices
     """
     ifnames = []
     if self.is_enabled():
         ifnames = fs.File(self.bonding_masters_filename).read().split()
     return ifnames
Example #2
0
 def __init__(self, filename=None):
     filename = filename or OVIRT_NODE_DEFAULTS_FILENAME
     if filename == OVIRT_NODE_DEFAULTS_FILENAME \
        and not fs.File(filename).exists():
         raise RuntimeError("Node config file does not exist: %s" %
                            filename)
     super(NodeConfigFile, self).__init__(filename, create=True)
Example #3
0
            def commit(self):
                from ovirtnode.ovirtfunctions import remove_config

                remove_config("/etc/kdump.conf")
                system.service("kdump", "stop")
                fs.File('/etc/kdump.conf').touch()

                self.backups.remove()
Example #4
0
 def delete(self, mifname):
     """Delete one bond master
     """
     if not self.is_bond(mifname):
         raise RuntimeError("Can no delete '%s', it is no bond master" %
                            mifname)
     #process.call(["ip", "link", "set", "dev", mifname, "down"])
     #process.call(["ip", "link", "delete", mifname, "type", "bond"])
     fs.File(self.bonding_masters_filename).write("-%s" % mifname)
Example #5
0
    def test_basic(self):
        FakeFs.erase()
        with patch("ovirt.node.utils.fs.File", FakeFs.File):
            f = fs.File("new-file")
            f.touch()
            assert "new-file" in FakeFs.filemap

            f.delete()
            print FakeFs.filemap
            assert FakeFs.filemap == {}
Example #6
0
def hostname(new_hostname=None):
    """Get or set the current hostname
    """
    if new_hostname:
        # hostnamectl set's runtime and config file
        utils.process.check_call(["hostnamectl", "set-hostname", new_hostname])

        # FIXME:
        # hostnamectl --static is not writing into /etc/hostname.
        # Because of that, the new hostname won't persist across
        # reboot in case user change it via TUI.
        # Restarting systemd-hostnamed doesn't help either.
        hostname_file = fs.File("/etc/hostname")
        hostname_file.write(contents=new_hostname, mode="w+")

    return socket.gethostname()
Example #7
0
 def ifnames(self):
     """Return the ifnames of all bond devices
     """
     return fs.File(self.bonding_masters_filename).read().split()
Example #8
0
 def is_enabled(self):
     """If bonding is enabled
     """
     return fs.File(self.bonding_masters_filename).exists()