def __init__(self, dd_controller, curr_nat_sessions): self.EVENT_ADD = Constants.EVENT_ADD self.EVENT_UPDATE = Constants.EVENT_UPDATE self.EVENT_DELETE = Constants.EVENT_DELETE ######################### YANG CONSTANTS ######################### self.SILENT = Constants.ADVERTISE_SILENT self.ON_CHANGE = Constants.ADVERTISE_ON_CHANGE self.PERIODIC = Constants.ADVERTISE_PERIODIC self.url_natSession = "config-nat:nat/nat-table/nat-session" self.elements = {} self.elements['natSession'] = Element(advertise=self.ON_CHANGE) ################################################################## self.periods = [] for key, element in self.elements.items(): if element.advertise == self.PERIODIC: element.period = element.period / 1000 if element.period not in self.periods: self.periods.append(element.period) self.on_change_interval = ConfigurationInstance( ).get_on_change_interval() logging.debug("on_change_interval: " + str(self.on_change_interval)) self.nat_sessions_old = curr_nat_sessions print("nat_sessions_old: " + str(len(self.nat_sessions_old))) self.nat_sessions_new = [] self.nat_sessions_removed = [] self.ddController = dd_controller self.natTableController = NatTableController() self.natTableParser = NatTableParser()
def __init__(self, dd_controller, curr_whitelist): self.EVENT_ADD = Constants.EVENT_ADD self.EVENT_UPDATE = Constants.EVENT_UPDATE self.EVENT_DELETE = Constants.EVENT_DELETE ######################### YANG CONSTANTS ######################### self.SILENT = Constants.ADVERTISE_SILENT self.ON_CHANGE = Constants.ADVERTISE_ON_CHANGE self.PERIODIC = Constants.ADVERTISE_PERIODIC self.url_whitelist = "config-firewall:firewall/whitelist" self.url_name = "/url" self.elements = {} self.elements['url'] = Element(advertise=self.ON_CHANGE) ################################################################## self.periods = [] for key, element in self.elements.items(): if element.advertise == self.PERIODIC: element.period = element.period / 1000 if element.period not in self.periods: self.periods.append(element.period) self.on_change_interval = ConfigurationInstance().get_on_change_interval() logging.debug("on_change_interval: " + str(self.on_change_interval)) self.whitelist_old = curr_whitelist print("whitelist_old: " + str(len(self.whitelist_old))) self.whitelist_new = [] self.whitelist_updated = [] self.whitelist_removed = [] self.ddController = dd_controller self.whitelistController = WhitelistController()
def wait_for_selector(self, selector, timeout=0): """ :param selector: :param page: :param timeout: :return: """ return Element(asyncio.get_event_loop().run_until_complete(self.__waitForSelector(self.page, selector, timeout=timeout)))
def get_elements_by_xpath(self, xpath): """ find element by xpath :param page: page object :param xpath: the string to query element in the page source :return: list contain all element for selector """ return [Element(i) for i in asyncio.get_event_loop().run_until_complete(self.__get_elements_by_xpath(self.page, xpath=xpath))]
def get_elements_by_selector(self, selector): """ find element by selector , :param page: page object :param selector: the string to query element in the page source :return: list contain all element for selector """ return [Element(i) for i in asyncio.get_event_loop().run_until_complete(self.__get_elements_by_selector(self.page, selector=selector))]
def get_element_by_selector(self, selector): """ find element by selector , if not only one selector finded , default return first element :param page: page object :param selector: the string to query element in the page source :return: """ return Element(asyncio.get_event_loop().run_until_complete(self.__get_element_by_selector(self.page, selector=selector)))
def wait_for_function(self, pageFunction, *args, timeout=0): """ :param page: :param pageFunction: Function to be evaluated in browser context :param timeout: int maximum time to wait for in milliseconds. Defaults to 30000 (30 seconds). Pass 0 to disable timeout. :param args: Arguments to pass to pageFunction :return: """ return Element(asyncio.get_event_loop().run_until_complete(self.__waitForFunction(self.page, pageFunction, *args, timeout=timeout)))
def __init__(self, dd_controller, curr_dhcp_clients): self.EVENT_ADD = Constants.EVENT_ADD self.EVENT_UPDATE = Constants.EVENT_UPDATE self.EVENT_DELETE = Constants.EVENT_DELETE ######################### YANG CONSTANTS ######################### self.SILENT = Constants.ADVERTISE_SILENT self.ON_CHANGE = Constants.ADVERTISE_ON_CHANGE self.PERIODIC = Constants.ADVERTISE_PERIODIC self.url_clients = "config-dhcp-server:server/clients" self.elements = {} self.elements['client'] = Element(advertise=self.ON_CHANGE) ################################################################## self.periods = [] for key, element in self.elements.items(): if element.advertise == self.PERIODIC: element.period = element.period / 1000 if element.period not in self.periods: self.periods.append(element.period) self.on_change_interval = ConfigurationInstance( ).get_on_change_interval() logging.debug("on_change_interval: " + str(self.on_change_interval)) self.dhcp_clients_old = curr_dhcp_clients logging.debug("dhcp_clients_old: " + str(len(self.dhcp_clients_old))) self.dhcp_clients_new = [] self.dhcp_clients_updated = [] self.dhcp_clients_removed = [] self.ddController = dd_controller self.dhcpClientController = DhcpClientController() self.dhcpClientParser = DhcpClientParser()
def __init__(self, dd_controller, curr_interfaces): self.EVENT_ADD = Constants.EVENT_ADD self.EVENT_UPDATE = Constants.EVENT_UPDATE self.EVENT_DELETE = Constants.EVENT_DELETE ######################### YANG CONSTANTS ######################### self.SILENT = Constants.ADVERTISE_SILENT self.ON_CHANGE = Constants.ADVERTISE_ON_CHANGE self.PERIODIC = Constants.ADVERTISE_PERIODIC self.url_iface = "interfaces/ifEntry" self.elements = {} self.elements['interface'] = Element(advertise=self.ON_CHANGE) ################################################################## self.periods = [] for key, element in self.elements.items(): if element.advertise == self.PERIODIC: element.period = element.period/1000 if element.period not in self.periods: self.periods.append(element.period) self.on_change_interval = float(ConfigurationInstance().get_on_change_interval()) logging.debug("on_change_interval: " + str(self.on_change_interval)) self.interfaces_old = curr_interfaces print("interfaces_old: " + str(len(self.interfaces_old))) self.interfaces_new = [] self.interfaces_updated = [] self.interfaces_removed = [] self.ddController = dd_controller self.interfaceController = InterfaceController() self.interfaceParser = InterfaceParser()
def get_elements_by_xpath(self, xpath): return [ Element(i) for i in asyncio.get_event_loop().run_until_complete( self.__get_elements_by_xpath(self.frame, xpath=xpath)) ]
def get_elements_by_selector(self, selector): return [ Element(i) for i in asyncio.get_event_loop().run_until_complete( self.__get_elements_by_selector(self.frame, selector=selector)) ]
def wait_for_xpath(self, xpath, timeout=0): return Element(asyncio.get_event_loop().run_until_complete(self.__waitForXpath(self.page, xpath, timeout=timeout)))
def __init__(self, dd_controller, curr_dhcpServer_configuration): self.EVENT_ADD = Constants.EVENT_ADD self.EVENT_UPDATE = Constants.EVENT_UPDATE self.EVENT_DELETE = Constants.EVENT_DELETE ######################### YANG CONSTANTS ######################### self.SILENT = Constants.ADVERTISE_SILENT self.ON_CHANGE = Constants.ADVERTISE_ON_CHANGE self.PERIODIC = Constants.ADVERTISE_PERIODIC self.url_dhcpServerConfiguration = "config-dhcp-server:server/" self.url_defaultLeaseTime = self.url_dhcpServerConfiguration + "/defaultLeaseTime" self.url_maxLeaseTime = self.url_dhcpServerConfiguration + "/maxLeaseTime" self.url_subnet = self.url_dhcpServerConfiguration + "/subnet" self.url_subnetMask = self.url_dhcpServerConfiguration + "/subnetMask" self.url_router = self.url_dhcpServerConfiguration + "/router" self.url_dns_primaryServer = self.url_dhcpServerConfiguration + "/dnsPrimaryServer" self.url_dns_secondaryServer = self.url_dhcpServerConfiguration + "/dnsSecondaryServer" self.url_dns_domainName = self.url_dhcpServerConfiguration + "/dnsDomainName" self.url_sections = self.url_dhcpServerConfiguration + "/sections" self.url_section_startIP = "/sectionStartIp" self.url_section_endIP = "/sectionEndIp" self.elements = {} self.elements['server'] = Element(advertise=self.ON_CHANGE) self.elements['defaultLeaseTime'] = Element(advertise=self.SILENT) self.elements['maxLeaseTime'] = Element(advertise=self.SILENT) self.elements['subnet'] = Element(advertise=self.SILENT) self.elements['subnetMask'] = Element(advertise=self.SILENT) self.elements['router'] = Element(advertise=self.SILENT) self.elements['dnsPrimaryServer'] = Element(advertise=self.SILENT) self.elements['dnsSecondaryServer'] = Element(advertise=self.SILENT) self.elements['dnsDomainName'] = Element(advertise=self.SILENT) self.elements['sections'] = Element(advertise=self.SILENT) self.elements['section'] = Element(advertise=self.SILENT) self.elements['sectionStartIp'] = Element(advertise=self.SILENT) self.elements['sectionEndIp'] = Element(advertise=self.SILENT) ################################################################## self.periods = [] for key, element in self.elements.items(): if element.advertise == self.PERIODIC: element.period = element.period / 1000 if element.period not in self.periods: self.periods.append(element.period) self.on_change_interval = ConfigurationInstance().get_on_change_interval() logging.debug("on_change_interval: " + str(self.on_change_interval)) self.dhcpServerConfig_old = curr_dhcpServer_configuration self.dhcpServerConfig_new = None self.ddController = dd_controller self.dhcpServerController = DhcpServerController() self.dhcpServerParser = DhcpServerParser()