Search in sources :

Example 1 with SecurityRule

use of com.microsoft.azure.toolkit.lib.compute.security.model.SecurityRule in project azure-tools-for-java by Microsoft.

the class VMCreationDialog method setData.

@Override
public void setData(DraftVirtualMachine data) {
    Optional.ofNullable(data.getResourceGroup()).ifPresent(groupName -> cbResourceGroup.setValue(new AzureComboBox.ItemReference<>(group -> StringUtils.equalsIgnoreCase(group.getName(), groupName))));
    Optional.ofNullable(data.getSubscriptionId()).ifPresent(id -> cbSubscription.setValue(new AzureComboBox.ItemReference<>(subscription -> StringUtils.equalsIgnoreCase(subscription.getId(), id))));
    Optional.ofNullable(data.getName()).ifPresent(name -> txtVisualMachineName.setText(name));
    Optional.ofNullable(data.getRegion()).ifPresent(region -> cbRegion.setValue(region));
    Optional.ofNullable(data.getImage()).ifPresent(image -> cbImage.setValue(image));
    Optional.ofNullable(data.getSize()).ifPresent(size -> cbSize.setValue(size));
    Optional.ofNullable(data.getUserName()).ifPresent(name -> txtUserName.setText(name));
    cbAvailabilityOptions.setValue(data.getAvailabilitySet());
    // skip set value for password/cert
    Optional.ofNullable(data.getNetwork()).ifPresent(network -> cbVirtualNetwork.setData(network));
    Optional.ofNullable(data.getSubnet()).ifPresent(subnet -> cbSubnet.setValue(subnet));
    rdoNoneSecurityGroup.setSelected(data.getSecurityGroup() == null);
    Optional.ofNullable(data.getSecurityGroup()).ifPresent(networkSecurityGroup -> {
        if (networkSecurityGroup instanceof DraftNetworkSecurityGroup) {
            rdoBasicSecurityGroup.setSelected(true);
            final List<SecurityRule> securityRuleList = ((DraftNetworkSecurityGroup) networkSecurityGroup).getSecurityRuleList();
            rdoAllowSelectedInboundPorts.setSelected(!Collections.isEmpty(securityRuleList));
            pnlPorts.setData(securityRuleList);
            pnlBasicPorts.setData(securityRuleList);
        } else if (networkSecurityGroup.exists()) {
            rdoAdvancedSecurityGroup.setSelected(true);
            cbSecurityGroup.setData(networkSecurityGroup);
        }
    });
    cbPublicIp.setData(data.getIpAddress());
    cbStorageAccount.setData(data.getStorageAccount());
    final AzureSpotConfig azureSpotConfig = data.getAzureSpotConfig();
    if (azureSpotConfig == null) {
        chkAzureSpotInstance.setSelected(false);
    } else {
        chkAzureSpotInstance.setSelected(true);
        rdoStopAndDeallocate.setSelected(azureSpotConfig.getPolicy() != AzureSpotConfig.EvictionPolicy.StopAndDeallocate);
        rdoDelete.setSelected(azureSpotConfig.getPolicy() == AzureSpotConfig.EvictionPolicy.StopAndDeallocate);
        txtMaximumPrice.setText(String.valueOf(azureSpotConfig.getMaximumPrice()));
    }
}
Also used : AzureSpotConfig(com.microsoft.azure.toolkit.lib.compute.vm.model.AzureSpotConfig) SecurityRule(com.microsoft.azure.toolkit.lib.compute.security.model.SecurityRule) DraftNetworkSecurityGroup(com.microsoft.azure.toolkit.lib.compute.security.DraftNetworkSecurityGroup)

Aggregations

DraftNetworkSecurityGroup (com.microsoft.azure.toolkit.lib.compute.security.DraftNetworkSecurityGroup)1 SecurityRule (com.microsoft.azure.toolkit.lib.compute.security.model.SecurityRule)1 AzureSpotConfig (com.microsoft.azure.toolkit.lib.compute.vm.model.AzureSpotConfig)1