updated commander files
authorMarius Sandu-Popa <sandupopamarius@gmail.com>
Tue, 19 Jan 2010 14:46:03 +0000 (16:46 +0200)
committerMarius Sandu-Popa <sandupopamarius@gmail.com>
Tue, 19 Jan 2010 14:46:16 +0000 (16:46 +0200)
razvan/xml/ParserConf.py [moved from razvan/xml/conf.py with 100% similarity]
razvan/xml/SSHCommander.py [moved from razvan/xml/test2.py with 65% similarity]
razvan/xml/XMLParser.py [moved from razvan/xml/test.py with 69% similarity]

similarity index 100%
rename from razvan/xml/conf.py
rename to razvan/xml/ParserConf.py
similarity index 65%
rename from razvan/xml/test2.py
rename to razvan/xml/SSHCommander.py
index 23d4639..71cfc41 100644 (file)
@@ -4,9 +4,12 @@ paramiko.util.log_to_file('/tmp/paramiko.log')
 
 client = paramiko.SSHClient()
 client.load_system_host_keys()
-client.connect(hostname='p2p-next-07.grid.pub.ro',  username='p2p')
+client.connect(hostname='141.85.37.237',  username='marius', password='marius')
+#client.connect(hostname='p2p-next-07.grid.pub.ro',  username='p2p')
+stdin, stdout, stderr = client.exec_command('touch gugu dudu')
 stdin, stdout, stderr = client.exec_command('ls -l')
-
+print stdout.readlines()
+client.close()
 #~ host = "p2p-next-09.grid.pub.ro"
 #~ port = 22
 #~ transport = paramiko.Transport((host, port))
similarity index 69%
rename from razvan/xml/test.py
rename to razvan/xml/XMLParser.py
index ea5f75e..1f473b5 100644 (file)
@@ -1,15 +1,15 @@
 from lxml import etree 
 
 class SwarmInstance:
-       def __init__(self, id, list):
+       def __init__(self, id, node_id, list):
                self.id = id;
-               self.node_id = list[0];
-               self.btclient = list[1];
-               self.upload_limit = list[2];
-               self.download_limit = list[3];
-               self.port = list[4];
-               self.download_dir = list[5];
-               self.upload_dir = list[6];
+               self.node_id = node_id;
+               self.btclient = list[0];
+               self.upload_limit = list[1];
+               self.download_limit = list[2];
+               self.port = list[3];
+               self.download_dir = list[4];
+               self.upload_dir = list[5];
        
        def __str__(self):
                return '[%s: %s: %s: %s: %s: %s: %s: %s]' \
@@ -33,7 +33,6 @@ class NodeConfig:
 class ClientConfig:
        def __init__(self, id, node_path, filetype, options):
                self.id = id;
-               self.node_path = node_path;
                self.filetype = filetype;
                self.options = options;
                #~ self.upload_limit_option= list[2];
@@ -58,37 +57,48 @@ class FileType:
                return '[%s: %s: %s: %s: %s: %s: %s]' \
                        %(self.id, self.btclient, self.upload_limit, self.download_limit, self.port, self.upload_dir, self.download_dir);
 
-#~ tree = etree.parse("swarm.xml")
-#~ root = tree.getroot()
-#~ for elem in root:
-       #~ swn = SwarmInstance(elem.get("id"), [elemelem.text for elemelem in elem])
-       #~ print swn
-       #~ print "=================================="
-
 try:
        tree = etree.parse("clients.xml")
        root = tree.getroot()
-       dict = {}
+       clients_options = {}
        for elem in root:
                id = elem.get("id")
                options = [elem2.text for elem2 in elem[1:]]
                filetype =  [elem[0].get("type")]
                filetype.extend([elem2.text for elem2 in elem[0]])
-               dict[id] = [options, filetype]
+               clients_options[id] = [filetype, options]
+       
+       print clients_options
 except IOError as e:
        print e
 
 try:
        tree = etree.parse("nodes.xml")
        root = tree.getroot()
+       nodes = {}
        for elem in root:
-               list = [elem.get("id")]
-               list.extend([elem2.text for elem2 in elem[:len(elem)-1]])
-               dict = {}
+               id = elem.get("id")
+               list = [elem2.text for elem2 in elem[:len(elem)-1]]
+               client_paths = {}
                for elem2 in elem[len(elem)-1]:
-                       dict[elem2.get("id")]=elem2[0].text;
-               list.append(dict)
-               print list
-               print "=================================="
+                       client_id = elem2.get("id");
+                       client_paths [client_id]=elem2[0].text;
+               nodes[id] = [client_paths, list]
+       print nodes
+       print "=================================="
 except IOError as e:
        print e
+
+try:
+       tree = etree.parse("swarm.xml")
+       root = tree.getroot()
+       swarm = {}
+       for elem in root:
+               id = elem.get("id")
+               list = [elem2.text for elem2 in elem[:len(elem)-1]]
+               swarm[id] = list
+       print swarm
+       print "=================================="
+except IOError as e:
+       print e
+