]> git.ipfire.org Git - nitsi.git/blobdiff - test.py
Add the login credentials to the vm() class
[nitsi.git] / test.py
diff --git a/test.py b/test.py
index 0507d04570a0eabe390c5551f29c46c0f78103c3..8140aff86933aebc90dcb84ca6df08419a98e6d8 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -10,7 +10,6 @@ import libvirt
 
 import xml.etree.ElementTree as ET
 
-import inspect
 import os
 
 import configparser
@@ -54,7 +53,7 @@ class libvirt_con():
 
 
 class vm():
-    def __init__(self, vm_xml_file, snapshot_xml_file, image, root_uid):
+    def __init__(self, vm_xml_file, snapshot_xml_file, image, root_uid, username, password):
         self.log = log(4)
         self.con = libvirt_con("qemu:///system")
         try:
@@ -76,6 +75,9 @@ class vm():
 
         self.root_uid = root_uid
 
+        self.username = username
+        self.password = password
+
     def define(self):
         self.dom = self.con.con.defineXML(self.vm_xml)
         if self.dom == None:
@@ -107,7 +109,6 @@ class vm():
             raise BaseException
 
     def revert_snapshot(self):
-        print(inspect.getmembers(self.dom, predicate=inspect.ismethod))
         self.dom.revertToSnapshot(self.snapshot)
         self.snapshot.delete()
 
@@ -139,10 +140,10 @@ class vm():
 
         #serial_con.close()
 
-    def login(self, username, password):
+    def login(self):
         try:
-            self.serial_con = connection(self.get_serial_device(), username="root")
-            self.serial_con.login("25814@root")
+            self.serial_con = connection(self.get_serial_device(), username=self.username)
+            self.serial_con.login(self.password)
         except BaseException as e:
             self.log.error("Could not connect to the domain via serial console")