Exemple #1
0
def get_connector(credentials=None):
    grid_id = cfg.CONF.infoblox.cloud_data_center_id
    grid_opts = cfg.get_infoblox_grid_opts(grid_id)
    # map connector options to config
    # None as value means no name change needed
    mapping = {
        'host': 'grid_master_host',
        'username': '******',
        'password': '******',
        'wapi_version': None,
        'ssl_verify': None,
        'http_pool_connections': None,
        'http_pool_maxsize': None,
        'http_request_timeout': None
    }
    opts = {
        field:
        grid_opts[mapping[field]] if mapping[field] else grid_opts[field]
        for field in mapping
    }
    if opts['ssl_verify'] == 'False':
        opts['silent_ssl_warnings'] = True
    if credentials:
        opts['username'] = credentials['username']
        opts['password'] = credentials['password']
    return conn.Connector(opts)
def create_ea_defs(grid_id):
    print("\nCreating EA definitions...")
    print("-" * PRINT_LINE)
    print("")

    credentials = get_credentias()
    conn = utils.get_connector(credentials)

    if not (utils.get_features(conn).create_ea_def):
        LOG.error("WAPI Version '%s' is not supported - Script ABORTED!",
                  conn.wapi_version)
        exit(1)

    mgr = object_manager.InfobloxObjectManager(conn)
    ea_defs_created = mgr.create_required_ea_definitions(
        const.REQUIRED_EA_DEFS, reraise=True)
    if ea_defs_created:
        print("The following EA Definitions have been created: '%s'" %
              [ea_def['name'] for ea_def in ea_defs_created])
    else:
        print("All the EAs has been already created.")
    print("\n")

    grid_opts = config.get_infoblox_grid_opts(grid_id)
    gm_name = grid_opts['grid_master_name']
    member = objects.Member.search(conn, host_name=gm_name)

    if member is None:
        LOG.error("Cannot retrieve member information at GM='%s'" %
                  gm_name)
        exit(1)

    print("Adding grid configuration EAs to the grid master...")
    print("-" * PRINT_LINE)
    print("")
    ea_set = {}
    if member.extattrs is None:
        member.extattrs = objects.EA({})
    for ea, val in const.GRID_CONFIG_DEFAULTS.items():
        if (member.extattrs.get(ea) is None and
                not (val is None or val == [])):
            ea_set[ea] = val
            member.extattrs.set(ea, val)

    if ea_set:
        print("Grid configurations: '%s'" % ea_set)
        member.update()
    else:
        print("All the grid configurations have been already added.")
    print("\n")
def create_ea_defs(grid_id):
    print("\nCreating EA definitions...")
    print(("-" * PRINT_LINE))
    print("")

    credentials = get_credentias()
    conn = utils.get_connector(credentials)

    if not (utils.get_features(conn).create_ea_def):
        LOG.error("WAPI Version '%s' is not supported - Script ABORTED!",
                  conn.wapi_version)
        exit(1)

    mgr = object_manager.InfobloxObjectManager(conn)
    ea_defs_created = mgr.create_required_ea_definitions(
        const.REQUIRED_EA_DEFS, reraise=True)
    if ea_defs_created:
        print(("The following EA Definitions have been created: '%s'" %
               [ea_def['name'] for ea_def in ea_defs_created]))
    else:
        print("All the EAs has been already created.")
    print("\n")

    grid_opts = config.get_infoblox_grid_opts(grid_id)
    gm_name = grid_opts['grid_master_name']
    member = objects.Member.search(conn, host_name=gm_name)

    if member is None:
        LOG.error("Cannot retrieve member information at GM='%s'" % gm_name)
        exit(1)

    print("Adding grid configuration EAs to the grid master...")
    print(("-" * PRINT_LINE))
    print("")
    ea_set = {}
    if member.extattrs is None:
        member.extattrs = objects.EA({})
    for ea, val in list(const.GRID_CONFIG_DEFAULTS.items()):
        if (member.extattrs.get(ea) is None
                and not (val is None or val == [])):
            ea_set[ea] = val
            member.extattrs.set(ea, val)

    if ea_set:
        print(("Grid configurations: '%s'" % ea_set))
        member.update()
    else:
        print("All the grid configurations have been already added.")
    print("\n")
