Exemplo n.º 1
0
    def executeAdd(self,ipDict):
        self.vendor = self.vendorselect.get()
        self.hostname = self.hostnameinput.get().replace(" ","_")
        ipaddr = self.ipaddr.get()
        ls = self.Logical.get()
        if not ipaddr:
            Dialog(self,title='Error',
                   prompt='No address entered\n',
                   icon=cancel_icon)
            return
        if not self.vendor or not self.hostname:
            Dialog(self,title='Error',
                   prompt='Enter hostname and vendor\n',
                   icon=cancel_icon)
            return

        ipaddr.split(".")
        if len(ipaddr.split('.'))>4:
            answer = Dialog(self,title='Error',prompt='Wrong IP address entered\n',
                            icon=cancel_icon)
            if answer.ans == 'ok': self.clear()
            return
        for octate in range(len(ipaddr.split('.'))):
           try:
               if int(ipaddr.split(".")[octate])>255:
                   answer = Dialog(self,title='Error',prompt='Wrong IP address entered\n',
                                   icon=cancel_icon)
                   if answer.ans == 'ok': self.clear()
                   return
           except ValueError:
               answer = Dialog(self,title='Error',prompt='Wrong IP address entered\n',
                               icon=cancel_icon)
               if answer.ans == 'ok': self.clear()
               return


        if ls and ls!='None':
            ipDict[ipaddr]=[self.vendor.lower(),self.hostname,ls]
        else: ipDict[ipaddr]=[self.vendor.lower(),self.hostname]

        keylist = ipDict.keys()
        keylist.sort()
        routers = open(self.path+"devices.bas","w")
        for key in keylist:
            try: routers.write('ipv4='+key.ljust(15)+ ' vendor='+ipDict[key][0].ljust(10)+\
                                   ' hostname='+ipDict[key][1].ljust(20)+' logicalsys='+ipDict[key][2])
            except IndexError: routers.write('ipv4='+key.ljust(15)+ ' vendor='+ipDict[key][0].ljust(10)+\
                                             ' hostname='+ipDict[key][1])
            routers.write('\n')
        routers.close()
        self.clear()
Exemplo n.º 2
0
   def remove(self,parent,data):
      ip,interface,vlan = data[0], data[1], data[2]

      if self.status.up:
         clientList,removed = self.deleteClient(ip,interface,vlan)
         if removed:
            proceed = Dialog(parent,prompt='Click ok to proceed \nor cancel to review \n',
                          icon=self.warning)
            strfile = '\n'.join(clientList)
            cleanFile = delEmptyLine(strfile)
            self.status.saveRemoteFile(self.login,cleanFile)
            Dialog(parent,prompt= 'Client file updated successfully\n',nobutton=True)

         else: Dialog(parent,prompt= '\nClient not found at '+ip+' interface '+interface+'.'+vlan)
      else: Dialog(parent,prompt='Can not access server \n'+self.server+' \n',icon=self.error)
Exemplo n.º 3
0
   def update(self,parent,data):
      ip,interface,vlan = data[0], data[1], data[2]
      update = self.client(data)
      if self.status.up:
         clientList,removed = self.deleteClient(ip,interface,vlan)
         strfile = '\n'.join(clientList)
         strfile+=update
         cleanFile = delEmptyLine(strfile)
         self.status.saveRemoteFile(self.login,cleanFile)

         outputtext = ''
         outputtext+= '\n'
         outputtext+= 'Removed:'
         outputtext+= '--------'
         outputtext+= removed
         outputtext+= '\n'
         outputtext+= 'Added:'
         outputtext+= '------'
         outputtext+= update.strip()
         outputtext+= '\n'
         outputtext+= 'Client file updated successfully\n'

         output= outputWin()
         output.TB2('Vlan Finder',otputtext,parent,self)

      else: Dialog(parent,prompt='Can not access server \n'+self.server+' \n',icon=self.error)
