use of com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient in project cloudbreak by hortonworks.
the class AzureResourceConnector method collectResourcesToRemove.
@Override
public Map<String, Map<String, Object>> collectResourcesToRemove(AuthenticatedContext ac, CloudStack stack, List<CloudResource> resources, List<CloudInstance> vms) {
AzureClient client = ac.getParameter(AzureClient.class);
AzureCredentialView azureCredentialView = new AzureCredentialView(ac.getCloudCredential());
String stackName = azureUtils.getStackName(ac.getCloudContext());
Map<String, Map<String, Object>> resp = new HashMap<>(vms.size());
for (CloudInstance instance : vms) {
resp.put(instance.getInstanceId(), collectInstanceResourcesToRemove(ac, stack, client, azureCredentialView, stackName, instance));
}
return resp;
}
use of com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient in project cloudbreak by hortonworks.
the class AzureResourceConnector method check.
@Override
public List<CloudResourceStatus> check(AuthenticatedContext authenticatedContext, List<CloudResource> resources) {
List<CloudResourceStatus> result = new ArrayList<>();
AzureClient client = authenticatedContext.getParameter(AzureClient.class);
String stackName = azureUtils.getStackName(authenticatedContext.getCloudContext());
for (CloudResource resource : resources) {
switch(resource.getType()) {
case ARM_TEMPLATE:
LOGGER.info("Checking Azure group stack status of: {}", stackName);
try {
CloudResourceStatus templateResourceStatus;
if (client.templateDeploymentExists(stackName, stackName)) {
Deployment resourceGroupDeployment = client.getTemplateDeployment(stackName, stackName);
templateResourceStatus = azureUtils.getTemplateStatus(resource, resourceGroupDeployment, client, stackName);
} else {
templateResourceStatus = new CloudResourceStatus(resource, ResourceStatus.DELETED);
}
result.add(templateResourceStatus);
} catch (CloudException e) {
if (e.response().code() == AzureConstants.NOT_FOUND) {
result.add(new CloudResourceStatus(resource, ResourceStatus.DELETED));
} else {
throw new CloudConnectorException(e.body().message(), e);
}
} catch (RuntimeException e) {
throw new CloudConnectorException(String.format("Invalid resource exception: %s", e.getMessage()), e);
}
break;
case AZURE_NETWORK:
case AZURE_SUBNET:
break;
default:
throw new CloudConnectorException(String.format("Invalid resource type: %s", resource.getType()));
}
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient in project cloudbreak by hortonworks.
the class AzureResourceGroupValidator method validate.
@Override
public void validate(AuthenticatedContext ac, CloudStack cloudStack) {
AzureClient client = ac.getParameter(AzureClient.class);
String resourceGroupName = azureUtils.getResourceGroupName(ac.getCloudContext());
boolean exists = client.resourceGroupExists(resourceGroupName);
if (exists) {
throw new CloudConnectorException(String.format("Resource group is already exists with the given name: %s", resourceGroupName));
}
}
use of com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient in project cloudbreak by hortonworks.
the class AzureSetup method prepareImage.
@Override
public void prepareImage(AuthenticatedContext ac, CloudStack stack, Image image) {
LOGGER.info("prepare image: {}", image);
String imageResourceGroupName = armStorage.getImageResourceGroupName(ac.getCloudContext(), stack);
String region = ac.getCloudContext().getLocation().getRegion().value();
AzureClient client = ac.getParameter(AzureClient.class);
try {
copyVhdImageIfNecessary(ac, stack, image, imageResourceGroupName, region, client);
} catch (Exception ex) {
LOGGER.error("Could not create image with the specified parameters", ex);
throw new CloudConnectorException("Image creation failed because " + image.getImageName() + " does not exist or Cloudbreak could not reach.", ex);
}
LOGGER.debug("prepare image has been executed");
}
use of com.sequenceiq.cloudbreak.cloud.azure.client.AzureClient in project cloudbreak by hortonworks.
the class AzureSubnetValidator method validate.
@Override
public void validate(AuthenticatedContext ac, CloudStack cloudStack) {
AzureClient client = ac.getParameter(AzureClient.class);
azureUtils.validateSubnetRules(client, cloudStack.getNetwork());
}
Aggregations