當前位置: 首頁>>代碼示例>>Java>>正文


Java VolumeMount類代碼示例

本文整理匯總了Java中org.springframework.cloud.servicebroker.model.VolumeMount的典型用法代碼示例。如果您正苦於以下問題:Java VolumeMount類的具體用法?Java VolumeMount怎麽用?Java VolumeMount使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


VolumeMount類屬於org.springframework.cloud.servicebroker.model包,在下文中一共展示了VolumeMount類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initialize

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
@PostConstruct
public void initialize() throws EcsManagementClientException,
        EcsManagementResourceNotFoundException, URISyntaxException {
    S3Config s3Config = new S3Config(
            new URI(broker.getRepositoryEndpoint()));
    s3Config.withIdentity(broker.getPrefixedUserName())
            .withSecretKey(broker.getRepositorySecret());
    this.s3 = new S3JerseyClient(s3Config);
    this.bucket = broker.getPrefixedBucketName();

    // NOTE -- ideally we would not need this code, but for now, the VolumeMount class has
    // custom serialization that is not matched with corresponding deserialization, so
    // deserializing serialized volume mounts doesn't work OOTB.
    SimpleModule module = new SimpleModule();
    module.addDeserializer(VolumeMount.DeviceType.class, new DeviceTypeDeserializer());
    module.addDeserializer(VolumeMount.Mode.class, new ModeDeserializer());
    module.addDeserializer(VolumeDevice.class, new VolumeDeviceDeserializer());
    objectMapper.registerModule(module);
}
 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:20,代碼來源:ServiceInstanceBindingRepository.java

示例2: removeBinding

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
@Override
public void removeBinding(ServiceInstanceBinding binding)
        throws EcsManagementClientException, IOException {
    ServiceInstance instance = instanceRepository.find(instanceId);
    if (instance == null)
        throw new ServiceInstanceDoesNotExistException(instanceId);
    String bucketName = instance.getName();
    List<VolumeMount> volumes = binding.getVolumeMounts();
    if (volumes != null && volumes.size() > 0) {
        Map<String, Object> mountConfig = (
                    (SharedVolumeDevice) volumes.get(0).getDevice()
                ).getMountConfig();
        String unixId = (String) mountConfig.get("uid");
        LOG.error("Deleting user map of instance Id and Binding Id " +
                bucketName + " " + bindingId);
        try {
            ecs.deleteUserMap(bindingId, unixId);
        } catch (EcsManagementClientException e) {
            LOG.error("Error deleting user map: " + e.getMessage());
        }
    }

    ecs.removeUserFromBucket(bucketName, bindingId);
    ecs.deleteUser(bindingId);
}
 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:26,代碼來源:BucketBindingWorkflow.java

示例3: createVolumeExport

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
private List<VolumeMount> createVolumeExport(String export, URL baseUrl, Map<String, Object>parameters)
        throws EcsManagementClientException {
    int unixUid = createUserMap();
    String host = ecs.getNfsMountHost();
    if (host == null || host.isEmpty()) {
        host = baseUrl.getHost();
    }

    LOG.info("Adding export:  " + export + " to bucket: " + instanceId);
    String volumeGUID = UUID.randomUUID().toString();
    String absoluteExportPath = ecs.addExportToBucket(instanceId, export);
    LOG.info("export added.");

    Map<String, Object> opts = new HashMap<>();
    String nfsUrl = "nfs://" + host + absoluteExportPath;

    opts.put("source", nfsUrl);
    opts.put("uid", String.valueOf(unixUid));

    List<VolumeMount> mounts = new ArrayList<>();
    mounts.add(new VolumeMount(VOLUME_DRIVER, getContainerDir(parameters, bindingId),
            VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED,
            new SharedVolumeDevice(volumeGUID, opts)));

    return mounts;
}
 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:27,代碼來源:BucketBindingWorkflow.java

