Search in sources :

Example 1 with MySqlServer

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();
    });
}
Also used : ConnectorDialog(com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog) MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer)

Example 2 with MySqlServer

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);
    }
}
Also used : MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer)

Example 3 with MySqlServer

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);
    }
}
Also used : MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription)

Example 4 with MySqlServer

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();
    }
}
Also used : Draft(com.microsoft.azure.toolkit.intellij.common.Draft) AzureMySql(com.microsoft.azure.toolkit.lib.mysql.AzureMySql) MySqlServer(com.microsoft.azure.toolkit.lib.mysql.MySqlServer) AzureGroup(com.microsoft.azure.toolkit.lib.resource.AzureGroup) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Operation(com.microsoft.azuretools.telemetrywrapper.Operation) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)

Aggregations

MySqlServer (com.microsoft.azure.toolkit.lib.mysql.MySqlServer)4 Draft (com.microsoft.azure.toolkit.intellij.common.Draft)1 ConnectorDialog (com.microsoft.azure.toolkit.intellij.connector.ConnectorDialog)1 Subscription (com.microsoft.azure.toolkit.lib.common.model.Subscription)1 AzureOperation (com.microsoft.azure.toolkit.lib.common.operation.AzureOperation)1 AzureMySql (com.microsoft.azure.toolkit.lib.mysql.AzureMySql)1 AzureGroup (com.microsoft.azure.toolkit.lib.resource.AzureGroup)1 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)1