def get_connector(credentials=None):
    grid_id = cfg.CONF.infoblox.cloud_data_center_id
    grid_opts = cfg.get_infoblox_grid_opts(grid_id)
    # map connector options to config
    # None as value means no name change needed
    mapping = {'host': 'grid_master_host',
               'username': '******',
               'password': '******',
               'wapi_version': None,
               'ssl_verify': None,
               'http_pool_connections': None,
               'http_pool_maxsize': None,
               'http_request_timeout': None}
    opts = {field: grid_opts[mapping[field]]
            if mapping[field] else grid_opts[field]
            for field in mapping}
    if opts['ssl_verify'] == 'False':
        opts['silent_ssl_warnings'] = True
    if credentials:
        opts['username'] = credentials['username']
        opts['password'] = credentials['password']
    return conn.Connector(opts)
Exemple #5
0
 def _create_grid_configuration(context):
     grid_conf = GridConfiguration(context)
     grid_conf.grid_id = cfg.CONF.infoblox.cloud_data_center_id
     grid_opts = cfg.get_infoblox_grid_opts(grid_conf.grid_id)
     if not grid_opts['grid_master_host']:
         raise exc.InfobloxInvalidCloudDataCenter(
             data_center_id=grid_conf.grid_id)
     grid_conf.grid_name = grid_opts['data_center_name']
     grid_conf.grid_master_host = grid_opts['grid_master_host']
     grid_conf.grid_master_name = grid_opts['grid_master_name']
     grid_conf.admin_user_name = grid_opts['admin_user_name']
     grid_conf.admin_password = grid_opts['admin_password']
     grid_conf.wapi_version = grid_opts['wapi_version']
     grid_conf.ssl_verify = grid_opts['ssl_verify']
     grid_conf.http_request_timeout = grid_opts['http_request_timeout']
     grid_conf.http_pool_connections = grid_opts['http_pool_connections']
     grid_conf.http_pool_maxsize = grid_opts['http_pool_maxsize']
     grid_conf.wapi_max_results = grid_opts['wapi_max_results']
     grid_conf.wapi_paging = grid_opts['wapi_paging']
     # cloud user is used as admin, it needs to have proper permissions to
     # deal with non-delegated objects.
     gm_connection_opts = {
         'host': grid_conf.grid_master_host,
         'username': grid_conf.admin_user_name,
         'password': grid_conf.admin_password,
         'wapi_version': grid_conf.wapi_version,
         'ssl_verify': grid_conf.ssl_verify,
         'log_api_calls_as_info': True,
         'http_request_timeout': grid_conf.http_request_timeout,
         'http_pool_connections': grid_conf.http_pool_connections,
         'http_pool_maxsize': grid_conf.http_pool_maxsize,
         'max_results': grid_conf.wapi_max_results,
         'paging': grid_conf.wapi_paging
     }
     # Silent ssl warnings, if certificate verification is not enabled
     if gm_connection_opts['ssl_verify'] == 'False':
         gm_connection_opts['silent_ssl_warnings'] = True
     grid_conf.gm_connector = connector.Connector(gm_connection_opts)
     return grid_conf
