Beispiel #1
0
def make_nonprimary_connection(primary_connection, secondary_env_ref,
                               secondary_user_ref):
    dummy_host = primary_connection.environment.host
    user = RemoteUser(name="unused", reference=secondary_user_ref)
    environment = RemoteEnvironment(name="unused",
                                    reference=secondary_env_ref,
                                    host=dummy_host)
    return RemoteConnection(environment=environment, user=user)
Beispiel #2
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)