use of com.microsoft.azure.management.resources.DeploymentExportResult in project azure-tools-for-java by Microsoft.
the class DeploymentPropertyViewPresenter method onLoadProperty.
public void onLoadProperty(DeploymentNode node) {
Observable.fromCallable(() -> {
List<String> parameters = new ArrayList<>();
List<String> variables = new ArrayList<>();
List<String> resources = new ArrayList<>();
Deployment deployment = node.getDeployment();
DeploymentExportResult template = deployment.exportTemplate();
Map<String, Object> templateObj = (Map<String, Object>) template.template();
if (templateObj.get("parameters") != null) {
Map<String, Map<String, String>> parametersTmp = (Map<String, Map<String, String>>) templateObj.get("parameters");
for (String parameter : parametersTmp.keySet()) {
parameters.add(String.format("%s(%s)", parameter, parametersTmp.get(parameter).get("type")));
}
}
if (templateObj.get("variables") != null) {
Map<String, Map<String, String>> variablesTmp = (Map<String, Map<String, String>>) templateObj.get("variables");
for (String variable : variablesTmp.keySet()) {
variables.add(variable);
}
}
if (templateObj.get("resources") != null) {
List<Map<String, String>> resourcesTmp = (List<Map<String, String>>) templateObj.get("resources");
for (Map<String, String> resource : resourcesTmp) {
resources.add(String.format("%s(%s)", resource.get("name"), resource.get("type")));
}
}
return new DeploymentProperty(deployment, parameters, variables, resources, template.templateAsJson());
}).subscribeOn(this.getSchedulerProvider().io()).subscribe((property) -> {
DefaultLoader.getIdeHelper().invokeLater(() -> {
if (!this.isViewDetached()) {
getMvpView().onLoadProperty(property);
}
});
}, (e) -> {
DefaultLoader.getIdeHelper().invokeLater(() -> {
if (!this.isViewDetached()) {
DefaultLoader.getUIHelper().logError("An exception occurred when load deployment properties", e);
DefaultLoader.getUIHelper().showError(node, "An exception occurred when load deployment properties, " + e.getMessage());
}
});
});
}
use of com.microsoft.azure.management.resources.DeploymentExportResult in project cloudbreak by hortonworks.
the class AzureResourceConnectorTest method setUp.
@Before
public void setUp() {
DeploymentExportResult deploymentExportResult = mock(DeploymentExportResult.class);
Group group = mock(Group.class);
AzureStackView azureStackView = mock(AzureStackView.class);
groups = List.of(group);
CloudResource cloudResource = mock(CloudResource.class);
instances = List.of(cloudResource);
network = new Network(new Subnet("0.0.0.0/16"));
AzureImage image = new AzureImage("id", "name", true);
imageModel = new Image(IMAGE_NAME, new HashMap<>(), "centos7", "redhat7", "", "default", "default-id", new HashMap<>());
when(stack.getGroups()).thenReturn(groups);
when(stack.getNetwork()).thenReturn(network);
when(stack.getImage()).thenReturn(imageModel);
when(ac.getCloudContext()).thenReturn(cloudContext);
when(ac.getParameter(AzureClient.class)).thenReturn(client);
when(ac.getCloudCredential()).thenReturn(new CloudCredential("aCredentialId", "aCredentialName", "account"));
when(azureUtils.getStackName(cloudContext)).thenReturn(STACK_NAME);
when(azureStorage.getCustomImage(any(), any(), any())).thenReturn(image);
when(deployment.exportTemplate()).thenReturn(deploymentExportResult);
when(azureResourceGroupMetadataProvider.getResourceGroupName(cloudContext, stack)).thenReturn(RESOURCE_GROUP_NAME);
when(azureCloudResourceService.getDeploymentCloudResources(deployment)).thenReturn(instances);
when(azureCloudResourceService.getInstanceCloudResources(STACK_NAME, instances, groups, RESOURCE_GROUP_NAME)).thenReturn(instances);
when(azureStackViewProvider.getAzureStack(any(), eq(stack), eq(client), eq(ac))).thenReturn(azureStackView);
}
use of com.microsoft.azure.management.resources.DeploymentExportResult in project azure-tools-for-java by microsoft.
the class DeploymentPropertyViewPresenter method onLoadProperty.
public void onLoadProperty(DeploymentNode node) {
Observable.fromCallable(() -> {
List<String> parameters = new ArrayList<>();
List<String> variables = new ArrayList<>();
List<String> resources = new ArrayList<>();
Deployment deployment = node.getDeployment();
DeploymentExportResult template = deployment.exportTemplate();
Map<String, Object> templateObj = (Map<String, Object>) template.template();
if (templateObj.get("parameters") != null) {
Map<String, Map<String, String>> parametersTmp = (Map<String, Map<String, String>>) templateObj.get("parameters");
for (String parameter : parametersTmp.keySet()) {
parameters.add(String.format("%s(%s)", parameter, parametersTmp.get(parameter).get("type")));
}
}
if (templateObj.get("variables") != null) {
Map<String, Map<String, String>> variablesTmp = (Map<String, Map<String, String>>) templateObj.get("variables");
for (String variable : variablesTmp.keySet()) {
variables.add(variable);
}
}
if (templateObj.get("resources") != null) {
List<Map<String, String>> resourcesTmp = (List<Map<String, String>>) templateObj.get("resources");
for (Map<String, String> resource : resourcesTmp) {
resources.add(String.format("%s(%s)", resource.get("name"), resource.get("type")));
}
}
return new DeploymentProperty(deployment, parameters, variables, resources, template.templateAsJson());
}).subscribeOn(this.getSchedulerProvider().io()).subscribe((property) -> {
DefaultLoader.getIdeHelper().invokeLater(() -> {
if (!this.isViewDetached()) {
getMvpView().onLoadProperty(property);
}
});
}, (e) -> {
DefaultLoader.getIdeHelper().invokeLater(() -> {
if (!this.isViewDetached()) {
DefaultLoader.getUIHelper().logError("An exception occurred when load deployment properties", e);
DefaultLoader.getUIHelper().showError(node, "An exception occurred when load deployment properties, " + e.getMessage());
}
});
});
}
Aggregations