Exemple #6
0
    def _create_grid_configuration(context):
        grid_conf = GridConfiguration(context)
        grid_conf.grid_id = cfg.CONF.infoblox.cloud_data_center_id
        grid_opts = cfg.get_infoblox_grid_opts(grid_conf.grid_id)
        if not grid_opts['grid_master_host']:
            raise exc.InfobloxInvalidCloudDataCenter(
                data_center_id=grid_conf.grid_id)
        grid_conf.grid_name = grid_opts['data_center_name']
        grid_conf.grid_master_host = grid_opts['grid_master_host']
        grid_conf.grid_master_name = grid_opts['grid_master_name']
        grid_conf.admin_user_name = grid_opts['admin_user_name']
        grid_conf.admin_password = grid_opts['admin_password']
        grid_conf.wapi_version = grid_opts['wapi_version']
        grid_conf.ssl_verify = grid_opts['ssl_verify']
        grid_conf.http_request_timeout = grid_opts['http_request_timeout']
        grid_conf.http_pool_connections = grid_opts['http_pool_connections']
        grid_conf.http_pool_maxsize = grid_opts['http_pool_maxsize']
        grid_conf.wapi_max_results = grid_opts['wapi_max_results']

        # cloud user is used as admin, it needs to have proper permissions to
        # deal with non-delegated objects.
        gm_connection_opts = {
            'host': grid_conf.grid_master_host,
            'username': grid_conf.admin_user_name,
            'password': grid_conf.admin_password,
            'wapi_version': grid_conf.wapi_version,
            'ssl_verify': grid_conf.ssl_verify,
            'log_api_calls_as_info': True,
            'http_request_timeout': grid_conf.http_request_timeout,
            'http_pool_connections': grid_conf.http_pool_connections,
            'http_pool_maxsize': grid_conf.http_pool_maxsize,
            'max_results': grid_conf.wapi_max_results}
        # Silent ssl warnings, if certificate verification is not enabled
        if gm_connection_opts['ssl_verify'] == 'False':
            gm_connection_opts['silent_ssl_warnings'] = True
        grid_conf.gm_connector = connector.Connector(gm_connection_opts)
        return grid_conf
    def _create_grid_configuration(context):
        grid_conf = GridConfiguration(context)
        grid_conf.grid_id = cfg.CONF.infoblox.cloud_data_center_id
        grid_opts = cfg.get_infoblox_grid_opts(grid_conf.grid_id)
        if not grid_opts["grid_master_host"]:
            raise exc.InfobloxInvalidCloudDataCenter(data_center_id=grid_conf.grid_id)
        grid_conf.grid_name = grid_opts["data_center_name"]
        grid_conf.grid_master_host = grid_opts["grid_master_host"]
        grid_conf.grid_master_name = grid_opts["grid_master_name"]
        grid_conf.admin_user_name = grid_opts["admin_user_name"]
        grid_conf.admin_password = grid_opts["admin_password"]
        grid_conf.wapi_version = grid_opts["wapi_version"]
        grid_conf.ssl_verify = grid_opts["ssl_verify"]
        grid_conf.http_request_timeout = grid_opts["http_request_timeout"]
        grid_conf.http_pool_connections = grid_opts["http_pool_connections"]
        grid_conf.http_pool_maxsize = grid_opts["http_pool_maxsize"]
        grid_conf.wapi_max_results = grid_opts["wapi_max_results"]

        # cloud user is used as admin, it needs to have proper permissions to
        # deal with non-delegated objects.
        gm_connection_opts = {
            "host": grid_conf.grid_master_host,
            "username": grid_conf.admin_user_name,
            "password": grid_conf.admin_password,
            "wapi_version": grid_conf.wapi_version,
            "ssl_verify": grid_conf.ssl_verify,
            "log_api_calls_as_info": True,
            "http_request_timeout": grid_conf.http_request_timeout,
            "http_pool_connections": grid_conf.http_pool_connections,
            "http_pool_maxsize": grid_conf.http_pool_maxsize,
            "max_results": grid_conf.wapi_max_results,
        }
        # Silent ssl warnings, if certificate verification is not enabled
        if gm_connection_opts["ssl_verify"] == "False":
            gm_connection_opts["silent_ssl_warnings"] = True
        grid_conf.gm_connector = connector.Connector(gm_connection_opts)
        return grid_conf