Package hudson.plugins.libvirt.lib

Examples of hudson.plugins.libvirt.lib.IDomain


        LogRecord info = new LogRecord(Level.FINE, "Getting hypervisor domains.");
        LOGGER.log(info);
        if (con != null) {
            for (String c : con.listDefinedDomains()) {
                if (c != null && !c.equals("")) {
                    IDomain domain = null;
                    try {
                        domain = con.domainLookupByName(c);
                        domains.put(domain.getName(), domain);
                    } catch (Exception e) {
                        LogRecord rec = new LogRecord(Level.WARNING, "Error retrieving information for domain with name: {0}.");
                        rec.setParameters(new Object[]{c});
                        rec.setThrown(e);
                        LOGGER.log(rec);
                    }
                }
            }
            for (int c : con.listDomains()) {
                IDomain domain = null;
                try {
                    domain = con.domainLookupByID(c);
                    domains.put(domain.getName(), domain);
                } catch (Exception e) {
                    LogRecord rec = new LogRecord(Level.WARNING, "Error retrieving information for domain with id: {0}.");
                    rec.setParameters(new Object[]{c});
                    rec.setThrown(e);
                    LOGGER.log(rec);
View Full Code Here


    Hypervisor hypervisor = vmL.findOurHypervisorInstance();
    logger.log(Level.INFO, "Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down. reason: "+cause+" ("+cause.getClass().getName()+")");
    taskListener.getLogger().println("Virtual machine \"" + virtualMachineName + "\" (slave \"" + getDisplayName() + "\") is to be shut down.");
    try {     
            Map<String, IDomain> computers = hypervisor.getDomains();
            IDomain domain = computers.get(virtualMachineName);
            if (domain != null) {
              if (domain.isRunningOrBlocked()) {
                String snapshotName = slave.getSnapshotName();
                    if (snapshotName != null && snapshotName.length() > 0) {
                      taskListener.getLogger().println("Reverting to " + snapshotName + " and shutting down.");
                      domain.revertToSnapshot(domain.snapshotLookupByName(snapshotName));
                    } else {
                      taskListener.getLogger().println("Shutting down.");

                        System.err.println("method: " + slave.getShutdownMethod());
                        if (slave.getShutdownMethod().equals("suspend")) {
                            domain.suspend();
                        } else if (slave.getShutdownMethod().equals("destroy")) {
                            domain.destroy();
                        } else {
                      domain.shutdown();
                    }
                    }
                } else {
                    taskListener.getLogger().println("Already suspended, no shutdown required.");
                }
View Full Code Here

            try {
                Map<String, IDomain> domains = hypervisor.getDomains();

                String vmName = slaveLauncher.getVirtualMachineName();
                IDomain domain = domains.get(vmName);
                if (domain != null) {
                    listener.getLogger().println("Preparing to revert " + vmName + " to snapshot " + snapshotName + ".");

                    try {
                        IDomainSnapshot snapshot = domain.snapshotLookupByName(snapshotName);
                        try {
                            Computer computer = slave.getComputer();
                            try {
                                computer.getChannel().syncLocalIO();
                                try {
                                    computer.getChannel().close();
                                    computer.disconnect(null);
                                    try {
                                        computer.waitUntilOffline();

                                        listener.getLogger().println("Reverting " + vmName + " to snapshot " + snapshotName + ".");
                                        domain.revertToSnapshot(snapshot);

                                        listener.getLogger().println("Relaunching " + vmName + ".");
                                        try {
                                            launcher.launch(slave.getComputer(), listener);
                                        } catch (IOException e) {
View Full Code Here

              if (virtualMachine == null) // still null? no such vm!
                throw new Exception("Virtual machine \"" + virtualMachineName + "\" (slave title \"" + slaveComputer.getDisplayName() + "\") not found on the specified hypervisor!");
          }
       
            Map<String, IDomain> computers = virtualMachine.getHypervisor().getDomains();
            IDomain domain = computers.get(virtualMachine.getName());
            if (domain != null) {
                if( domain.isNotBlockedAndNotRunning() ) {
                    taskListener.getLogger().println("Starting, waiting for " + WAIT_TIME_MS + "ms to let it fully boot up...");
                    domain.create();
                    Thread.sleep(WAIT_TIME_MS);

                    int attempts = 0;
                    while (true) {
                        attempts++;
View Full Code Here

                VirtualMachine virtualMachine = launcher.getVirtualMachine();

                for (int i = 0; i < 5; i++) {
                    try {
                        Map<String, IDomain> computers = virtualMachine.getHypervisor().getDomains();
                        IDomain domain = computers.get(virtualMachine.getName());
                        domain.create();
                    } catch(VirtException e) {
                        try {Thread.sleep(500); } catch (Exception e2) {}
                        continue;
                    }
                    break;
View Full Code Here

TOP

Related Classes of hudson.plugins.libvirt.lib.IDomain

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.