Exemplo n.º 4
0
def boDbutton(parent, serverlogin, server, FQP, data, commandList):

    pe = data[0]
    st = data[5]
    revertDate = data[6]

    stnumber = 'ST' + st.zfill(6) + 'by' + parent.username
    scriptname = stnumber + '.sh'
    scriptPath = FQP

    error = cancel_icon

    commandStr = ':'.join(commandList)
    task = scriptPath + "/basowilldo.py -commands \'" + commandStr + "\' -ipaddress " + pe + " >" + scriptPath + "/Logs/" + stnumber + ".log\nrm " + scriptPath + "/PendingTickets/" + scriptname

    status = Server(serverlogin, server, scriptPath, scriptname)

    if status.up:
        status.revertScript(task)
        time.sleep(2)
        status.revertJob(revertDate)
        time.sleep(1)
        return status.retrieveRemoteFile()
    else:
        Dialog(parent,
               prompt='Can not access server \n' + server + ' \n',
               icon=error)
        return False
Exemplo n.º 5
0
   def add(self,parent,data):
      ip,interface,vlan = data[0], data[1], data[2]
      update = self.client(data)
      if self.status.up:
         clientList,removed = self.deleteClient(ip,interface,vlan)
         strfile = '\n'.join(clientList)
         if removed:
            proceed = Dialog(parent,prompt='Client alread exist in package \Proceed anyway? \n',
                             icon= self.warning)
            if procced.ans != 'ok': return

         else: proceed = Dialog(parent,prompt='Click ok to proceed \nor cancel to review \n',
                          icon=self.warning)
         if proceed.ans == 'ok':
            strfile+=update
            cleanFile = delEmptyLine(strfile)
            self.status.saveRemoteFile(self.login,cleanFile)
            Dialog(parent,prompt= 'Client file updated successfully\n')
      else: Dialog(parent,prompt='Can not access server \n'+self.server+' \n', icon=self.error)
Exemplo n.º 6
0
 def clear(self, confirmed=False):
     if not confirmed:
         d = Dialog(self, prompt="Are you sure? \n", icon=warning_icon)
     if confirmed or d.ans == 'ok':
         comboboxes = [
             self.TCombobox1_4, self.TCombobox1_5, self.TCombobox1_6,
             self.TCombobox1_7, self.TCombobox1_8, self.TCombobox1_9,
             self.TCombobox1_10, self.TCombobox1_11
         ]
         for cbox in comboboxes:
             cbox.set('')
         self.TEntry1_12.delete(0, END)
     else:
         return
Exemplo n.º 7
0
 def executeRemove(self,ipDict):
     try: ipDict.pop(self.ipaddr.get())
     except KeyError:
        answer = Dialog(self,title='Error',prompt='Device not found\n',
                        icon=cancel_icon)
        if answer.ans == 'ok':self.clear()
        return
     keylist = ipDict.keys()
     keylist.sort()
     routers = open(self.path+"devices.bas","w")
     for key in keylist:
       routers.write('ipv4='+key.ljust(15)+ ' vendor='+ipDict[key][0].ljust(10)+\
                 ' hostname='+ipDict[key][1]+'\n')
     routers.close()
     self.clear()
