use of com.microsoft.azure.toolkit.lib.mysql.MySqlServer in project azure-tools-for-java by Microsoft.
the class ConnectToMySQLAction method actionPerformed.
@Override
public void actionPerformed(NodeActionEvent e) {
AzureSignInAction.requireSignedIn(project, () -> {
final ConnectorDialog dialog = new ConnectorDialog(project);
final MySqlServer server = this.node.getServer();
final Database database = new Database(server.id(), null);
final DatabaseResource resource = new DatabaseResource(database, DatabaseResource.Definition.AZURE_MYSQL);
dialog.setResource(resource);
dialog.show();
});
}
use of com.microsoft.azure.toolkit.lib.mysql.MySqlServer in project azure-tools-for-java by Microsoft.
the class MySQLModule method renderChildren.
public void renderChildren(List<MySqlServer> servers) {
for (final MySqlServer server : servers) {
final MySQLNode node = new MySQLNode(this, server);
addChildNode(node);
}
}
use of com.microsoft.azure.toolkit.lib.mysql.MySqlServer in project azure-tools-for-java by Microsoft.
the class MySQLPropertyView method showProperty.
@Override
public void showProperty(MySQLProperty property) {
final MySqlServer server = property.getServer();
final String sid = server.entity().getSubscriptionId();
if (!server.exists()) {
this.closeEditor();
return;
}
final Subscription subscription = az(AzureAccount.class).account().getSubscription(sid);
if (subscription != null) {
overview.getSubscriptionTextField().setText(subscription.getName());
databaseComboBox.setServer(server);
databaseComboBox.refreshItems();
}
overview.getResourceGroupTextField().setText(server.entity().getResourceGroupName());
overview.getStatusTextField().setText(server.entity().getState());
overview.getLocationTextField().setText(server.entity().getRegion().getLabel());
overview.getSubscriptionIDTextField().setText(sid);
overview.getServerNameTextField().setText(server.entity().getFullyQualifiedDomainName());
overview.getServerNameTextField().setCaretPosition(0);
overview.getServerAdminLoginNameTextField().setText(server.entity().getAdministratorLoginName() + "@" + server.name());
overview.getServerAdminLoginNameTextField().setCaretPosition(0);
overview.getMysqlVersionTextField().setText(server.entity().getVersion());
final String skuTier = server.entity().getSkuTier();
final int skuCapacity = server.entity().getVCore();
final int storageGB = server.entity().getStorageInMB() / 1024;
final String performanceConfigurations = skuTier + ", " + skuCapacity + " vCore(s), " + storageGB + " GB";
overview.getPerformanceConfigurationsTextField().setText(performanceConfigurations);
overview.getSslEnforceStatusTextField().setText(server.entity().getSslEnforceStatus());
if (StringUtils.equalsIgnoreCase("READY", server.entity().getState())) {
connectionSecuritySeparator.expand();
connectionSecuritySeparator.setEnabled(true);
connectionStringsSeparator.expand();
connectionStringsSeparator.setEnabled(true);
originalAllowAccessToAzureServices = server.firewallRules().isAzureAccessRuleEnabled();
connectionSecurity.getAllowAccessFromAzureServicesCheckBox().setSelected(originalAllowAccessToAzureServices);
originalAllowAccessToLocal = server.firewallRules().isLocalMachineAccessRuleEnabled();
connectionSecurity.getAllowAccessFromLocalMachineCheckBox().setSelected(originalAllowAccessToLocal);
} else {
connectionSecuritySeparator.collapse();
connectionSecuritySeparator.setEnabled(false);
connectionStringsSeparator.collapse();
connectionStringsSeparator.setEnabled(false);
}
}
use of com.microsoft.azure.toolkit.lib.mysql.MySqlServer in project azure-tools-for-java by Microsoft.
the class CreateMySQLAction method createMySQL.
@AzureOperation(name = "mysql|server.create.task", params = { "config.getServerName()", "config.getSubscription().getName()" }, type = AzureOperation.Type.SERVICE)
public void createMySQL(final AzureMySQLConfig config) {
final Operation operation = TelemetryManager.createOperation(ActionConstants.MySQL.CREATE);
try {
operation.start();
final String subscriptionId = config.getSubscription().getId();
EventUtil.logEvent(EventType.info, operation, Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, subscriptionId));
// create resource group if necessary.
if (config.getResourceGroup() instanceof Draft) {
try {
Azure.az(AzureGroup.class).get(subscriptionId, config.getResourceGroup().getName());
} catch (Throwable ex) {
Azure.az(AzureGroup.class).subscription(subscriptionId).create(config.getResourceGroup().getName(), config.getRegion().getName());
}
config.setResourceGroup(Azure.az(AzureGroup.class).get(subscriptionId, config.getResourceGroup().getName()));
}
// create mysql server
final MySqlServer server = Azure.az(AzureMySql.class).subscription(subscriptionId).create(MySqlServerConfig.builder().subscription(config.getSubscription()).resourceGroup(config.getResourceGroup()).region(config.getRegion()).name(config.getServerName()).version(config.getVersion()).administratorLoginName(config.getAdminUsername()).administratorLoginPassword(String.valueOf(config.getPassword())).build()).commit();
// update access from azure services
if (config.isAllowAccessFromAzureServices()) {
server.firewallRules().enableAzureAccessRule();
}
// update access from local machine
if (config.isAllowAccessFromLocalMachine()) {
server.firewallRules().enableLocalMachineAccessRule(server.getPublicIpForLocalMachine());
}
} catch (final RuntimeException e) {
EventUtil.logError(operation, ErrorType.systemError, e, null, null);
throw e;
} finally {
operation.complete();
}
}
Aggregations