use of com.microsoft.azure.docker.model.DockerHost in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method onRemoveDockerHostAction.
private void onRemoveDockerHostAction() {
DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
String apiURL = (String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4);
DockerHost deleteHost = dockerManager.getDockerHostForURL(apiURL);
Azure azureClient = dockerManager.getSubscriptionsMap().get(deleteHost.sid).azureClient;
int option = AzureDockerUIResources.deleteAzureDockerHostConfirmationDialog(azureClient, deleteHost);
if (option != 1 && option != 2) {
if (AzureDockerUtils.DEBUG)
System.out.format("User canceled delete Docker host op: %d\n", option);
return;
}
AppInsightsClient.createByType(AppInsightsClient.EventType.DockerHost, deleteHost.name, "Remove");
int currentRow = dockerHostsTable.getSelectedRow();
tableModel.removeRow(currentRow);
tableModel.fireTableDataChanged();
if (dockerHostsTableSelection.row == currentRow) {
dockerHostsTableSelection = null;
}
AzureDockerUIResources.deleteDockerHost(model.getProject(), azureClient, deleteHost, option, new Runnable() {
@Override
public void run() {
dockerManager.refreshDockerHostDetails();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
refreshDockerHostsTable();
}
});
}
});
setFinishButtonState(doValidate(false) == null);
setNextButtonState(doValidate(false) == null);
}
use of com.microsoft.azure.docker.model.DockerHost in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method onAddNewDockerHostAction.
private void onAddNewDockerHostAction() {
AppInsightsClient.createByType(AppInsightsClient.EventType.DockerHost, "", "Add");
AzureNewDockerWizardModel newDockerHostModel = new AzureNewDockerWizardModel(model.getProject(), dockerManager);
AzureNewDockerWizardDialog wizard = new AzureNewDockerWizardDialog(newDockerHostModel);
wizard.setTitle("Create Docker Host");
wizard.show();
if (wizard.getExitCode() == 0) {
dockerHostsTable.setEnabled(false);
DockerHost host = newDockerHostModel.getDockerHost();
dockerImageDescription.host = host;
dockerImageDescription.hasNewDockerHost = true;
dockerImageDescription.sid = host.sid;
model.setSubscription(this.dockerManager.getSubscriptionsMap().get(host.sid));
AzureDockerPreferredSettings dockerPrefferedSettings = dockerManager.getDockerPreferredSettings();
if (dockerPrefferedSettings == null) {
dockerPrefferedSettings = new AzureDockerPreferredSettings();
}
dockerPrefferedSettings.region = host.hostVM.region;
dockerPrefferedSettings.vmSize = host.hostVM.vmSize;
dockerPrefferedSettings.vmOS = host.hostOSType.name();
dockerManager.setDockerPreferredSettings(dockerPrefferedSettings);
final DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
if (dockerHostsTableSelection != null && (Boolean) tableModel.getValueAt(dockerHostsTableSelection.row, 0)) {
tableModel.setValueAt(false, dockerHostsTableSelection.row, 0);
}
Vector<Object> row = new Vector<>();
row.add(false);
row.add(host.name);
row.add("TO_BE_CREATED");
row.add(host.hostOSType.toString());
row.add(host.apiUrl);
tableModel.insertRow(0, row);
tableModel.setValueAt(true, 0, 0);
dockerHostsTable.setRowSelectionInterval(0, 0);
setFinishButtonState(doValidate(false) == null);
setNextButtonState(doValidate(false) == null);
}
}
use of com.microsoft.azure.docker.model.DockerHost in project azure-tools-for-java by Microsoft.
the class DockerHostNode method refreshDockerHostInstance.
private void refreshDockerHostInstance(VirtualMachine vm) {
if (vm != null) {
DockerHost updatedDockerHost = AzureDockerVMOps.getDockerHost(vm, dockerManager.getDockerVaultsMap());
if (updatedDockerHost != null) {
updatedDockerHost.sid = dockerHost.sid;
updatedDockerHost.hostVM.sid = dockerHost.hostVM.sid;
if (updatedDockerHost.certVault == null) {
updatedDockerHost.certVault = dockerHost.certVault;
updatedDockerHost.hasPwdLogIn = dockerHost.hasPwdLogIn;
updatedDockerHost.hasSSHLogIn = dockerHost.hasSSHLogIn;
updatedDockerHost.isTLSSecured = dockerHost.isTLSSecured;
}
dockerManager.updateDockerHost(updatedDockerHost);
dockerHost = updatedDockerHost;
if (dockerHost.certVault != null) {
try {
// it might throw here if the credentials are invalid
Map<String, DockerImage> dockerImages = AzureDockerImageOps.getImages(dockerHost);
Map<String, DockerContainer> dockerContainers = AzureDockerContainerOps.getContainers(dockerHost);
AzureDockerContainerOps.setContainersAndImages(dockerContainers, dockerImages);
dockerHost.dockerImages = dockerImages;
} catch (Exception e) {
DefaultLoader.getUIHelper().logError(e.getMessage(), e);
}
}
setIconPath(getDockerHostIcon());
for (DockerImage dockerImage : updatedDockerHost.dockerImages.values()) {
try {
addChildNode(new DockerImageNode(this, dockerManager, updatedDockerHost, dockerImage));
} catch (Exception ignored) {
}
}
}
}
}
use of com.microsoft.azure.docker.model.DockerHost in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method onEditDockerHostAction.
private void onEditDockerHostAction() {
try {
DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
String apiURL = (String) tableModel.getValueAt(dockerHostsTable.getSelectedRow(), 4);
DockerHost updateHost = dockerManager.getDockerHostForURL(apiURL);
if (updateHost != null && !updateHost.isUpdating) {
AzureDockerUIResources.updateDockerHost(model.getProject(), new EditableDockerHost(updateHost), model.getDockerHostsManager(), true);
} else {
PluginUtil.displayErrorDialog("Error: Invalid Edit Selection", "The selected Docker host can not be edited at this time!");
}
} catch (Exception e) {
setDialogButtonsState(false);
String msg = "An error occurred while attempting to edit the selected Docker host.\n" + e.getMessage();
if (AzureDockerUtils.DEBUG)
e.printStackTrace();
LOGGER.error("onEditDockerHostAction", e);
PluginUtil.displayErrorDialog("Update Docker Hosts Error", msg);
}
}
use of com.microsoft.azure.docker.model.DockerHost in project azure-tools-for-java by Microsoft.
the class AzureSelectDockerHostStep method refreshDockerHostsTable.
/* Refresh the docker hosts entries in the select host table
*
*/
private void refreshDockerHostsTable() {
DefaultTableModel tableModel = (DefaultTableModel) dockerHostsTable.getModel();
String oldSelection = dockerHostsTableSelection != null ? dockerHostsTableSelection.host.apiUrl : null;
if (dockerHostsTableSelection != null) {
tableModel.setValueAt(false, dockerHostsTableSelection.row, 0);
dockerHostsTableSelection = null;
}
if (dockerHostsTable.getSelectedRow() >= 0) {
dockerHostsTable.removeRowSelectionInterval(dockerHostsTable.getSelectedRow(), dockerHostsTable.getSelectedRow());
}
int size = tableModel.getRowCount();
while (size > 0) {
size--;
try {
tableModel.removeRow(size);
} catch (Exception e) {
e.printStackTrace();
}
}
dockerHostsTable.removeAll();
dockerHostsTable.repaint();
try {
List<DockerHost> dockerHosts = dockerManager.getDockerHostsList();
boolean selected = false;
if (dockerHosts != null) {
int idx = 0;
for (DockerHost host : dockerHosts) {
Vector<Object> row = new Vector<>();
row.add(false);
row.add(host.name);
row.add(host.state.toString());
row.add(host.hostOSType.toString());
row.add(host.apiUrl);
tableModel.addRow(row);
if (oldSelection != null && oldSelection.equals(host.apiUrl)) {
tableModel.setValueAt(true, idx, 0);
selected = true;
}
idx++;
}
if (!selected) {
dockerHostsTableSelection = null;
}
}
dockerHostsTable.repaint();
} catch (Exception e) {
setDialogButtonsState(false);
String msg = "An error occurred while attempting to get the list of recognizable Docker hosts.\n" + e.getMessage();
if (AzureDockerUtils.DEBUG)
e.printStackTrace();
LOGGER.error("refreshDockerHostsTable", e);
PluginUtil.displayErrorDialog("Refresh Docker Hosts Error", msg);
}
}
Aggregations