def gw(self, name): logging.info("In gw() for IPv4StaticRoute class.") gw1 = Hosts(fmc=self.fmc) gw1.get(name=name) if "id" in gw1.__dict__: self.gateway = { "object": {"type": gw1.type, "id": gw1.id, "name": gw1.name} } else: logging.warning( f"Network {name} not found. Cannot set up device for IPv4StaticRoute." )
def encryption_domain(self, action, names=[]): """ Associate Encryption. :param action: (str) 'add', 'remove', or 'clear'. :param names: (list) List of Encryption names. """ logging.debug("In endpoint() for Endpoints class.") fqdns_json = FQDNS(fmc=self.fmc).get() host_json = Hosts(fmc=self.fmc).get() net_json = Networks(fmc=self.fmc).get() netg_json = NetworkGroups(fmc=self.fmc).get() items = ( fqdns_json.get("items", []) + host_json.get("items", []) + net_json.get("items", []) + netg_json.get("items", []) ) new_network = None if action == "add": for name in names: for item in items: if item["name"] == name: new_network = {"id": item["id"], "type": item["type"]} break if new_network is None: logging.warning( f'FQDNS/Host/Network/Network Group"{name}" is not found in FMC.' f" Cannot add to protectedNetworks." ) else: if "protectedNetworks" in self.__dict__: self.protectedNetworks["networks"].append(new_network) logging.info(f'Appending "{name}" to protectedNetworks.') else: self.protectedNetworks = {"networks": [new_network]} logging.info(f'Adding "{name}" to protectedNetworks.') elif action == "remove": if "protectedNetworks" in self.__dict__: for name in names: self.protectedNetworks = list( filter(lambda i: i["name"] != name, self.protectedNetworks) ) else: logging.warning( "protectedNetworks has no members. Cannot remove network." ) elif action == "clear": if "protectedNetworks" in self.__dict__: del self.protectedNetworks
def gw(self, name): """ Gateway for this route. :param name: (str) Name of object that is the gateway address. :return: None """ logging.info("In gw() for IPv6StaticRoute class.") gw1 = Hosts(fmc=self.fmc) gw1.get(name=name) if "id" in gw1.__dict__: self.gateway = { "object": {"type": gw1.type, "id": gw1.id, "name": gw1.name} } else: logging.warning( f'Network "{name}" not found. Cannot set up device for IPv6StaticRoute.' )