use of com.sequenceiq.cloudbreak.cloud.openstack.view.KeystoneCredentialView in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method sshKeys.
@Override
public CloudSshKeys sshKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
KeystoneCredentialView osCredential = openStackClient.createKeystoneCredential(cloudCredential);
Set<CloudSshKey> cloudSshKeys = new HashSet<>();
for (Keypair keypair : osClient.compute().keypairs().list()) {
Map<String, Object> properties = new HashMap<>();
properties.put("fingerprint", keypair.getFingerprint());
properties.put("id", keypair.getId());
properties.put("publicKey", keypair.getPublicKey());
properties.put("createdAt", keypair.getCreatedAt());
CloudSshKey cloudSshKey = new CloudSshKey();
cloudSshKey.setName(keypair.getName());
cloudSshKey.setProperties(properties);
cloudSshKeys.add(cloudSshKey);
}
Map<String, Set<CloudSshKey>> result = new HashMap<>();
result.put(region.value() == null ? osCredential.getTenantName() : region.value(), cloudSshKeys);
LOGGER.info("openstack cloud ssh keys result: {}", result);
return new CloudSshKeys(result);
}
use of com.sequenceiq.cloudbreak.cloud.openstack.view.KeystoneCredentialView in project cloudbreak by hortonworks.
the class OpenStackPlatformResources method securityGroups.
@Override
public CloudSecurityGroups securityGroups(CloudCredential cloudCredential, Region region, Map<String, String> filters) {
OSClient<?> osClient = openStackClient.createOSClient(cloudCredential);
KeystoneCredentialView osCredential = openStackClient.createKeystoneCredential(cloudCredential);
Set<CloudSecurityGroup> cloudSecurityGroups = new HashSet<>();
List<? extends SecGroupExtension> osSecurityGroups = osClient.compute().securityGroups().list();
LOGGER.info("security groups from openstack: {}", osSecurityGroups);
for (SecGroupExtension secGroup : osSecurityGroups) {
Map<String, Object> properties = new HashMap<>();
properties.put("tenantId", secGroup.getTenantId());
properties.put("rules", secGroup.getRules());
CloudSecurityGroup cloudSecurityGroup = new CloudSecurityGroup(secGroup.getName(), secGroup.getId(), properties);
cloudSecurityGroups.add(cloudSecurityGroup);
}
Map<String, Set<CloudSecurityGroup>> result = new HashMap<>();
result.put(region.value() == null ? osCredential.getTenantName() : region.value(), cloudSecurityGroups);
LOGGER.info("openstack security groups result: {}", result);
return new CloudSecurityGroups(result);
}
use of com.sequenceiq.cloudbreak.cloud.openstack.view.KeystoneCredentialView in project cloudbreak by hortonworks.
the class OpenStackClient method getV2TenantId.
public String getV2TenantId(AuthenticatedContext authenticatedContext) {
KeystoneCredentialView osCredential = createKeystoneCredential(authenticatedContext);
String facing = authenticatedContext.getCloudCredential().getStringParameter(FACING);
Access access = authenticatedContext.getParameter(Access.class);
return OSFactory.clientFromAccess(access, Facing.value(facing)).identity().tenants().getByName(osCredential.getTenantName()).getId();
}
Aggregations