use of org.netxms.client.packages.PackageDeploymentListener in project netxms by netxms.
the class PackageManager method deployPackage.
/**
* Deploy package on managed nodes
*/
private void deployPackage() {
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (selection.size() != 1)
return;
final PackageInfo pkg = (PackageInfo) selection.getFirstElement();
ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createNodeSelectionFilter(false));
dlg.enableMultiSelection(true);
if (dlg.open() != Window.OK)
return;
final Set<Long> objects = new HashSet<Long>();
for (AbstractObject o : dlg.getSelectedObjects()) {
objects.add(o.getObjectId());
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deployPackage(pkg.getId(), objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {
private PackageDeploymentMonitor monitor = null;
@Override
public void statusUpdate(long nodeId, int status, String message) {
if (monitor != null)
monitor.viewStatusUpdate(nodeId, status, message);
}
@Override
public void deploymentStarted() {
final Object sync = new Object();
synchronized (sync) {
runInUIThread(new Runnable() {
@Override
public void run() {
try {
monitor = (PackageDeploymentMonitor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PackageDeploymentMonitor.ID, toString(), IWorkbenchPage.VIEW_ACTIVATE);
monitor.setPackageId(pkg.getId());
} catch (PartInitException e) {
MessageDialogHelper.openError(getSite().getShell(), Messages.get().PackageManager_Error, Messages.get().PackageManager_ErrorOpenView + e.getLocalizedMessage());
}
synchronized (sync) {
sync.notify();
}
}
});
try {
sync.wait();
} catch (InterruptedException e) {
}
}
}
@Override
public void deploymentComplete() {
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
}
});
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DepStartError;
}
};
job.setUser(false);
job.start();
}
use of org.netxms.client.packages.PackageDeploymentListener in project netxms by netxms.
the class PackageDeploymentMonitor method redeployPackages.
private void redeployPackages() {
final Set<Long> objects = new HashSet<Long>();
Collection<DeploymentStatus> array = statusList.values();
for (DeploymentStatus obj : array) {
if (// status failed
obj.getStatus() == 4) {
objects.add(obj.getNodeObject().getObjectId());
}
}
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
ConsoleJob job = new ConsoleJob(Messages.get().PackageManager_DeployAgentPackage, null, Activator.PLUGIN_ID, null) {
@Override
protected void runInternal(IProgressMonitor monitor) throws Exception {
session.deployPackage(packageId, objects.toArray(new Long[objects.size()]), new PackageDeploymentListener() {
@Override
public void statusUpdate(long nodeId, int status, String message) {
viewStatusUpdate(nodeId, status, message);
}
@Override
public void deploymentStarted() {
}
@Override
public void deploymentComplete() {
runInUIThread(new Runnable() {
@Override
public void run() {
MessageDialogHelper.openInformation(getSite().getShell(), Messages.get().PackageManager_Information, Messages.get().PackageManager_PkgDepCompleted);
}
});
}
});
}
@Override
protected String getErrorMessage() {
return Messages.get().PackageManager_DepStartError;
}
};
job.setUser(false);
job.start();
}
Aggregations