How to use the fmcapi.api_objects.device_services.devicerecords.DeviceRecords function in fmcapi

To help you get started, we’ve selected a few fmcapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daxm / fmcapi / fmcapi / api_objects / policy_services / hitcounts.py View on Github external
def device(self, name='', id=''):
        logging.debug("In device() for HitCounts class")
        if id != '':
            self.device_id = id
        elif name != '':
            device1 = DeviceRecords(fmc=self.fmc)
            device1.get(name=name)
            if 'id' in device1.__dict__:
                self.device_id = device1.id
            else:
                logging.warning(f'Device "{name}" not found.  Cannot configure device for HitCounts.')
        else:
            logging.error('No device name or id was provided.')
        # Rebuild the URL with possible new information
        self.URL = self.URL.split('?')[0]
        self.URL = f'{self.URL}{self.URL_SUFFIX}'
github daxm / fmcapi / fmcapi / api_objects / device_services / ipv6staticroutes.py View on Github external
def device(self, device_name):
        """
        Associate device to this route.

        :param device_name: (str) Name of device.
        :return: None
        """
        logging.debug("In device() for IPv6StaticRoute class.")
        device1 = DeviceRecords(fmc=self.fmc)
        device1.get(name=device_name)
        if "id" in device1.__dict__:
            self.device_id = device1.id
            self.URL = f"{self.fmc.configuration_url}{self.PREFIX_URL}/{self.device_id}/routing/ipv6staticroutes"
            self.device_added_to_url = True
        else:
            logging.warning(
                f"Device {device_name} not found.  Cannot set up device for IPv6StaticRoute."
            )
github daxm / fmcapi / fmcapi / api_objects / device_services / devicerecords.py View on Github external
logging.warning(f'Access Control Policy {name} not found.  Cannot set up accessPolicy for DeviceRecords.')

    def post(self, **kwargs):
        logging.debug("In post() for Device class.")
        response = super().post(**kwargs)
        if 'post_wait_time' in kwargs:
            self.post_wait_time = kwargs['post_wait_time']
        else:
            self.post_wait_time = 300
        logging.info(f'DeviceRecords registration task submitted.  '
                     f'Waiting {self.post_wait_time} seconds for it to complete.')
        time.sleep(self.post_wait_time)
        return response


class Device(DeviceRecords):
    """Dispose of this Class after 20210101."""

    def __init__(self, fmc, **kwargs):
        warnings.resetwarnings()
        warnings.warn("Deprecated: Device() should be called via DeviceRecords().")
        super().__init__(fmc, **kwargs)
github daxm / fmcapi / fmcapi / api_objects / device_services / etherchannelinterfaces.py View on Github external
def device(self, device_name):
        """
        Associate device to EtherChannel.

        :param device_name: (str) Name of device.
        :return: None
        """
        logging.debug("In device() for EtherchannelInterfaces class.")
        device1 = DeviceRecords(fmc=self.fmc)
        device1.get(name=device_name)
        if "id" in device1.__dict__:
            self.device_id = device1.id
            self.URL = f"{self.fmc.configuration_url}{self.PREFIX_URL}/{self.device_id}/etherchannelinterfaces"
            self.device_added_to_url = True
        else:
            logging.warning(
                f"Device {device_name} not found.  Cannot set up device for EtherchannelInterfaces."
            )
github daxm / fmcapi / fmcapi / api_objects / device_services / redundantinterfaces.py View on Github external
def device(self, device_name):
        """
        Associate device to this redundant interface.

        :param device_name: (str) Name of device.
        :return: None
        """
        logging.debug("In device() for RedundantInterfaces class.")
        device1 = DeviceRecords(fmc=self.fmc)
        device1.get(name=device_name)
        if "id" in device1.__dict__:
            self.device_id = device1.id
            self.URL = f"{self.fmc.configuration_url}{self.PREFIX_URL}/{self.device_id}/redundantinterfaces"
            self.device_added_to_url = True
        else:
            logging.warning(
                f'Device "{device_name}" not found.  Cannot set up device for RedundantInterfaces.'
            )
github daxm / fmcapi / fmcapi / api_objects / update_packages / upgradepackage.py View on Github external
def devices(self, devices):
        """
        List of devices.

        :param devices: (list) List of device names.
        :return: None
        """
        logging.debug("In devices() for Upgrades class.")
        for device in devices:
            device1 = DeviceRecords(fmc=self.fmc)
            device1.get(name=device)
            if "id" in device1.__dict__ and "targets" in self.__dict__:
                self.targets.append(
                    {"id": device1.id, "type": device1.type, "name": device1.name}
                )
            elif "id" in device1.__dict__:
                self.targets = [
                    {"id": device1.id, "type": device1.type, "name": device1.name}
                ]
            else:
                logging.warning(
                    f'Device "{device}" not found.  Cannot prepare devices for Upgrades.'
                )
github daxm / fmcapi / fmcapi / api_objects / device_services / bridgegroupinterfaces.py View on Github external
def device(self, device_name):
        """
        Associate device to this group.

        :param device_name: (str) Name of device.
        :return: None
        """
        logging.debug("In device() for BridgeGroupInterfaces class.")
        device1 = DeviceRecords(fmc=self.fmc)
        device1.get(name=device_name)
        if "id" in device1.__dict__:
            self.device_id = device1.id
            self.URL = f"{self.fmc.configuration_url}{self.PREFIX_URL}/{self.device_id}/bridgegroupinterfaces"
            self.device_added_to_url = True
        else:
            logging.warning(
                f"Device {device_name} not found.  Cannot set up device for BridgeGroupInterfaces."
            )