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'.")
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)
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)
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)
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)
def test_init_mount_spec(remote_environment): mount = Mount(remote_environment, 'mount_path', 'shared_path') MountSpecification([mount], OwnershipSpecification(10, 10))
def test_init_ownership_spec_bad_gid(): with pytest.raises(IncorrectTypeError) as err_info: OwnershipSpecification(10, '10') assert err_info.value.message == ( "OwnershipSpecification's parameter 'gid' was type 'str' but" " should be of type 'int'.")
def test_init_ownership_spec(): OwnershipSpecification(10, 10)