def __addr_fetch(self) -> ReturnCode:
        token = fdm_login(host=self.origin_addr,
                          port=self.port,
                          username=self.username,
                          password=self.password)
        networks = fdm_get_networks(
            token,
            host=self.origin_addr,
            port=self.port,
        )

        for obj in networks['items']:
            if obj['subType'] == "HOST":
                if obj['value'] == str(self.ip_addr):
                    self.name = obj['name']
                    self.id = obj['id']
                    return ReturnCode.SUCCESS

        return ReturnCode.OBJECT_NOT_FOUND
Exemple #2
0
    def __range_fetch(self) -> ReturnCode:
        token = fdm_login(host=self.origin_addr,
                          port=self.port,
                          username=self.username,
                          password=self.password)
        networks = fdm_get_networks(token,
                                    host=self.origin_addr,
                                    port=self.port,)

        for obj in networks['items']:
            if obj['subType'] == "RANGE":
                first_addr = re.search(self.range_regex, obj['value']).group("first_addr")
                last_addr = re.search(self.range_regex, obj['value']).group("last_addr")
                if ip_address(first_addr) == self.first_addr \
                    and ip_address(last_addr) == self.last_addr:
                    self.name = obj['name']
                    self.id = obj['id']
                    return ReturnCode.SUCCESS

        return ReturnCode.OBJECT_NOT_FOUND