Package hudson.plugins.libvirt.lib.jlibvirt

Source Code of hudson.plugins.libvirt.lib.jlibvirt.JLibVirtConnectImpl

package hudson.plugins.libvirt.lib.jlibvirt;


import com.nirima.libvirt.remote.ILibVirt;
import hudson.plugins.libvirt.lib.IConnect;
import hudson.plugins.libvirt.lib.IDomain;
import hudson.plugins.libvirt.lib.VirtException;

import com.nirima.libvirt.Connect;

/**
* @author Nigel Magnay
*/
public class JLibVirtConnectImpl implements IConnect {

    private final Connect connect;

    public JLibVirtConnectImpl(Connect connect) {
        this.connect = connect;
    }

    public JLibVirtConnectImpl(String host, int port, String username, String password, String hypervisorUri, boolean b) throws VirtException {
        try
        {
            this.connect = new Connect(host, port, username, password, hypervisorUri, b);
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public long getVersion() throws VirtException {
        try {
            return getLibVirt().connectGetVersion();
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public int[] listDomains() throws VirtException {
        try {
            return connect.listDomains();
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public String[] listDefinedDomains() throws VirtException {
        try {
            return connect.listDefinedDomains();
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public IDomain domainLookupByName(String c) throws VirtException {
        try {
            return new JLibVirtDomainImpl(connect.domainLookupByName(c));
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public IDomain domainLookupByID(int c) throws VirtException {
        try {
            return new JLibVirtDomainImpl(connect.domainLookupById(c));
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public void close() throws VirtException {
        try {
            getLibVirt().connectClose();
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public boolean isConnected() throws VirtException {
        try {
            return connect.isConnected();
        } catch (Exception e) {
            throw new VirtException(e);
        }
    }

    public ILibVirt getLibVirt() {
        return connect.getLibVirt();
    }
}
TOP

Related Classes of hudson.plugins.libvirt.lib.jlibvirt.JLibVirtConnectImpl

TOP
Copyright © 2018 www.massapi.com. 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.