Ejemplo n.º 1
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties
        - Init Glance Clients to each region
        - Init GlanceSync client
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = context.config[PROPERTIES_CONFIG_GLANCESYNC] \
        [PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]

    # Init Glance operation managers. Only 'base' managers relative to "CREDENTIAL_TYPE_BASE_ADMIN" credential type
    # Format: {Spain: GlanceOperations, Trento: GlanceOperations}
    __logger__.info("Initiating Glance managers for testing")
    context.glance_manager_list = dict()
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        if CREDENTIAL_TYPE_BASE_ADMIN in cred[PROPERTIES_CONFIG_CRED_TYPE]:
            region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_USER]
            password = cred[PROPERTIES_CONFIG_CRED_PASS]
            tenant_id = cred[PROPERTIES_CONFIG_CRED_TENANT_ID]
            auth_url = cred[PROPERTIES_CONFIG_CRED_KEYSTONE_URL]

            # Init GlanceOperation
            glance_ops = GlanceOperations(username, password, tenant_id, auth_url, region_name)
            context.glance_manager_list.update({region_name: glance_ops})

    __logger__.debug("Glance operation managers list: %s", context.glance_manager_list)

    # Init GlanceSync client (master node)
    __logger__.info("Initiating GlanceSync client")
    context.glancesync_client = None
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
        if region_name == context.master_region_name:
            hostname = cred[PROPERTIES_CONFIG_CRED_HOST_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_HOST_USER]
            password = cred[PROPERTIES_CONFIG_CRED_HOST_PASSWORD]
            key = cred[PROPERTIES_CONFIG_CRED_HOST_KEY]
            config_file_path = context.config[PROPERTIES_CONFIG_GLANCESYNC] \
                [PROPERTIES_CONFIG_GLANCESYNC_CONFIG_FILE]
            glancesyc_bin_path = context.config[PROPERTIES_CONFIG_GLANCESYNC] \
                [PROPERTIES_CONFIG_GLANCESYNC_BIN_PATH]
            context.glancesync_client = GlanceSyncClient(hostname, username, password,
                                                         configuration_file_path=config_file_path,
                                                         glancesyc_bin_path=glancesyc_bin_path,
                                                         master_keyfile=key)
            break

    if context.glancesync_client is None:
        assert context.glancesync_client, \
            "GlanceSync configuration for '%s' not found".format(context.master_region_name)

    __logger__.debug("GlanceSync client created for master region '%s'", context.master_region_name)
Ejemplo n.º 2
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties.
        - Init Glance client.
        - Init GlanceSync API Client.
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = \
        context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]
    __logger__.info("Master Region set to '%s'", context.master_region_name)

    # Init Glance operation managers. Only 'base' managers relative to "CREDENTIAL_TYPE_BASE_ADMIN" credential type
    # Format: {Spain: GlanceOperations, Trento: GlanceOperations}
    __logger__.info("Initiating Glance managers for testing purposes")
    context.glance_manager_list = dict()
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        if CREDENTIAL_TYPE_BASE_ADMIN in cred[PROPERTIES_CONFIG_CRED_TYPE]:
            region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_USER]
            password = cred[PROPERTIES_CONFIG_CRED_PASS]
            tenant_id = cred[PROPERTIES_CONFIG_CRED_TENANT_ID]
            auth_url = cred[PROPERTIES_CONFIG_CRED_KEYSTONE_URL]

            # Init GlanceOperation
            glance_ops = GlanceOperations(username, password, tenant_id, auth_url, region_name)
            context.glance_manager_list.update({region_name: glance_ops})

    __logger__.debug("Glance operation managers list: %s", context.glance_manager_list)

    # Init GlanceSync API Client
    __logger__.info("Initiating GlanceSync API Client")

    keystone_url = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_CRED_KEYSTONE_URL]
    tenant_id = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_CRED_TENANT_ID]
    username = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_CRED_USER]
    password = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_CRED_PASS]

    host = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_API_GLANCESYNC_HOST]
    protocol = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_API_GLANCESYNC_PROTOCOL]
    port = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_API_GLANCESYNC_PORT]
    base_resource = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][PROPERTIES_CONFIG_API_GLANCESYNC_RESOURCE]

    context.glancesync_api_client = GlanceSyncApiClient(username, password, tenant_id, keystone_url,
                                                        protocol, host, port, base_resource)
Ejemplo n.º 3
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties
        - Write information into log file
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = \
        context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]
