本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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());
}
示例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));
}
示例12: getVolumeMounts
import org.springframework.cloud.servicebroker.model.VolumeMount; //导入依赖的package包/类
public List<VolumeMount> getVolumeMounts() { return volumeMounts; }
示例13: setVolumeMounts
import org.springframework.cloud.servicebroker.model.VolumeMount; //导入依赖的package包/类
public void setVolumeMounts(List<VolumeMount> volumeMounts) { this.volumeMounts = volumeMounts; }