use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class VMCreationDialog method getData.
@Override
public DraftVirtualMachine getData() {
final Subscription subscription = cbSubscription.getValue();
final String subscriptionId = Optional.ofNullable(subscription).map(Subscription::getId).orElse(StringUtils.EMPTY);
final ResourceGroup resourceGroup = cbResourceGroup.getValue();
final String resourceGroupName = Optional.ofNullable(resourceGroup).map(ResourceGroup::getName).orElse(StringUtils.EMPTY);
final String vmName = txtVisualMachineName.getText();
final DraftVirtualMachine draftVirtualMachine = new DraftVirtualMachine();
draftVirtualMachine.setSubscriptionId(subscriptionId);
draftVirtualMachine.setResourceGroup(resourceGroupName);
draftVirtualMachine.setName(vmName);
draftVirtualMachine.setRegion(cbRegion.getValue());
draftVirtualMachine.setNetwork(cbVirtualNetwork.getValue());
draftVirtualMachine.setSubnet(cbSubnet.getValue());
draftVirtualMachine.setImage(cbImage.getValue());
draftVirtualMachine.setIpAddress(cbPublicIp.getValue());
draftVirtualMachine.setUserName(txtUserName.getText());
if (rdoPassword.isSelected()) {
draftVirtualMachine.setAuthenticationType(AuthenticationType.Password);
draftVirtualMachine.setPassword(passwordFieldInput.getValue());
} else if (rdoSshPublicKey.isSelected()) {
draftVirtualMachine.setAuthenticationType(AuthenticationType.SSH);
try {
draftVirtualMachine.setSshKey(readCert(txtCertificate.getValue()));
} catch (final IOException e) {
// swallow exception while get data
}
}
draftVirtualMachine.setSize(cbSize.getValue());
draftVirtualMachine.setAvailabilitySet(cbAvailabilityOptions.getValue());
// Azure Spot
if (chkAzureSpotInstance.isSelected()) {
final AzureSpotConfig.EvictionType evictionType = AzureSpotConfig.EvictionType.CapacityOnly;
final AzureSpotConfig.EvictionPolicy evictionPolicy = rdoStopAndDeallocate.isSelected() ? AzureSpotConfig.EvictionPolicy.StopAndDeallocate : AzureSpotConfig.EvictionPolicy.Delete;
final double maximumPrice = Double.parseDouble(txtMaximumPrice.getText());
final AzureSpotConfig spotConfig = new AzureSpotConfig(maximumPrice, evictionType, evictionPolicy);
draftVirtualMachine.setAzureSpotConfig(spotConfig);
} else {
draftVirtualMachine.setAzureSpotConfig(null);
}
// Security Group
if (rdoAdvancedSecurityGroup.isSelected()) {
draftVirtualMachine.setSecurityGroup(cbSecurityGroup.getValue());
} else if (rdoBasicSecurityGroup.isSelected()) {
final DraftNetworkSecurityGroup draftNetworkSecurityGroup = new DraftNetworkSecurityGroup();
draftNetworkSecurityGroup.setSubscriptionId(subscriptionId);
draftNetworkSecurityGroup.setResourceGroup(resourceGroupName);
draftNetworkSecurityGroup.setName(vmName + "-sg" + Utils.getTimestamp());
draftNetworkSecurityGroup.setRegion(cbRegion.getValue());
draftNetworkSecurityGroup.setSecurityRuleList(pnlPorts.getData());
draftVirtualMachine.setSecurityGroup(draftNetworkSecurityGroup);
}
draftVirtualMachine.setStorageAccount(cbStorageAccount.getValue());
return draftVirtualMachine;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class VMCreationDialog method onSubscriptionChanged.
private void onSubscriptionChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED && e.getItem() instanceof Subscription) {
final Subscription subscription = (Subscription) e.getItem();
this.cbResourceGroup.setSubscription(subscription);
this.cbRegion.setSubscription(subscription);
this.cbImage.setSubscription(subscription);
this.cbAvailabilityOptions.setSubscription(subscription);
this.cbSize.setSubscription(subscription);
this.cbVirtualNetwork.setSubscription(subscription);
this.cbSecurityGroup.setSubscription(subscription);
this.cbPublicIp.setSubscription(subscription);
this.cbStorageAccount.setSubscription(subscription);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class BaseStorageAccountCreationDialog method onSubscriptionChanged.
private void onSubscriptionChanged(final ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
final Subscription subscription = (Subscription) e.getItem();
this.resourceGroupComboBox.setSubscription(subscription);
this.accountNameTextField.setSubscriptionId(subscription.getId());
this.regionComboBox.setSubscription(subscription);
} else if (e.getStateChange() == ItemEvent.DESELECTED) {
this.resourceGroupComboBox.setSubscription(null);
this.accountNameTextField.setSubscriptionId(null);
this.regionComboBox.setSubscription(null);
}
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AzureMvpModel method getSelectedSubscriptions.
/**
* Get list of selected Subscriptions.
*
* @return List of Subscription instances
*/
@AzureOperation(name = "account|subscription.get_detail.selected", type = AzureOperation.Type.SERVICE)
public List<Subscription> getSelectedSubscriptions() {
final List<Subscription> ret = new ArrayList<>();
final AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
ret.addAll(azureManager.getSelectedSubscriptions());
Collections.sort(ret, getComparator(Subscription::getName));
return ret;
}
use of com.microsoft.azure.toolkit.lib.common.model.Subscription in project azure-tools-for-java by Microsoft.
the class AzureRedisMvpModel method getRedisCaches.
/**
* Get all redis caches.
* @return A map containing RedisCaches with subscription id as the key
*/
public HashMap<String, RedisCaches> getRedisCaches() {
HashMap<String, RedisCaches> redisCacheMaps = new HashMap<>();
List<Subscription> subscriptions = az(AzureAccount.class).account().getSelectedSubscriptions();
for (Subscription subscription : subscriptions) {
Azure azure = AuthMethodManager.getInstance().getAzureClient(subscription.getId());
if (azure.redisCaches() == null) {
continue;
}
redisCacheMaps.put(subscription.getId(), azure.redisCaches());
}
return redisCacheMaps;
}
Aggregations