use of com.sequenceiq.cloudbreak.cloud.model.publickey.PublicKeyUnregisterRequest in project cloudbreak by hortonworks.
the class EnvironmentResourceService method deletePublicKey.
public void deletePublicKey(Environment environment, String publicKeyId) {
try {
LOGGER.info("Try to delete the ssh key ({}) for {}", publicKeyId, environment.getName());
PublicKeyConnector publicKeyConnector = getPublicKeyConnector(environment.getCloudPlatform()).orElseThrow(() -> new BadRequestException("No public key connector for cloud platform: " + environment.getCloudPlatform()));
PublicKeyUnregisterRequest request = createPublicKeyUnregisterRequest(environment, publicKeyId);
publicKeyConnector.unregister(request);
LOGGER.info("the ssh key ({}) deleted successfully for {}", publicKeyId, environment.getName());
} catch (UnsupportedOperationException e) {
LOGGER.info("Cloud platform {} does not support public key services", environment.getCloudPlatform());
}
}
use of com.sequenceiq.cloudbreak.cloud.model.publickey.PublicKeyUnregisterRequest in project cloudbreak by hortonworks.
the class AwsPublicKeyConnectorTest method unregisterNotFoundDoesNotThrow.
@Test
void unregisterNotFoundDoesNotThrow() {
PublicKeyUnregisterRequest request = generateUnregisterRequest();
when(ec2client.deleteKeyPair(any())).thenThrow(new AmazonServiceException("no such key"));
underTest.unregister(request);
ArgumentCaptor<DeleteKeyPairRequest> captor = ArgumentCaptor.forClass(DeleteKeyPairRequest.class);
verify(ec2client).deleteKeyPair(captor.capture());
DeleteKeyPairRequest result = captor.getValue();
assertThat(result.getKeyName()).isEqualTo(PUBLIC_KEY_ID);
verifyNoMoreInteractions(ec2client);
}
use of com.sequenceiq.cloudbreak.cloud.model.publickey.PublicKeyUnregisterRequest in project cloudbreak by hortonworks.
the class AwsPublicKeyConnectorTest method unregister.
@Test
void unregister() {
PublicKeyUnregisterRequest request = generateUnregisterRequest();
underTest.unregister(request);
ArgumentCaptor<DeleteKeyPairRequest> captor = ArgumentCaptor.forClass(DeleteKeyPairRequest.class);
verify(ec2client).deleteKeyPair(captor.capture());
DeleteKeyPairRequest result = captor.getValue();
assertThat(result.getKeyName()).isEqualTo(PUBLIC_KEY_ID);
verifyNoMoreInteractions(ec2client);
}
Aggregations