Ejemplo n.º 4
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties.
        - Init Glance client.
        - Init GlanceSync API Client.
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = \
        context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]
    __logger__.info("Master Region set to '%s'", context.master_region_name)

    # Init Glance operation managers. Only 'base' managers relative to "CREDENTIAL_TYPE_BASE_ADMIN" credential type
    # Format: {Spain: GlanceOperations, Trento: GlanceOperations}
    __logger__.info("Initiating Glance managers for testing purposes")
    context.glance_manager_list = dict()
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        if CREDENTIAL_TYPE_BASE_ADMIN in cred[PROPERTIES_CONFIG_CRED_TYPE]:
            region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_USER]
            password = cred[PROPERTIES_CONFIG_CRED_PASS]
            tenant_id = cred[PROPERTIES_CONFIG_CRED_TENANT_ID]
            auth_url = cred[PROPERTIES_CONFIG_CRED_KEYSTONE_URL]

            # Init GlanceOperation
            glance_ops = GlanceOperations(username, password, tenant_id,
                                          auth_url, region_name)
            context.glance_manager_list.update({region_name: glance_ops})

    __logger__.debug("Glance operation managers list: %s",
                     context.glance_manager_list)

    # Init GlanceSync client (master node)
    __logger__.info("Initiating GlanceSync client")
    context.glancesync_cmd_client = None
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
        if region_name == context.master_region_name:
            hostname = cred[PROPERTIES_CONFIG_CRED_HOST_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_HOST_USER]
            password = cred[PROPERTIES_CONFIG_CRED_HOST_PASSWORD]
            key = cred[PROPERTIES_CONFIG_CRED_HOST_KEY]
            config_file_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_CONFIG_FILE]

            glancesyc_bin_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_BIN_PATH]

            context.glancesync_cmd_client = GlanceSyncRemoteCmdClient(
                hostname,
                username,
                password,
                configuration_file_path=config_file_path,
                glancesyc_bin_path=glancesyc_bin_path,
                master_keyfile=key)
            break

    if context.glancesync_cmd_client is None:
        assert context.glancesync_cmd_client, \
            "GlanceSync configuration for '%s' not found".format(context.master_region_name)

    __logger__.debug("Glance operation managers list: %s",
                     context.glance_manager_list)

    # Init GlanceSync API Client
    __logger__.info("Initiating GlanceSync API Client")

    keystone_url = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_CRED_KEYSTONE_URL]
    tenant_id = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_CRED_TENANT_ID]
    username = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_CRED_USER]
    password = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_CRED_PASS]

    host = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_API_GLANCESYNC_HOST]
    protocol = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_API_GLANCESYNC_PROTOCOL]
    port = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_API_GLANCESYNC_PORT]
    base_resource = context.config[PROPERTIES_CONFIG_API_GLANCESYNC][
        PROPERTIES_CONFIG_API_GLANCESYNC_RESOURCE]

    context.glancesync_api_client = GlanceSyncApiClient(
        username, password, tenant_id, keystone_url, protocol, host, port,
        base_resource)
Ejemplo n.º 5
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties
        - Init Glance Clients to each region
        - Init GlanceSync client
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = \
        context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]

    # Download external resources
    __logger__.info("Downloading external resources defined in properties")
    resource_list = context.config[PROPERTIES_CONFIG_RES]
    for resource in resource_list:
        path = os.path.join(IMAGES_DIR, resource[PROPERTIES_CONFIG_RES_NAME])
        if os.path.isfile(path):
            __logger__.debug("Resource file '%s' already available", resource[PROPERTIES_CONFIG_RES_NAME])
        else:
            resource_file = urllib2.urlopen(resource[PROPERTIES_CONFIG_RES_url])
            with open(path, 'wb') as output_file:
                output_file.write(resource_file.read())
                __logger__.debug("New resource downloaded '%s'", path)

    # Init Glance operation managers. Only 'base' managers relative to "CREDENTIAL_TYPE_BASE_ADMIN" credential type
    # Format: {Spain: GlanceOperations, Trento: GlanceOperations}
    __logger__.info("Initiating Glance managers for testing")
    context.glance_manager_list = dict()
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        if CREDENTIAL_TYPE_BASE_ADMIN in cred[PROPERTIES_CONFIG_CRED_TYPE]:
            region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_USER]
            password = cred[PROPERTIES_CONFIG_CRED_PASS]
            tenant_id = cred[PROPERTIES_CONFIG_CRED_TENANT_ID]
            auth_url = cred[PROPERTIES_CONFIG_CRED_KEYSTONE_URL]

            # Init GlanceOperation
            glance_ops = GlanceOperations(username, password, tenant_id, auth_url, region_name)
            context.glance_manager_list.update({region_name: glance_ops})

    __logger__.debug("Glance operation managers list: %s", context.glance_manager_list)

    # Init GlanceSync client (master node)
    __logger__.info("Initiating GlanceSync client")
    context.glancesync_cmd_client = None
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
        if region_name == context.master_region_name:
            hostname = cred[PROPERTIES_CONFIG_CRED_HOST_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_HOST_USER]
            password = cred[PROPERTIES_CONFIG_CRED_HOST_PASSWORD]
            key = cred[PROPERTIES_CONFIG_CRED_HOST_KEY]
            config_file_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_CONFIG_FILE]

            glancesyc_bin_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_BIN_PATH]

            context.glancesync_cmd_client = GlanceSyncRemoteCmdClient(hostname, username, password,
                                                                      configuration_file_path=config_file_path,
                                                                      glancesyc_bin_path=glancesyc_bin_path,
                                                                      master_keyfile=key)
            break

    if context.glancesync_cmd_client is None:
        assert context.glancesync_cmd_client, \
            "GlanceSync configuration for '%s' not found".format(context.master_region_name)

    __logger__.debug("GlanceSync client created for master region '%s'", context.master_region_name)