Exemplo n.º 8
0
    def __init__(self, parent, ipDict, intDict, policerDict, choice=None):

        confDict = {}
        self.error = error_icon
        self.warning = warning_icon

        ls = parent.TCombobox1_4.get()
        if ls == 'None': ls = False

        pe = parent.TCombobox1_5.get()
        if not pe in ipDict.keys():
            Dialog(parent, prompt="Edge router unknown\n", icon=self.error)
            return

        iface = parent.TCombobox1_6.get()
        if not iface in intDict[pe] or iface == 'Null':
            Dialog(parent, prompt="Interface unknown\n", icon=self.error)
            return

        vlan = parent.TCombobox1_7.get()
        try:
            if int(vlan) not in range(0, 4095):
                Dialog(parent,
                       prompt="VLAN not in correct range\n",
                       icon=self.error)
                return
        except ValueError:
            Dialog(parent,
                   prompt="VLAN not in correct range\n",
                   icon=self.error)
            return

        cir = parent.TCombobox1_10.get()
        if not cir in policerDict[pe]:
            Dialog(parent,
                   prompt="Standard subscription is not defined\n",
                   icon=self.error)
            return

        pir = parent.TCombobox1_11.get()
        if not pir in policerDict[pe]:
            Dialog(parent,
                   prompt="onDemand subscription is not defined\n",
                   icon=self.error)
            return

        st = parent.TCombobox1_8.get()
        try:
            int(st)
        except ValueError:
            if parent.choice: pass
            else:
                Dialog(parent,
                       prompt="Service ticket must be in numbers\n",
                       icon=self.error)
                return

        rev = parent.TCombobox1_9.get()
        try:
            datetime.datetime.strptime(rev, '%B %d %Y')
            date = True
        except ValueError:
            date = False
            if re.findall(r'^[0-9]+.?(min|day|days|month|months)$', rev):
                rev = 'now+' + rev
            else:
                Dialog(parent,
                       prompt="Revert date has wrong format\n",
                       icon=self.error)
                return

        ds = parent.TEntry1_12.get()

        if parent.choice:
            ticket = st
            jobid = parent.bigdict[ticket][4]
            serv = Server(parent.serverlogin, parent.server, parent.scriptPath,
                          ticket + '.sh')
            if serv.up:
                success = check_icon
                serv.deleteFromRemoteFile(ticket, jobid)
                time.sleep(1)
                Dialog(parent,
                       prompt='Ticket ' + ticket + ' deleted successfully \n',
                       icon=success)
            # convert the ST back to an integer without 'ST' and 'byuser'
            st = str(int(re.findall(r'\d+', ticket.split('by')[0])[0]))
        ''' call the loading class '''
        parent.loading = loading(parent.Frame3,
                                 parent,
                                 pbar=[0.093, 0.857, 0.08, 0.300],
                                 words='Loading')
        parent.update_idletasks()

        d = createConfig()
        ''' create a job to revert on server '''

        commandList = []
        if ipDict[pe][0] == 'juniper':
            commandList = d.junos(pe, ls, iface, vlan, cir)
        elif ipDict[pe][0] == 'juniper':
            commandList = d.cisco(pe, ls, iface, vlan, cir)

        data = [pe, ls, iface, vlan, cir, st, rev]
        serverlogin = parent.serverlogin
        server = parent.server
        FQP = parent.scriptPath

        done = False
        if commandList:
            done = boDbutton(parent, serverlogin, server, FQP, data,
                             commandList)
        ''' configure the on demand bandwidth on router '''

        commandList = []
        if ipDict[pe][0] == 'juniper':
            commandList = d.junos(pe, ls, iface, vlan, pir)
        elif ipDict[pe][0] == 'juniper':
            commandList = d.cisco(pe, ls, iface, vlan, pir)

        confDict[pe] = [ipDict[pe][0], ipDict[pe][1], commandList]
        self.c = ClassSendCommand()
        error = False
        if done:
            error = self.c.execute(parent,
                                   confDict,
                                   parent.username,
                                   parent.password,
                                   extra=done)

        parent.config(cursor='')
        parent.update()
        parent.loading.stop(parent)
        if done and error:
            Dialog(
                parent,
                prompt='There was an error in configuration of ' + pe +
                ' \nHowever a revert task has been added on server ' + server +
                ' \nPlease configure the device manually revert will be automated\n',
                icon=self.warning)
        parent.clear(confirmed=True)
