Example #1
0
 def test_str_to_bool(self):
     self.assertTrue(str_to_bool('True'))
     self.assertTrue(str_to_bool('true'))
     self.assertTrue(str_to_bool('YES'))
     self.assertFalse(str_to_bool('truex'))
     self.assertTrue(str_to_bool(1))
     self.assertTrue(str_to_bool('1'))
     self.assertFalse(str_to_bool(0))
     self.assertFalse(str_to_bool('0'))
Example #2
0
def permission_to_edit(tab, opts):
    """
    Gets the config and determines if the UI had been locked or is allowed to be edited.
    :param tab: class or instance that's a subclass of ui.Tab
    :return: If app.config locks the tab or not
    """
    if opts.get(tab.SECTION):
        section_lock = str_to_bool(opts.get(tab.SECTION).get(UI_LOCK))
        return not section_lock
    if opts.get('integrations'):
        integrations_lock = str_to_bool(opts.get('integrations').get(UI_LOCK))
        return not integrations_lock
    if opts.get('resilient'):
        global_lock = str_to_bool(opts.get('resilient').get(UI_LOCK))
        return not global_lock

    return True
    def __init__(self, opts, location, vsys=None):
        pan_config = opts.get("fn_pa_panorama")
        pan_config["location"] = location

        # validate config fields
        validate_fields(["panorama_host", "api_key", "location"], pan_config)

        self.__key = pan_config["api_key"]
        self.__location = pan_config["location"]
        self.__vsys = vsys
        self.__output_format = "json"

        self.verify = str_to_bool(pan_config.get("cert", "True"))
        self.host = pan_config["panorama_host"]
        self.rc = RequestsCommon(opts, pan_config)
        self.query_parameters = self.__build_query_parameters()