Ejemplo n.º 6
0
def before_all(context):
    """
    HOOK: To be executed before all:
        - Load project properties
        - Init Glance Clients to each region
        - Init GlanceSync client
    """

    __logger__.info("SetUp execution")

    # Load project properties
    __logger__.info("Loading project properties")
    context.config = load_project_properties()
    context.master_region_name = \
        context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_MASTER_REGION_NAME]

    # Download external resources
    __logger__.info("Downloading external resources defined in properties")
    resource_list = context.config[PROPERTIES_CONFIG_RES]
    for resource in resource_list:
        path = os.path.join(IMAGES_DIR, resource[PROPERTIES_CONFIG_RES_NAME])
        if os.path.isfile(path):
            __logger__.debug("Resource file '%s' already available", resource[PROPERTIES_CONFIG_RES_NAME])
        else:
            resource_file = urllib2.urlopen(resource[PROPERTIES_CONFIG_RES_url])
            with open(path, 'wb') as output_file:
                output_file.write(resource_file.read())
                __logger__.debug("New resource downloaded '%s'", path)

    # Init Glance operation managers. Only 'base' managers relative to "CREDENTIAL_TYPE_BASE_ADMIN" credential type
    # Format: {Spain: GlanceOperations, Trento: GlanceOperations}
    __logger__.info("Initiating Glance managers for testing")
    context.glance_manager_list = dict()
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        if CREDENTIAL_TYPE_BASE_ADMIN in cred[PROPERTIES_CONFIG_CRED_TYPE]:
            region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_USER]
            password = cred[PROPERTIES_CONFIG_CRED_PASS]
            tenant_id = cred[PROPERTIES_CONFIG_CRED_TENANT_ID]
            auth_url = cred[PROPERTIES_CONFIG_CRED_KEYSTONE_URL]

            # Init GlanceOperation
            glance_ops = GlanceOperations(username, password, tenant_id, auth_url, region_name)
            context.glance_manager_list.update({region_name: glance_ops})

    __logger__.debug("Glance operation managers list: %s", context.glance_manager_list)

    # Init GlanceSync client (master node)
    __logger__.info("Initiating GlanceSync client")
    context.glancesync_cmd_client = None
    for cred in context.config[PROPERTIES_CONFIG_CRED]:
        region_name = cred[PROPERTIES_CONFIG_CRED_REGION_NAME]
        if region_name == context.master_region_name:
            hostname = cred[PROPERTIES_CONFIG_CRED_HOST_NAME]
            username = cred[PROPERTIES_CONFIG_CRED_HOST_USER]
            password = cred[PROPERTIES_CONFIG_CRED_HOST_PASSWORD]
            key = cred[PROPERTIES_CONFIG_CRED_HOST_KEY]
            config_file_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_CONFIG_FILE]

            glancesyc_bin_path = \
                context.config[PROPERTIES_CONFIG_GLANCESYNC][PROPERTIES_CONFIG_GLANCESYNC_BIN_PATH]

            context.glancesync_cmd_client = GlanceSyncRemoteCmdClient(hostname, username, password,
                                                                      configuration_file_path=config_file_path,
                                                                      glancesyc_bin_path=glancesyc_bin_path,
                                                                      master_keyfile=key)
            break

    if context.glancesync_cmd_client is None:
        assert context.glancesync_cmd_client, \
            "GlanceSync configuration for '%s' not found".format(context.master_region_name)

    __logger__.debug("GlanceSync client created for master region '%s'", context.master_region_name)