def test_init_mount_spec_bad_mounts():
     with pytest.raises(IncorrectTypeError) as err_info:
         MountSpecification(['string'], OwnershipSpecification(10, 10))
     assert err_info.value.message == (
         "MountSpecification's parameter 'mounts' was a list of"
         " [type 'str'] but should be of type 'list of dlpx.virtualization"
         ".platform._plugin_classes.Mount'.")
Example #2
0
def virtual_mount_specification(virtual_source, repository):
    logger.debug("virtual_mount_specification")
    mount_path = virtual_source.parameters.m_path
    logger.debug("Mount Path:" + mount_path)
    environment = virtual_source.connection.environment
    mounts = [Mount(environment, mount_path)]
    return MountSpecification(mounts)
 def test_init_mount_spec_mounts_not_list():
     with pytest.raises(IncorrectTypeError) as err_info:
         MountSpecification('string', OwnershipSpecification(10, 10))
     assert err_info.value.message == (
         "MountSpecification's parameter 'mounts' was type 'str' but"
         " should be of type 'list of dlpx.virtualization.platform"
         "._plugin_classes.Mount'.")
        def staged_mount_spec_impl(staged_source, repository):
            TestPlugin.assert_plugin_args(staged_source=staged_source,
                                                repository=repository)

            mount = Mount(
                staged_source.source_connection.environment, TEST_MOUNT_PATH)
            ownership_spec = OwnershipSpecification(TEST_UID, TEST_GID)

            return MountSpecification([mount], ownership_spec)
        def staged_mount_spec_impl(staged_source, repository):
            TestPlugin.assert_plugin_args(staged_source=staged_source,
                                          repository=repository)
            # setting the shared_path should fail in the wrapper
            mount = Mount(staged_source.source_connection.environment,
                          TEST_MOUNT_PATH, TEST_SHARED_PATH)
            ownership_spec = OwnershipSpecification(TEST_UID, TEST_GID)

            return MountSpecification([mount], ownership_spec)
Example #6
0
def staged_mount_specification(staged_source, repository):
    common.add_debug_heading_block("Start Staged Mount Specification")
    helpers._record_hook("staging mount specification",
                         staged_source.staged_connection)
    logger.debug("mount_path={}".format(staged_source.parameters.mount_path))
    mount = Mount(staged_source.staged_connection.environment,
                  staged_source.parameters.mount_path)
    common.add_debug_heading_block("End Staged Mount Specification")
    return MountSpecification([mount])
    def test_init_mount_spec_bad_owner_spec(remote_environment):
        mount = Mount(remote_environment, 'mount_path', 'shared_path')

        with pytest.raises(IncorrectTypeError) as err_info:
            MountSpecification([mount], 'string')
        assert err_info.value.message == (
            "MountSpecification's parameter 'ownership_specification' was"
            " type 'str' but should be of class 'dlpx.virtualization"
            ".platform._plugin_classes.OwnershipSpecification'"
            " if defined.")
Example #8
0
def linked_mount_specification(staged_source, repository):
    logger.debug("linked_mount_specification")
    try:
        mount_path = staged_source.parameters.mount_path
        logger.debug("Mount Path:" + mount_path)
        environment = staged_source.staged_connection.environment
        mounts = [Mount(environment, mount_path)]
    except Exception as err:
        logger.debug("ERROR: Error creating NFS Mount" + err.message)
        raise
    return MountSpecification(mounts)
        def virtual_mount_spec_impl(virtual_source, repository):
            TestPlugin.assert_plugin_args(virtual_source=virtual_source,
                                          repository=repository)

            primary_mount = Mount(virtual_source.connection.environment,
                                  TEST_MOUNT_PATH, TEST_SHARED_PATH)
            another_mount = Mount(virtual_source.connection.environment,
                                  TEST_MOUNT_PATH, TEST_SHARED_PATH)
            ownership_spec = OwnershipSpecification(TEST_UID, TEST_GID)

            return MountSpecification([primary_mount, another_mount],
                                      ownership_spec)
