Package org.libvirt

Examples of org.libvirt.Connect


        }
    }

    @Override
    public boolean deleteStoragePool(String uuid) {
        Connect conn = null;
        try {
            conn = LibvirtConnection.getConnection();
        } catch (LibvirtException e) {
            throw new CloudRuntimeException(e.toString());
        }

        StoragePool sp = null;
        Secret s = null;

        try {
            sp = conn.storagePoolLookupByUUIDString(uuid);
        } catch (LibvirtException e) {
            return true;
        }

        /*
         * Some storage pools, like RBD also have 'secret' information stored in libvirt
         * Destroy them if they exist
        */
        try {
            s = conn.secretLookupByUUIDString(uuid);
        } catch (LibvirtException e) {
        }

        try {
            if (sp.isPersistent() == 1) {
View Full Code Here


        if (poolUuid == null) {
            return false;
        }

        try {
            Connect conn = LibvirtConnection.getConnection();

            StoragePool pool = conn.storagePoolLookupByUUIDString(poolUuid);

            deleteStoragePool(poolUuid);

            return true;
        } catch (LibvirtException ex) {
View Full Code Here

        value = (String) params.get("host.reserved.mem.mb");
        _dom0MinMem = NumbersUtil.parseInt(value, 0) * 1024 * 1024;

        LibvirtConnection.initialize(_hypervisorURI);
        Connect conn = null;
        try {
            conn = LibvirtConnection.getConnection();

            if (_bridgeType == BridgeType.OPENVSWITCH) {
                if (conn.getLibVirVersion() < (10 * 1000 + 0)) {
                    throw new ConfigurationException("LibVirt version 0.10.0 required for openvswitch support, but version "
                            + conn.getLibVirVersion() + " detected");
                }
            }
        } catch (LibvirtException e) {
            throw new CloudRuntimeException(e.getMessage());
        }

        if (HypervisorType.KVM == _hypervisorType) {
            /* Does node support HVM guest? If not, exit */
            if (!IsHVMEnabled(conn)) {
                throw new ConfigurationException(
                        "NO HVM support on this machine, please make sure: "
                                + "1. VT/SVM is supported by your CPU, or is enabled in BIOS. "
                                + "2. kvm modules are loaded (kvm, kvm_amd|kvm_intel)");
            }
        }

        _hypervisorPath = getHypervisorPath(conn);
        try {
            _hvVersion = conn.getVersion();
            _hvVersion = (_hvVersion % 1000000) / 1000;
            _hypervisorLibvirtVersion = conn.getLibVirVersion();
            _hypervisorQemuVersion = conn.getVersion();
        } catch (LibvirtException e) {
            s_logger.trace("Ignoring libvirt error.", e);
        }

        _guestCpuMode = (String) params.get("guest.cpu.mode");
View Full Code Here

    }

    @Override
    public boolean stop() {
        try {
            Connect conn = LibvirtConnection.getConnection();
            conn.close();
        } catch (LibvirtException e) {
            s_logger.trace("Ignoring libvirt error.", e);
        }

        return true;
View Full Code Here

        opr = "-D";
        add = false;
      }

      String result = null;
        Connect conn;
    try {
      if (cmd.getType() == PvlanSetupCommand.Type.DHCP) {
        Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger);
        if (add) {
          conn = LibvirtConnection.getConnectionByVmName(dhcpName);
View Full Code Here

            s_logger.error("mismatch now resolved to " + nic);
        }
        String vmName = cmd.getVmName();
        Domain vm = null;
        try {
            Connect conn = LibvirtConnection.getConnectionByVmName(vmName);
            vm = getDomain(conn, vmName);
            List<InterfaceDef> pluggedNics = getInterfaces(conn, vmName);
            Integer nicnum = 0;
            for (InterfaceDef pluggedNic : pluggedNics) {
                if (pluggedNic.getMacAddress().equalsIgnoreCase(nic.getMac())) {
View Full Code Here

            }
        }
    }

    private UnPlugNicAnswer execute(UnPlugNicCommand cmd) {
        Connect conn;
        NicTO nic = cmd.getNic();
        String vmName = cmd.getVmName();
        Domain vm = null;
        try {
            conn = LibvirtConnection.getConnectionByVmName(vmName);
View Full Code Here

            }
        }
    }

    private SetupGuestNetworkAnswer execute(SetupGuestNetworkCommand cmd) {
        Connect conn;
        NicTO nic = cmd.getNic();
        String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
        String routerGIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP);
        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
        String gateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY);
View Full Code Here

            return new SetNetworkACLAnswer(cmd, false, results);
        }
    }

    protected SetSourceNatAnswer execute(SetSourceNatCommand cmd) {
        Connect conn;
        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
        String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
        IpAddressTO pubIP = cmd.getIpAddress();

        try {
View Full Code Here

            return new SetSourceNatAnswer(cmd, false, msg);
        }
    }

    protected IpAssocAnswer execute(IpAssocVpcCommand cmd) {
        Connect conn;
        String[] results = new String[cmd.getIpAddresses().length];
        int i = 0;
        String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
        String routerIP = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
View Full Code Here

TOP

Related Classes of org.libvirt.Connect

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.