Exemplo n.º 9
0
    def __init__(self,
                 username,
                 password,
                 ipDict,
                 intDict,
                 policerDict,
                 serverdata,
                 choice=None):

        self.username = username
        self.password = password
        self.serverlogin = serverdata[0]
        self.server = serverdata[1]
        self.scriptPath = serverdata[2]

        if choice:
            self.choice = choice
        else:
            self.choice = False

        Tkinter.Toplevel.__init__(self)

        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font9 = "-family Calibri -size 15 -weight bold -slant roman "  \
            "-underline 0 -overstrike 0"
        self.style = ttk.Style()
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        self.geometry("570x690+346+156")
        self.resizable(width=False, height=False)
        self.title("Bandwidth on Demand")
        self.configure(background="#d9d9d9")
        self.configure(highlightbackground="#d9d9d9")
        self.configure(highlightcolor="black")

        self.Frame1 = Tkinter.Frame(self)
        self.Frame1.place(relx=0.018,
                          rely=0.014,
                          relheight=0.978,
                          relwidth=0.974)
        self.Frame1.configure(borderwidth="2")
        self.Frame1.configure(background="#d9d9d9")
        self.Frame1.configure(highlightbackground="#d9d9d9")
        self.Frame1.configure(highlightcolor="black")
        self.Frame1.configure(width=555)

        self.Label1 = Tkinter.Label(self.Frame1)
        self.Label1.place(relx=0.018, rely=0.015, height=43, width=289)
        self.Label1.configure(activebackground="#f9f9f9")
        self.Label1.configure(activeforeground="black")
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font=font9)
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(highlightbackground="#f0f0f0f0f0f0")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Bandwidth on demand''')

        self.Frame3 = Tkinter.Frame(self.Frame1)
        self.Frame3.place(relx=0.018,
                          rely=0.104,
                          relheight=0.881,
                          relwidth=0.964)
        self.Frame3.configure(borderwidth="2")
        self.Frame3.configure(background="#d9d9d9")
        self.Frame3.configure(highlightbackground="#d9d9d9")
        self.Frame3.configure(highlightcolor="black")
        self.Frame3.configure(width=535)

        self.Frame3_9 = Tkinter.Frame(self.Frame3)
        self.Frame3_9.place(relx=0.037,
                            rely=0.218,
                            relheight=0.261,
                            relwidth=0.925)
        self.Frame3_9.configure(relief='groove')
        self.Frame3_9.configure(borderwidth="2")
        self.Frame3_9.configure(relief='groove')
        self.Frame3_9.configure(background="#d9d9d9")
        self.Frame3_9.configure(highlightbackground="#d9d9d9")
        self.Frame3_9.configure(highlightcolor="black")
        self.Frame3_9.configure(width=495)

        ipList = ipDict.keys()
        ipList.sort()

        def updateint(*args):
            self.usedvlans = []
            self.TEntry1_12.delete(0, END)
            self.TCombobox1_6.configure(textvar=self.intselect,
                                        values=intDict[self.devselect.get()])
            self.TCombobox1_6.set('Select interface')
            self.TCombobox1_7.configure(textvar=self.vlanselect,
                                        values=self.usedvlans)
            self.TCombobox1_7.set('')
            self.TCombobox1_10.configure(
                textvar=self.cirselect,
                values=policerDict[self.devselect.get()])
            self.TCombobox1_10.set('Select')
            self.TCombobox1_11.configure(
                textvar=self.pirselect,
                values=policerDict[self.devselect.get()])
            self.TCombobox1_11.set('Select')
            try:
                self.TCombobox1_4.set(ipDict[self.devselect.get()][2])
            except IndexError:
                self.TCombobox1_4.set('None')

        self.devselect = Tkinter.StringVar(self.Frame3_9)
        self.TCombobox1_5 = ttk.Combobox(self.Frame3_9)
        self.TCombobox1_5.place(relx=0.02,
                                rely=0.258,
                                relheight=0.2,
                                relwidth=0.448)
        self.TCombobox1_5.configure(takefocus="")
        self.TCombobox1_5.configure(textvariable=self.devselect, values=ipList)
        self.TCombobox1_5.bind("<<ComboboxSelected>>", updateint)

        self.TCombobox1_4 = ttk.Combobox(self.Frame3_9)
        self.TCombobox1_4.place(relx=0.505,
                                rely=0.258,
                                relheight=0.2,
                                relwidth=0.448)
        self.TCombobox1_4.configure(takefocus="")

        def updatevlan(*args):
            self.TEntry1_12.delete(0, END)
            if self.TCombobox1_6.get() == 'Null':
                self.usedvlans = []
                self.TCombobox1_7.configure(textvar=self.vlanselect,
                                            values=self.usedvlans)
                return
            self.loading = loading(self.Frame3_9,
                                   self,
                                   pbar=[0.505, 0.71, 0.2, 0.448],
                                   words='Loading vlans')
            self.update_idletasks()
            self.vlanDict = getUsedVlanDesc(self.TCombobox1_5.get(), ipDict,
                                            self.TCombobox1_6.get(),
                                            self.username, self.password)
            self.usedvlans = self.vlanDict.keys()
            self.usedvlans.sort()
            self.TCombobox1_7.configure(textvar=self.vlanselect,
                                        values=self.usedvlans)
            self.TCombobox1_7.set('Select')
            self.config(cursor='')
            self.update()
            self.loading.stop(self)

        self.intselect = Tkinter.StringVar(self.Frame3_9)
        self.TCombobox1_6 = ttk.Combobox(self.Frame3_9)
        self.TCombobox1_6.place(relx=0.02,
                                rely=0.71,
                                relheight=0.2,
                                relwidth=0.448)
        self.TCombobox1_6.configure(takefocus="")
        self.TCombobox1_6.bind("<<ComboboxSelected>>", updatevlan)

        def updatedesc(*args):
            self.TEntry1_12.delete(0, END)
            self.TEntry1_12.insert(0, self.vlanDict[self.vlanselect.get()])

        self.vlanselect = Tkinter.StringVar(self.Frame3_9)
        self.TCombobox1_7 = ttk.Combobox(self.Frame3_9)
        self.TCombobox1_7.place(relx=0.505,
                                rely=0.71,
                                relheight=0.2,
                                relwidth=0.448)
        self.TCombobox1_7.configure(takefocus="")
        self.TCombobox1_7.bind("<<ComboboxSelected>>", updatedesc)

        self.TLabel1_7 = ttk.Label(self.Frame3_9)
        self.TLabel1_7.place(relx=0.02, rely=0.06, height=29, width=150)
        self.TLabel1_7.configure(background="#d9d9d9")
        self.TLabel1_7.configure(foreground="#000000")
        self.TLabel1_7.configure(font="TkDefaultFont")
        self.TLabel1_7.configure(relief='flat')
        self.TLabel1_7.configure(text='''Edge router''')

        self.TLabel1_6 = ttk.Label(self.Frame3_9)
        self.TLabel1_6.place(relx=0.505, rely=0.06, height=29, width=150)
        self.TLabel1_6.configure(background="#d9d9d9")
        self.TLabel1_6.configure(foreground="#000000")
        self.TLabel1_6.configure(font="TkDefaultFont")
        self.TLabel1_6.configure(relief='flat')
        self.TLabel1_6.configure(text='''Logical system''')

        self.TLabel1_8 = ttk.Label(self.Frame3_9)
        self.TLabel1_8.place(relx=0.02, rely=0.516, height=29, width=100)
        self.TLabel1_8.configure(background="#d9d9d9")
        self.TLabel1_8.configure(foreground="#000000")
        self.TLabel1_8.configure(font="TkDefaultFont")
        self.TLabel1_8.configure(relief='flat')
        self.TLabel1_8.configure(text='''Interface''')

        self.TLabel1_9 = ttk.Label(self.Frame3_9)
        self.TLabel1_9.place(relx=0.505, rely=0.516, height=29, width=100)
        self.TLabel1_9.configure(background="#d9d9d9")
        self.TLabel1_9.configure(foreground="#000000")
        self.TLabel1_9.configure(font="TkDefaultFont")
        self.TLabel1_9.configure(relief='flat')
        self.TLabel1_9.configure(text='''VLAN''')

        self.Frame3_10 = Tkinter.Frame(self.Frame3)
        self.Frame3_10.place(relx=0.037,
                             rely=0.034,
                             relheight=0.16,
                             relwidth=0.925)
        self.Frame3_10.configure(relief='groove')
        self.Frame3_10.configure(borderwidth="2")
        self.Frame3_10.configure(relief='groove')
        self.Frame3_10.configure(background="#d9d9d9")
        self.Frame3_10.configure(highlightbackground="#d9d9d9")
        self.Frame3_10.configure(highlightcolor="black")
        self.Frame3_10.configure(width=495)

        # Service ticket
        self.TCombobox1_8 = ttk.Combobox(self.Frame3_10)
        self.TCombobox1_8.place(relx=0.02,
                                rely=0.35,
                                relheight=0.326,
                                relwidth=0.448)
        self.TCombobox1_8.configure(takefocus="")
        if choice:

            def updateothers(*args):
                self.TCombobox1_5.set(self.bigdict[self.sts.get()][0])
                self.TCombobox1_6.set(self.bigdict[self.sts.get()][1])
                self.TCombobox1_7.set(self.bigdict[self.sts.get()][2])
                self.TCombobox1_9.set(self.bigdict[self.sts.get()][5])
                self.TCombobox1_10.configure(
                    textvar=self.cirselect,
                    values=policerDict[self.devselect.get()])
                self.TCombobox1_10.set(self.bigdict[self.sts.get()][3])
                self.TCombobox1_11.configure(
                    textvar=self.pirselect,
                    values=policerDict[self.devselect.get()])
                self.TCombobox1_11.set('Select')

            serv = Server(self.serverlogin, self.server, self.scriptPath, '*')
            if serv.up:
                self.bigdict = serv.retrieveRemoteFile(bigdict=True)
                self.sts = StringVar(self.Frame3_10)
                self.TCombobox1_8.configure(state='readonly')
                self.TCombobox1_8.configure(textvar=self.sts,
                                            values=self.bigdict.keys())
                self.TCombobox1_8.bind("<<ComboboxSelected>>", updateothers)
            else:
                Dialog(self.parent,
                       prompt='Can not access server \n' + server + ' \n')

        # revert date
        self.TCombobox1_9 = ttk.Combobox(self.Frame3_10)
        self.TCombobox1_9.place(relx=0.505,
                                rely=0.35,
                                relheight=0.326,
                                relwidth=0.448)
        self.TCombobox1_9.configure(takefocus="")

        self.TLabel1_11 = ttk.Label(self.Frame3_10)
        self.TLabel1_11.place(relx=0.02, rely=0.02, height=29, width=130)
        self.TLabel1_11.configure(background="#d9d9d9")
        self.TLabel1_11.configure(foreground="#000000")
        self.TLabel1_11.configure(font="TkDefaultFont")
        self.TLabel1_11.configure(relief='flat')
        self.TLabel1_11.configure(text='''Service ticket''')
        self.TLabel1_11.configure(width=130)

        self.TLabel1_12 = ttk.Label(self.Frame3_10)
        self.TLabel1_12.place(relx=0.505, rely=0.02, height=29, width=180)
        self.TLabel1_12.configure(background="#d9d9d9")
        self.TLabel1_12.configure(foreground="#000000")
        self.TLabel1_12.configure(font="TkDefaultFont")
        self.TLabel1_12.configure(relief='flat')
        self.TLabel1_12.configure(text='''Revert date''')

        self.TLabel1_13 = ttk.Label(self.Frame3_10)
        self.TLabel1_13.place(relx=0.50, rely=0.70, height=20, width=240)
        self.TLabel1_13.configure(justify='left')
        font14 = "-family {Segoe UI} -size 7 -weight normal -slant "  \
             "italic -underline 0 -overstrike 0"
        self.TLabel1_13.configure(font=font14, anchor='w')
        self.TLabel1_13.configure(text='eg: June 1 2019 or 10 days')

        self.Frame3_11 = Tkinter.Frame(self.Frame3)
        self.Frame3_11.place(relx=0.037,
                             rely=0.504,
                             relheight=0.261,
                             relwidth=0.925)
        self.Frame3_11.configure(relief='groove')
        self.Frame3_11.configure(borderwidth="2")
        self.Frame3_11.configure(relief='groove')
        self.Frame3_11.configure(background="#d9d9d9")
        self.Frame3_11.configure(highlightbackground="#d9d9d9")
        self.Frame3_11.configure(highlightcolor="black")
        self.Frame3_11.configure(width=495)

        self.cirselect = Tkinter.StringVar(self.Frame3_11)
        self.TCombobox1_10 = ttk.Combobox(self.Frame3_11)
        self.TCombobox1_10.place(relx=0.02,
                                 rely=0.258,
                                 relheight=0.2,
                                 relwidth=0.448)
        self.TCombobox1_10.configure(takefocus="")

        self.pirselect = Tkinter.StringVar(self.Frame3_11)
        self.TCombobox1_11 = ttk.Combobox(self.Frame3_11)
        self.TCombobox1_11.place(relx=0.505,
                                 rely=0.258,
                                 relheight=0.2,
                                 relwidth=0.448)
        self.TCombobox1_11.configure(takefocus="")

        self.TLabel1_11 = ttk.Label(self.Frame3_11)
        self.TLabel1_11.place(relx=0.02, rely=0.516, height=29, width=190)
        self.TLabel1_11.configure(background="#d9d9d9")
        self.TLabel1_11.configure(foreground="#000000")
        self.TLabel1_11.configure(font="TkDefaultFont")
        self.TLabel1_11.configure(relief='flat')
        self.TLabel1_11.configure(text='''Client name (optional)''')
        self.TLabel1_11.configure(width=190)

        self.TLabel1_12 = ttk.Label(self.Frame3_11)
        self.TLabel1_12.place(relx=0.02, rely=0.06, height=29, width=180)
        self.TLabel1_12.configure(background="#d9d9d9")
        self.TLabel1_12.configure(foreground="#000000")
        self.TLabel1_12.configure(font="TkDefaultFont")
        self.TLabel1_12.configure(relief='flat')
        self.TLabel1_12.configure(text='''Standard subscription''')
        self.TLabel1_12.configure(width=180)

        self.TLabel1_13 = ttk.Label(self.Frame3_11)
        self.TLabel1_13.place(relx=0.505, rely=0.06, height=29, width=210)
        self.TLabel1_13.configure(background="#d9d9d9")
        self.TLabel1_13.configure(foreground="#000000")
        self.TLabel1_13.configure(font="TkDefaultFont")
        self.TLabel1_13.configure(relief='flat')
        self.TLabel1_13.configure(text='''On-demand subscription''')
        self.TLabel1_13.configure(width=210)

        self.TEntry1_12 = ttk.Entry(self.Frame3_11)
        self.TEntry1_12.place(relx=0.02,
                              rely=0.71,
                              relheight=0.2,
                              relwidth=0.94)
        self.TEntry1_12.configure(takefocus="")
        self.TEntry1_12.configure(cursor="ibeam")

        self.Button1 = Tkinter.Button(self.Frame3)
        self.Button1.place(relx=0.093, rely=0.857, height=42, width=158)
        self.Button1.configure(pady="0")
        self.Button1.configure(text='''Submit''')
        self.Button1.configure(
            command=lambda: conf(self, ipDict, intDict, policerDict))

        self.Button1_13 = Tkinter.Button(self.Frame3)
        self.Button1_13.place(relx=0.579, rely=0.857, height=42, width=158)
        self.Button1_13.configure(pady="0")
        self.Button1_13.configure(text='''Clear''')
        self.Button1_13.configure(command=lambda: self.clear())
Exemplo n.º 10
0
 def view(self):
    if self.status.up:
       return self.status.retrieveRemoteFile(self.login)
    else: Dialog(parent,prompt='Can not access server \n'+self.server+' \n',icon=self.error)
Exemplo n.º 11
0
def readsettings(parent):
    warning = warning_icon
    try:
        settingsfile = open('settings', 'r')
        settingsfile = ' '.join((''.join(settingsfile)).split('\n'))
        line = settingsfile
        if re.findall(r'auth-se.?=.?(\S+)', line):
            authserver = re.findall(r'auth-se.?=.?(\S+)', line)[0]
        else:
            d = Settings(None)
            Dialog(
                d,
                resizable=False,
                nobutton=True,
                icon=warning,
                prompt=
                'Authentication server not found \nPlease go to general settings tab \nand specify the authentication server \n'
            )
            d.mainloop()
            return
        if re.findall(r'devdata.?=.?(\S+)', line):
            devicedbpath = re.findall(r'devdata.?=.?(\S+)', line)[0]
        else:
            d = Settings(None, paths=[authserver])
            Dialog(
                d,
                resizable=False,
                nobutton=True,
                icon=warning,
                prompt=
                'Devices database not found \nPlease go to general settings tab \nand specify the database full location \n'
            )
            d.mainloop()
            return
        if re.findall(r'bp-serv.?=.?(\S+)', line):
            burstserver = re.findall(r'bp-serv.?=.?(\S+)', line)[0]
        else:
            burstserver = ''

        if re.findall(r'bp-user.?=.?(\S+)', line):
            burstuser = re.findall(r'bp-user.?=.?(\S+)', line)[0]
        else:
            burstuser = ''

        if re.findall(r'bp-data.?=.?(\S+)', line):
            burstdb = re.findall(r'bp-data.?=.?(\S+)', line)[0]
        else:
            burstdb = ''

        if re.findall(r'bd-serv.?=.?(\S+)', line):
            ondemserver = re.findall(r'bd-serv.?=.?(\S+)', line)[0]
        else:
            ondemserver = ''

        if re.findall(r'bd-user.?=.?(\S+)', line):
            ondemuser = re.findall(r'bd-user.?=.?(\S+)', line)[0]
        else:
            ondemuser = ''

        if re.findall(r'bd--pwd.?=.?(\S+)', line):
            ondempwd = re.findall(r'bd--pwd.?=.?(\S+)', line)[0]
        else:
            ondempwd = ''

        paths = [
            authserver, devicedbpath, burstserver, burstuser, burstdb,
            ondemserver, ondemuser, ondempwd
        ]

        return paths

    except IOError:
        d = Settings(None)
        Dialog(
            d,
            resizable=False,
            nobutton=True,
            icon=warning,
            prompt=
            'System settings are missing.  \nGeneral settings are required for system to work  \nPlease setup the system and restart the application  \n'
        )
        d.mainloop()
        return False
Exemplo n.º 12
0
    def save(self, settings):

        settingsdict = {}
        try:
            settingsfile = open('settings')
            for line in settingsfile:
                if re.findall(r'^(general|burst|ondem)', line):
                    key = line.strip()
                    settingsdict[key] = []
                else:
                    settingsdict[key].append(line.strip())
            settingsfile.close()
        except IOError:
            pass

        if settings == 'general':
            devdata = self.TEntry1.get()
            auth_se = self.TEntry2.get()
            if not devdata or not auth_se:
                Dialog(self, prompt='Please fill all the field \n')
                return
            try:
                settingsdict.pop('general')
            except KeyError:
                pass
            settingsdict['general'] = [
                'devdata = ' + devdata, 'auth-se = ' + auth_se
            ]

        elif settings == 'burst':
            bp_serv = self.TEntry3.get()
            bp_user = self.TEntry4.get()
            bp_data = self.TEntry5.get()
            if not bp_serv or not bp_user or not bp_data:
                Dialog(self, prompt='Please fill all the field \n')
                return
            try:
                settingsdict.pop('burst')
            except KeyError:
                pass
            settingsdict['burst'] = [
                'bp-serv = ' + bp_serv, 'bp-user = '******'bp-data = ' + bp_data
            ]

        elif settings == 'ondem':
            bd_serv = self.TEntry6.get()
            bd_user = self.TEntry7.get()
            bd__pwd = self.TEntry8.get()
            if not bd_serv or not bd_user or not bd__pwd:
                Dialog(self, prompt='Please fill all the field \n')
                return
            try:
                settingsdict.pop('ondem')
            except KeyError:
                pass
            settingsdict['ondem'] = [
                'bd-serv = ' + bd_serv, 'bd-user = '******'bd--pwd = ' + bd__pwd
            ]

        subprocess.check_call(["attrib", "-H", "settings"])
        settingsfile = open('settings', 'w')
        for key in settingsdict.keys():
            settingsfile.write(key + '\n')
            for item in settingsdict[key]:
                settingsfile.write(' ' + item + '\n')
        settingsfile.close()
        subprocess.check_call(["attrib", "+H", "settings"])
        self.destroy()
        return
Exemplo n.º 13
0
    def __init__(self, parent, ipDict, intDict, policerDict, serverdata,
                 choice):

        pe = parent.TCombobox1_4.get()
        if not pe in ipDict.keys():
            Dialog(parent, prompt="Edge router unknown\n", icon=warning_icon)
            return

        iface = parent.TCombobox1_5.get()
        if not iface in intDict[pe] or iface == 'Null':
            Dialog(parent, prompt="Interface unknown\n")
            return

        vlan = parent.TCombobox1_6.get()
        try:
            if int(vlan) not in range(0, 4095):
                Dialog(parent, prompt="VLAN not in correct range\n")
                return
        except ValueError:
            Dialog(parent, prompt="VLAN not in correct range\n")
            return

        if choice != 'Remove client':
            days = parent.TCombobox1_7.get()
            if not days:
                Dialog(parent, prompt="Specify applicable days\n")
                return

            st = parent.TCombobox1_8.get()
            if not st:
                Dialog(parent, prompt="Specify start time\n")
                return

            et = parent.TCombobox1_9.get()
            if not et:
                Dialog(parent, prompt="Specify end time\n")
                return

            cir = parent.TCombobox1_10.get()
            if not cir in policerDict[pe]:
                Dialog(parent, prompt="CIR is not defined\n")
                return

            pir = parent.TCombobox1_11.get()
            if not pir in policerDict[pe]:
                Dialog(parent, prompt="PIR is not defined\n")
                return

            ds = parent.TEntry1_12.get()
            if not ds:
                Dialog(parent, prompt="Client name is not defined\n")
                return
            ds = ds.replace(' ', '-')

            data = [pe, iface, vlan, cir, pir, st, et, days, ds]
        else:
            data = [pe, iface, vlan]

        serverlogin = serverdata[0]
        server = serverdata[1]
        FQP = serverdata[2]

        parent.loading = loading(parent.Frame3,
                                 parent,
                                 pbar=[0.093, 0.9, 0.08, 0.300],
                                 words='Loading')
        parent.update_idletasks()

        bEditorbutton(parent, serverlogin, server, FQP, choice, data)

        parent.config(cursor='')
        parent.update()
        parent.loading.stop(parent)

        parent.clear()