Ejemplo n.º 1
0
 def normalize(self, intf_conv):
     for f in os.listdir(CONF_DIR):
         if f.endswith('.txt'):
             file_name = os.path.splitext(f)[0]
             file_text = file_io.read_txt(CONF_DIR + '/' + f)
             converted_intf = self.convert_intf(file_text, intf_conv.get(file_name, {}))
             updated_text = self.cleanup(converted_intf)
             new_filename = os.path.join(TMP_DIR, file_name + '.txt')
             file_io.write_txt(new_filename, updated_text)
     return
Ejemplo n.º 2
0
 def extract_ip(self):
     result = {}
     # cwd = os.path.join(TMP_DIR, CONF_DIR)
     for f in os.listdir(TMP_DIR):
         if f.endswith('.txt'):
             dev_name = os.path.splitext(f)[0]
             file_text = file_io.read_txt(TMP_DIR + '/' + f)
             ips = self.get_ips(file_text)
             result[dev_name] = ips
     file_io.write_yaml(TMP_DIR + '/' + 'ip.yml', result)
     return result
Ejemplo n.º 3
0
 def normalize(self, intf_conv):
     for f in os.listdir(CONF_DIR):
         if f.endswith('.txt'):
             file_name = os.path.splitext(f)[0]
             file_text = file_io.read_txt(CONF_DIR + '/' + f)
             converted_intf = self.convert_intf(
                 file_text, intf_conv.get(file_name, {}))
             updated_text = self.cleanup(converted_intf)
             new_filename = os.path.join(TMP_DIR, file_name + '.txt')
             file_io.write_txt(new_filename, updated_text)
     return
Ejemplo n.º 4
0
 def extract_ip(self):
     result = {}
     cwd = os.path.join(TMP_DIR, CONF_DIR)
     for f in os.listdir(cwd):
         if f.endswith('.txt'):
             dev_name = os.path.splitext(f)[0]
             file_text = file_io.read_txt(cwd + '/' + f)
             ips = self.get_ips(file_text)
             result[dev_name] = ips
     file_io.write_yaml(TMP_DIR + '/' + 'ip.yml', result)
     return result
Ejemplo n.º 5
0
 def configure_nodes(self, path):
     import threading
     processes = []
     for node_name in self.nodes:
         conf = 'enable\r configure terminal\r no ip domain-lookup\r'
         conf += file_io.read_txt('{0}/{1}.txt'.format(path, node_name))
         conf += '\rend\r write\r'
         process = threading.Thread(target=self.nodes[node_name].configure, args=(conf,))
         # self.nodes[node_name].configure(conf)
         process.start()
         processes.append(process)
         # print("*** NODE {} CONFIGURED".format(node_name))
     [p.join() for p in processes]
     return None
Ejemplo n.º 6
0
 def configure_nodes(self, path):
     import threading
     processes = []
     for node_name in self.nodes:
         conf = 'no\renable\r configure terminal\r no ip domain-lookup\r'
         conf += file_io.read_txt('{0}/{1}.txt'.format(path, node_name))
         conf += '\rend\r write\r'
         process = threading.Thread(target=self.nodes[node_name].configure,
                                    args=(conf, ))
         # self.nodes[node_name].configure(conf)
         process.start()
         processes.append(process)
         # print("*** NODE {} CONFIGURED".format(node_name))
     [p.join() for p in processes]
     return None
Ejemplo n.º 7
0
def set_API_key(filename):
    global service
    API_KEY = file_io.read_txt(filename)
    service = discovery.build('commentanalyzer',
                              'v1alpha1',
                              developerKey=API_KEY)