[Ovirt-devel] [PATCH node] add more network and iscsi-initiator related functions to network.py

Joey Boggs jboggs at redhat.com
Tue Oct 26 19:07:59 UTC 2010


---
 scripts/network.py |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/scripts/network.py b/scripts/network.py
index 28e32f2..97cefe7 100644
--- a/scripts/network.py
+++ b/scripts/network.py
@@ -191,6 +191,32 @@ class Network:
             if OVIRT_VARS.has_key("NTP"):
                 log("Testing NTP Configuration")
                 test_ntp_configuration()
+    def identify_nic(self, nic):
+        os.system("ethtool -p %s 10") % nic
+        return
+
+    def is_valid_hostname(self, hostname):
+        if re.search("^([a-zA-Z0-9.-]+)$", hostname):
+            return True
+
+    def set_hostname(self, hostname):
+        if is_valid_hostname(hostname) or hostname == "":
+            if hostname == "":
+                hostname = "localhost"
+            ret = os.system("hostname %s")
+            if ret == 0:
+                set_hostname = augeas.Augeas("root=/")
+                set_hostname.set("/files/etc/sysconfig/network/HOSTNAME", "%s") % hostname
+                set_hostname.save()
+
+    def set_iscsi_initiator(self, initiator_name):
+        iscsi_config = open(INITIATOR_FILE, "w")
+        iscsi_config.write("InitiatorName=" + INITIATOR_NAME)
+        if ovirt_store_config(INITIATOR_FILE):
+            log("Initiator name set as: " + INITIATOR_NAME)
+        else:
+            log("Setting initiator name failed\n")
+
 try:
     if "AUTO" in sys.argv[1]:
         if OVIRT_VARS.has_key("OVIRT_INIT"):
-- 
1.7.2.3




More information about the ovirt-devel mailing list