Example #10
0
def virtual_mount_specification(virtual_source, repository):
    mount_path = virtual_source.parameters.mount_path

    if check_stale_mountpoint(virtual_source.connection, mount_path):
        cleanup_process = CouchbaseOperation(
            Resource.ObjectBuilder.set_virtual_source(
                virtual_source).set_repository(repository).build())
        cleanup_process.stop_couchbase()
        clean_stale_mountpoint(virtual_source.connection, mount_path)

    check_server_is_used(virtual_source.connection, mount_path)

    mounts = [Mount(virtual_source.connection.environment, mount_path)]
    logger.debug("Mounting path {}".format(mount_path))
    logger.debug("Setting ownership to uid {} and gid {}".format(
        repository.uid, repository.gid))
    ownership_spec = OwnershipSpecification(repository.uid, repository.gid)

    logger.debug("in mounting: {}".format(
        str(virtual_source.parameters.node_list)))

    if virtual_source.parameters.node_list is not None and len(
            virtual_source.parameters.node_list) > 0:
        # more nodes
        for m in virtual_source.parameters.node_list:
            logger.debug("in loop: {}".format(str(m)))
            node_host = RemoteHost(name='foo',
                                   reference=m["environment"].replace(
                                       '_ENVIRONMENT', ''),
                                   binary_path="",
                                   scratch_path="")
            e = RemoteEnvironment("foo", m["environment"], node_host)
            mount = Mount(e, mount_path)
            mounts.append(mount)

            user = RemoteUser(name="unused", reference=m['environmentUser'])
            environment = RemoteEnvironment(name="unused",
                                            reference=m['environment'],
                                            host=node_host)
            clean_node_conn = RemoteConnection(environment=environment,
                                               user=user)

            if check_stale_mountpoint(clean_node_conn, mount_path):
                clean_node = CouchbaseOperation(
                    Resource.ObjectBuilder.set_virtual_source(
                        virtual_source).set_repository(repository).build(),
                    clean_node_conn)
                clean_node.stop_couchbase()
                clean_stale_mountpoint(clean_node_conn, mount_path)

            check_server_is_used(clean_node_conn, mount_path)

    return MountSpecification(mounts, ownership_spec)
Example #11
0
def mount_specification(repository, virtual_source):
    helpers._record_hook("virtual mount spec", virtual_source.connection)
    virtual_source.mongo_install_path = repository.mongo_install_path
    virtual_source.mongo_shell_path = repository.mongo_shell_path

    nodes = []
    nodes.append(virtual_source.connection.environment.reference)
    for node in virtual_source.parameters.additional_nodes:
        nodes.append(node['environment'])
    totalnodes = len(nodes)
    logger.info("Total Nodes : {}".format(totalnodes))
    logger.info("Nodes = {}".format(nodes))
    logger.info("Mount Path = {}".format(virtual_source.parameters.mount_path))

    nodemount_list = []
    for node in nodes:
        nodemount = Mount(node, virtual_source.parameters.mount_path)
        nodemount_list.append(nodemount)
    return MountSpecification(nodemount_list)
Example #12
0
def linked_mount_specification(staged_source, repository):
    mount_path = staged_source.parameters.mount_path

    if check_stale_mountpoint(staged_source.staged_connection, mount_path):
        cleanup_process = CouchbaseOperation(
            Resource.ObjectBuilder.set_staged_source(
                staged_source).set_repository(repository).build())
        cleanup_process.stop_couchbase()
        clean_stale_mountpoint(staged_source.staged_connection, mount_path)

    check_server_is_used(staged_source.staged_connection, mount_path)

    environment = staged_source.staged_connection.environment
    linked.check_mount_path(staged_source, repository)
    logger.debug("Mounting path {}".format(mount_path))
    mounts = [Mount(environment, mount_path)]
    logger.debug("Setting ownership to uid {} and gid {}".format(
        repository.uid, repository.gid))
    ownership_spec = OwnershipSpecification(repository.uid, repository.gid)
    return MountSpecification(mounts, ownership_spec)
Example #13
0
def linked_mount_specification(staged_source, repository):
    mount_path = staged_source.parameters.mount_path
    environment = staged_source.staged_connection.environment
    linked.check_mount_path(staged_source, repository)
    mounts = [Mount(environment, mount_path)]
    return MountSpecification(mounts)
Example #14
0
def virtual_mount_specification(virtual_source, repository):
    mount_path = virtual_source.parameters.mount_path
    mounts = [Mount(virtual_source.connection.environment, mount_path)]
    return MountSpecification(mounts)
 def test_init_mount_spec(remote_environment):
     mount = Mount(remote_environment, 'mount_path', 'shared_path')
     MountSpecification([mount], OwnershipSpecification(10, 10))