util.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:oneview-redfish-toolkit 作者: HewlettPackard 项目源码 文件源码
def load_config(conf_file):
    """Loads redfish.conf file

        Loads and parsers the system conf file into config global var
        Loads json schemas into schemas_dict global var
        Established a connection with OneView and sets in as ov_conn
        global var

        Args:
            conf_file: string with the conf file name

        Returns:
            None

        Exception:
            OneViewRedfishResourceNotFoundError:
                - if conf file not found
                - if any of the schemas files are not found
                - if the schema directory is not found
            OneViewRedFishResourceNotAccessibleError:
                - if can't access schema's directory
            HPOneViewException:
                - if fails to connect to oneview
    """

    config = load_conf(conf_file)
    globals()['config'] = config

    # Config file read set global vars
    # Setting ov_config
    ov_config = dict(config.items('oneview_config'))
    ov_config['credentials'] = dict(config.items('credentials'))
    ov_config['api_version'] = int(ov_config['api_version'])
    globals()['ov_config'] = ov_config

    # Setting schemas_dict
    schemas = dict(config.items('schemas'))
    globals()['schemas'] = schemas

    registries = dict(config.items('registry'))

    # Load schemas | Store schemas | Connect to OneView
    try:
        ov_client = OneViewClient(ov_config)

        globals()['ov_client'] = ov_client

        registry_dict = load_registry(
            config['redfish']['registry_dir'],
            registries)
        globals()['registry_dict'] = registry_dict

        store_schemas(config['redfish']['schema_dir'])
    except errors.OneViewRedfishResourceNotFoundError as e:
        raise errors.OneViewRedfishError(
            'Failed to load schemas or registries: {}'.format(e)
        )
    except Exception as e:
        raise errors.OneViewRedfishError(
            'Failed to connect to OneView: {}'.format(e)
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号