def job(self, device, _): napalm_driver = napalm_connection(self, device) napalm_driver.open() config = f''' ip vrf {self.vrf_name} rd {self.local_as}:235 route-target import {self.local_as}:410 route-target export {self.local_as}:400 maximum route 10000 80 interface {self.loopback} ip vrf forwarding {self.vrf_name} ip address {self.loopback_ip} 255.255.255.255 router bgp {self.local_as} address-family ipv4 vrf {self.vrf_name} network {self.loopback_ip} mask 255.255.255.255 neighbor {self.neighbor_ip} remote-as {self.remote_as} neighbor {self.neighbor_ip} activate neighbor {self.neighbor_ip} send-community both neighbor {self.neighbor_ip} as-override exit-address-family ''' config = '\n'.join(config.splitlines()) getattr(napalm_driver, 'load_merge_candidate')(config=config) napalm_driver.commit_config() napalm_driver.close() return {'success': True, 'result': f'Config push ({config})'}
def job(self, device, payload): napalm_driver = napalm_connection(self, device) napalm_driver.open() config = '\n'.join(substitute(self.content, locals()).splitlines()) getattr(napalm_driver, self.action)(config=config) napalm_driver.commit_config() napalm_driver.close() return {'success': True, 'result': f'Config push ({config})'}
def job(self, device, payload): napalm_driver = napalm_connection(self, device) napalm_driver.open() traceroute = napalm_driver.traceroute(device.ip_address, source=self.source, vrf=self.vrf, ttl=self.ttl or 255, timeout=self.timeout or 2) napalm_driver.close() return {'success': 'success' in traceroute, 'result': traceroute}
def job(self, device, payload): napalm_driver = napalm_connection(self, device) napalm_driver.open() ping = napalm_driver.ping(device.ip_address, source=self.source, vrf=self.vrf, ttl=self.ttl or 255, timeout=self.timeout or 2, size=self.size or 100, count=self.count or 5) napalm_driver.close() return {'success': 'success' in ping, 'result': ping}
def job(self, device, payload): napalm_driver, result = napalm_connection(self, device), {} napalm_driver.open() for getter in self.getters: try: result[getter] = getattr(napalm_driver, getter)() except Exception as e: result[getter] = f'{getter} failed because of {e}' output, match = str(result), substitute(self.content_match, locals()) success = (self.content_match_regex and search(match, output) or match in output and not self.content_match_regex) napalm_driver.close() return {'success': success, 'result': result}
def job(self, device, _): napalm_driver, result = napalm_connection(self, device), {} napalm_driver.open() for getter in self.getters: try: result[getter] = getattr(napalm_driver, getter)() except Exception as e: result[getter] = f'{getter} failed because of {e}' match = substitute(self.content_match, locals()) napalm_driver.close() return { 'expected': match, 'negative_logic': self.negative_logic, 'result': result, 'success': self.match_content(str(result), match) }
def job(self, device, _): napalm_driver = napalm_connection(self, device) napalm_driver.open() napalm_driver.rollback() napalm_driver.close() return {'success': True, 'result': 'Rollback successful'}