示例4: createBindingWithVolumeSucceeds

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
@Test
public void createBindingWithVolumeSucceeds() throws Exception {
	CreateServiceInstanceBindingRequest request = createRequest;
	CreateServiceInstanceAppBindingResponse response = ServiceInstanceBindingFixture.buildCreateAppBindingResponseWithVolumeMount();
	when(serviceInstanceBindingService.createServiceInstanceBinding(eq(request)))
			.thenReturn(response);
	VolumeMount volumeMount = response.getVolumeMounts().get(0);
	SharedVolumeDevice device = (SharedVolumeDevice) volumeMount.getDevice();

	setupCatalogService(request.getServiceDefinitionId());

	mockMvc.perform(put(buildCreateUrl(false))
			.content(DataFixture.toJson(request))
			.accept(MediaType.APPLICATION_JSON)
			.contentType(MediaType.APPLICATION_JSON))
			.andExpect(status().isCreated())
			.andExpect(jsonPath("$.credentials").doesNotExist())
			.andExpect(jsonPath("$.syslog_drain_url").doesNotExist())
			.andExpect(jsonPath("$.volume_mounts[0].driver", is(volumeMount.getDriver())))
			.andExpect(jsonPath("$.volume_mounts[0].container_dir", is(volumeMount.getContainerDir())))
			.andExpect(jsonPath("$.volume_mounts[0].mode", is(volumeMount.getMode().toString())))
			.andExpect(jsonPath("$.volume_mounts[0].device_type", is(volumeMount.getDeviceType().toString())))
			.andExpect(jsonPath("$.volume_mounts[0].device.volume_id", is(device.getVolumeId())))
			.andExpect(jsonPath("$.volume_mounts[0].device.mount_config", is(device.getMountConfig())));
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-cloudfoundry-service-broker,代碼行數:26,代碼來源:ServiceInstanceBindingControllerIntegrationTest.java

示例5: expected

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
private static VolumeMount expected() {
    Map<String, Object> mountConfig = new HashMap<>();
    mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions");
    mountConfig.put("attr_timeout", "0");
    mountConfig.put("negative_timeout", "2");
    final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig);
    return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice);
}
 
開發者ID:orange-cloudfoundry,項目名稱:static-creds-broker,代碼行數:9,代碼來源:VolumeMountMapperTest.java

示例6: expectedVolumeMount

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
private static VolumeMount expectedVolumeMount() {
    Map<String, Object> mountConfig = new HashMap<>();
    mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions");
    mountConfig.put("attr_timeout", "0");
    mountConfig.put("negative_timeout", "2");
    final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig);
    return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice);
}
 
開發者ID:orange-cloudfoundry,項目名稱:static-creds-broker,代碼行數:9,代碼來源:ConfigureServiceBrokerWithVolumeMountTest.java

示例7: expectedNfsv3SharedVolumeMount

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
private static VolumeMount expectedNfsv3SharedVolumeMount() {
    Map<String, Object> mountConfig = new HashMap<>();
    mountConfig.put("source", "nfs://1.2.3.4:25840/my/share/to/mount?uid=1004&gid=1004&auto_cache&multithread&default_permissions");
    mountConfig.put("attr_timeout", "0");
    mountConfig.put("negative_timeout", "2");
    final SharedVolumeDevice sharedVolumeDevice = new SharedVolumeDevice("bc2c1eab-05b9-482d-b0cf-750ee07de311", mountConfig);
    return new VolumeMount("nfsv3driver", "/data/images", VolumeMount.Mode.READ_WRITE, VolumeMount.DeviceType.SHARED, sharedVolumeDevice);
}
 
開發者ID:orange-cloudfoundry,項目名稱:static-creds-broker,代碼行數:9,代碼來源:CreateServiceInstanceVolumeBindingTest.java

示例8: deserialize

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
@Override
public VolumeMount.Mode deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JsonNode node = jp.getCodec().readTree(jp);
    String s = node.asText();
    if (s.equals("rw")) {
        return VolumeMount.Mode.READ_WRITE;
    } else {
        return VolumeMount.Mode.READ_ONLY;
    }
}
 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:11,代碼來源:ServiceInstanceBindingRepository.java

