Package com.xensource.xenapi

Examples of com.xensource.xenapi.Host


            if (hostuuid.equals(masterRec.uuid)) {
                s_logger.debug("This is last host to eject, so don't need to eject: " + hostuuid);
                return new Answer(cmd);
            }

            Host host = Host.getByUuid(conn, hostuuid);
            // remove all tags cloud stack add before eject
            Host.Record hr = host.getRecord(conn);
            Iterator<String> it = hr.tags.iterator();
            while (it.hasNext()) {
                String tag = it.next();
                if (tag.startsWith("vmops-version-")) {
                    it.remove();
                }
            }
            // eject from pool
            try {
                Pool.eject(conn, host);
                try {
                    Thread.sleep(10 * 1000);
                } catch (InterruptedException e) {
                }
            } catch (XenAPIException e) {
                String msg = "Unable to eject host " + _host.uuid + " due to " + e.toString();
                s_logger.warn(msg);
                host.destroy(conn);
            }
            return new Answer(cmd);
        } catch (XenAPIException e) {
            String msg = "XenAPIException Unable to destroy host " + _host.uuid + " in xenserver database due to " + e.toString();
            s_logger.warn(msg, e);
View Full Code Here


                    continue; // Skip DOM0
                }
                String vm_name = record.nameLabel;
                VmPowerState ps = record.powerState;
                final State state = convertToState(ps);
                Host host = record.residentOn;
                String host_uuid = null;
                if( ! isRefNull(host) ) {
                    host_uuid = host.getUuid(conn);
                    synchronized (_cluster.intern()) {
                        s_vms.put(_cluster, host_uuid, vm_name, state);
                    }
                }
                if (s_logger.isTraceEnabled()) {
View Full Code Here

            Set<SR> srs = SR.getByNameLabel(conn, srname);
            if ( srs != null && !srs.isEmpty()) {
                return srs.iterator().next();
            }
            Map<String, String> smConfig = new HashMap<String, String>();
            Host host = Host.getByUuid(conn, hypervisorResource.getHost().uuid);
            String uuid = UUID.randomUUID().toString();

            sr = SR.introduce(conn,uuid, srname, srname, "file", "file", false, smConfig);
            PBD.Record record = new PBD.Record();
            record.host = host;
View Full Code Here

        return dynamicMinRam;
    }

    protected boolean hostHasHotFix(Connection conn, String hotFixUuid) {
        try {
            Host host = Host.getByUuid(conn, _host.uuid);
            Host.Record re = host.getRecord(conn);
            Set<HostPatch> patches = re.patches;
            PoolPatch poolPatch = PoolPatch.getByUuid(conn, hotFixUuid);
            for(HostPatch patch : patches) {
                PoolPatch pp = patch.getPoolPatch(conn);
                if (pp.equals(poolPatch) && patch.getApplied(conn)) {
View Full Code Here

                long cap = extsr.getPhysicalSize(conn);
                if (cap > 0) {
                    long avail = cap - extsr.getPhysicalUtilisation(conn);
                    String name = "Cloud Stack Local EXT Storage Pool for " + _host.uuid;
                    extsr.setNameDescription(conn, name);
                    Host host = Host.getByUuid(conn, _host.uuid);
                    String address = host.getAddress(conn);
                    StoragePoolInfo pInfo = new StoragePoolInfo(extsr.getNameLabel(conn), address, SRType.EXT.toString(), SRType.EXT.toString(), Storage.StoragePoolType.EXT, cap, avail);
                    StartupStorageCommand cmd = new StartupStorageCommand();
                    cmd.setPoolInfo(pInfo);
                    cmd.setGuid(_host.uuid);
                    cmd.setDataCenter(Long.toString(_dcId));
View Full Code Here

                    if (vlannum.equals("-1")) {
                        return;
                    }
                    try {
                        vlan.destroy(conn);
                        Host host = Host.getByUuid(conn, _host.uuid);
                        host.forgetDataSourceArchives(conn, "pif_" + bridge + "_tx");
                        host.forgetDataSourceArchives(conn, "pif_" + bridge + "_rx");
                        host.forgetDataSourceArchives(conn, "pif_" + device + "." + vlannum + "_tx");
                        host.forgetDataSourceArchives(conn, "pif_" + device + "." + vlannum + "_rx");
                    } catch (XenAPIException e) {
                        s_logger.info("Catch " + e.getClass().getName() + ": failed to destory VLAN " + device + " on host " + _host.uuid + " due to " + e.toString());
                    }
                }
                return;
View Full Code Here

        }
        synchronized (poolUuid.intern()) {
            mConn = getConnect(poolUuid);
            if (mConn != null){
                try{
                    Host host = Host.getByUuid(mConn, hostUuid);
                    if (!host.getEnabled(mConn)) {
                        String msg = "Cannot connect this host " + ipAddress + " due to the host is not enabled";
                        s_logger.debug(msg);
                        if (mConn.getIp().equalsIgnoreCase(ipAddress)) {
                            removeConnect(poolUuid);
                            mConn = null;
                        }
                        throw new CloudRuntimeException(msg);
                    }
                    return mConn;
                } catch (CloudRuntimeException e) {
                        throw e;
                } catch (Exception e) {
                    if (s_logger.isDebugEnabled()) {
                        s_logger.debug("connect through IP(" + mConn.getIp() + " for pool(" + poolUuid + ") is broken due to " + e.toString());
                    }
                    removeConnect(poolUuid);
                    mConn = null;
                }
            }

            if ( mConn == null ) {
                try {
                    Connection conn = new Connection(getURL(ipAddress), 5);
                    Session sess = loginWithPassword(conn, username, password, APIVersion.latest().toString());
                    Host host = sess.getThisHost(conn);
                    Boolean hostenabled = host.getEnabled(conn);
                    if( sess != null ){
                        try{
                            Session.logout(conn);
                        } catch (Exception e) {
                        }
                        conn.dispose();
                    }
                    if (!hostenabled) {
                        String msg = "Unable to create master connection, due to master Host " + ipAddress + " is not enabled";
                        s_logger.debug(msg);
                        throw new CloudRuntimeException(msg);
                    }
                    mConn = new XenServerConnection(getURL(ipAddress), ipAddress, username, password, _retries, _interval, wait);
                    loginWithPassword(mConn, username, password, APIVersion.latest().toString());
                catch (Types.HostIsSlave e) {
                    String maddress = e.masterIPAddress;
                    mConn = new XenServerConnection(getURL(maddress), maddress, username, password, _retries, _interval, wait);
                    try {
                        Session session = loginWithPassword(mConn, username, password, APIVersion.latest().toString());
                        Host host = session.getThisHost(mConn);
                        if (!host.getEnabled(mConn)) {
                            String msg = "Unable to create master connection, due to master Host " + maddress + " is not enabled";
                            s_logger.debug(msg);
                            throw new CloudRuntimeException(msg);
                        }
                    }  catch (Exception e1) {
View Full Code Here

            }
            if (s_logger.isTraceEnabled()) {
                s_logger.trace("callHostPlugin executing for command " + cmd
                        + " with " + getArgsString(args));
            }
            Host host = Host.getByUuid(conn, _host.uuid);
            task = host.callPluginAsync(conn, plugin, cmd, args);
            // poll every 1 seconds
            waitForTask(conn, task, 1000, timeout);
            checkForSuccess(conn, task);
            String result = task.getResult(conn);
            if (s_logger.isTraceEnabled()) {
View Full Code Here

        VirtualMachineTO vmSpec = cmd.getVirtualMachine();
        String vmName = vmSpec.getName();
        try {
            Connection conn = getConnection();
            Set<VM> vms = VM.getByNameLabel(conn, vmName);
            Host host = Host.getByUuid(conn, _host.uuid);

            // If DMC is not enable then don't execute this command.
            if (!isDmcEnabled(conn, host)) {
                throw new CloudRuntimeException("Unable to scale the vm: " + vmName + " as DMC - Dynamic memory control is not enabled for the XenServer:" + _host.uuid +
                        " ,check your license and hypervisor version.");
View Full Code Here

                    if (pbdr.host.getUuid(conn).equals(_host.uuid)) {
                        return;
                    }
                }
                sr.setShared(conn, true);
                Host host = Host.getByUuid(conn, _host.uuid);
                PBD.Record pbdr = pbds.iterator().next().getRecord(conn);
                pbdr.host = host;
                pbdr.uuid = "";
                PBD pbd = PBD.create(conn, pbdr);
                pbdPlug(conn, pbd, pbd.getUuid(conn));
View Full Code Here

TOP

Related Classes of com.xensource.xenapi.Host

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.