示例9: buildCreateAppBindingResponseWithVolumeMount

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
public static CreateServiceInstanceAppBindingResponse buildCreateAppBindingResponseWithVolumeMount() {
	return CreateServiceInstanceAppBindingResponse.builder()
			.volumeMounts(VolumeMount.builder()
					.driver("cephdriver")
					.containerDir("/data/images")
					.mode(VolumeMount.Mode.READ_WRITE)
					.deviceType(VolumeMount.DeviceType.SHARED)
					.device(SharedVolumeDevice.builder()
							.volumeId("volumeId")
							.mountConfig("configKey", "configValue")
							.build())
					.build())
			.build();
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-cloudfoundry-service-broker,代碼行數:15,代碼來源:ServiceInstanceBindingFixture.java

示例10: should_map_volume_mount

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
@Test
public void should_map_volume_mount() throws Exception {
    VolumeMountMapper mapper = new VolumeMountMapper();

    Assertions.assertThat(mapper.map(volumeMountProperties(), VolumeMount.class)).isEqualTo(expected());
}
 
開發者ID:orange-cloudfoundry,項目名稱:static-creds-broker,代碼行數:7,代碼來源:VolumeMountMapperTest.java

示例11: testCreateBucketUserWithExport

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
/**
 * The binding-service can create a user for a bucket (with parameters to
 * feed export & volume mount details), so long as the user doesn't exist.
 *
 * @throws JAXBException if there is a JSON serializaton error with repository
 * @throws IOException is unable to serialize JSON to string
 * @throws EcsManagementClientException if ecs management API returns an error
 */
@Test
public void testCreateBucketUserWithExport()
        throws IOException, JAXBException, EcsManagementClientException {
    when(catalog.findServiceDefinition(eq(BUCKET_SERVICE_ID)))
            .thenReturn(bucketServiceFixture());
    when(ecs.userExists(BINDING_ID)).thenReturn(false);
    when(ecs.getObjectEndpoint()).thenReturn(OBJ_ENDPOINT);
    when(ecs.getBucketFileEnabled(anyString())).thenReturn(true);
    when(ecs.getNfsMountHost()).thenReturn("foo");
    UserSecretKey userSecretKey = new UserSecretKey();
    userSecretKey.setSecretKey(TEST_KEY);
    when(ecs.createUser(BINDING_ID)).thenReturn(userSecretKey);
    doThrow(new EcsManagementClientException("Bad request body (1013)"))
            .doNothing()
            .when(ecs)
            .createUserMap(anyString(),anyInt());
    when(ecs.lookupServiceDefinition(BUCKET_SERVICE_ID))
            .thenReturn(bucketServiceFixture());
    ArgumentCaptor<ServiceInstanceBinding> bindingCaptor = ArgumentCaptor
            .forClass(ServiceInstanceBinding.class);
    when(ecs.prefix(BINDING_ID)).thenReturn(BINDING_ID);
    when(ecs.prefix(BINDING_ID + COLON + TEST_KEY))
            .thenReturn(BINDING_ID + COLON + TEST_KEY);
    when(ecs.prefix(SERVICE_INSTANCE_ID)).thenReturn(SERVICE_INSTANCE_ID);
    when(instanceRepository.find(SERVICE_INSTANCE_ID))
            .thenReturn(serviceInstanceFixture());
    doNothing().when(repository).save(bindingCaptor.capture());

    String absolutePath = "/" + NAMESPACE + "/" + SERVICE_INSTANCE_ID + "/" + EXPORT_NAME;

    when(ecs.addExportToBucket(eq(SERVICE_INSTANCE_ID), eq(EXPORT_NAME)))
            .thenReturn(absolutePath);

    bindSvc.createServiceInstanceBinding(bucketBindingExportRequestFixture());

    ServiceInstanceBinding binding = bindingCaptor.getValue();
    Map<String, Object> creds = binding.getCredentials();
    String s3Url = HTTP + BINDING_ID + COLON + TEST_KEY + "@127.0.0.1:9020/" + SERVICE_INSTANCE_ID;
    assertEquals(BINDING_ID, creds.get("accessKey"));
    assertEquals(SERVICE_INSTANCE_ID, creds.get("bucket"));
    assertEquals(TEST_KEY, creds.get(SECRET_KEY));
    assertEquals(s3Url, creds.get("s3Url"));

    List<VolumeMount> mounts = binding.getVolumeMounts();
    assertNotNull(mounts);
    String nfsUrl = NFS_SCHEME + "foo" + absolutePath;
    VolumeMount mount = mounts.get(0);
    SharedVolumeDevice device = (SharedVolumeDevice) mount.getDevice();
    Map<String, Object> volumeOpts = device.getMountConfig();

    assertEquals(1, mounts.size());
    assertEquals(DRIVER, mount.getDriver());
    assertEquals(VOLUME_MOUNT, mount.getContainerDir());
    assertEquals(VolumeMount.DeviceType.SHARED, mount.getDeviceType());
    assertEquals(VolumeMount.Mode.READ_WRITE, mount.getMode());
    assertEquals(String.class, device.getVolumeId().getClass());
    assertEquals(nfsUrl, volumeOpts.get("source"));


    verify(ecs, times(1)).createUser(BINDING_ID);
    verify(ecs, times(2)).createUserMap(anyString(), anyInt());
    verify(ecs, times(1)).userExists(BINDING_ID);
    verify(repository).save(any(ServiceInstanceBinding.class));
    verify(ecs, times(1)).addUserToBucket(eq(SERVICE_INSTANCE_ID), eq(BINDING_ID));
    verify(ecs, times(1)).addExportToBucket(eq(SERVICE_INSTANCE_ID), eq(EXPORT_NAME));
}
 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:75,代碼來源:EcsServiceInstanceBindingServiceTest.java

示例12: getVolumeMounts

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
public List<VolumeMount> getVolumeMounts() { return volumeMounts; } 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:2,代碼來源:ServiceInstanceBinding.java

示例13: setVolumeMounts

import org.springframework.cloud.servicebroker.model.VolumeMount; //導入依賴的package包/類
public void setVolumeMounts(List<VolumeMount> volumeMounts) { this.volumeMounts = volumeMounts; } 
開發者ID:codedellemc,項目名稱:ecs-cf-service-broker,代碼行數:2,代碼來源:ServiceInstanceBinding.java


注:本文中的org.springframework.cloud.servicebroker.model.VolumeMount類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。