Пример #1
0
        public vmserverTotals getVMServerTotals(bladeSpec blade)
        {
            // You should hold a lock on the VM server before calling this, to ensure the result doesn't change before you get
            // a chance to use it.
            if ((blade.permittedAccessRead & bladeLockType.lockVMCreation) == bladeLockType.lockNone)
            {
                throw new Exception("lockVMCreation is needed when calling .getVMServerTotals");
            }

            string sqlCommand = "select sum(cpucount) as cpus, sum(memoryMB) as ram, count(*) as VMs " +
                                " from vmConfiguration " +
                                "join bladeConfiguration on parentbladeID = bladeConfigKey " +
                                "where bladeIP = $vmServerIP" +
                                " and isWaitingForResources = 0 ";

            using (SQLiteCommand cmd = new SQLiteCommand(sqlCommand, conn))
            {
                cmd.Parameters.AddWithValue("$vmServerIP", blade.bladeIP);
                using (SQLiteDataReader reader = cmd.ExecuteReader())
                {
                    if (!reader.Read())
                    {
                        throw new Exception();
                    }
                    return(new vmserverTotals(reader));
                }
            }
        }
Пример #2
0
        public static hypervisor_iLo createHypForBlade(bladeSpec blade, snapshotDetails snap, NASParams nas)
        {
            userDesc usernameToUse = blade.credentials.First();

            return(new hypervisor_iLo(new hypSpec_iLo(
                                          blade.bladeIP, usernameToUse.username, usernameToUse.password,
                                          blade.iLOIP, blade.iLoUsername, blade.iLoPassword,
                                          nas.IP, nas.username, nas.password,
                                          snap.friendlyName, snap.path,
                                          blade.kernelDebugPort, blade.kernelDebugKey)));
        }
Пример #3
0
        public override bool Equals(object obj)
        {
            bladeSpec compareTo = obj as bladeSpec;

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

            if (iscsiIP != compareTo.iscsiIP)
            {
                return(false);
            }
            if (bladeIP != compareTo.bladeIP)
            {
                return(false);
            }
            if (iLOIP != compareTo.iLOIP)
            {
                return(false);
            }
            if (kernelDebugPort != compareTo.kernelDebugPort)
            {
                return(false);
            }
            if (currentlyHavingBIOSDeployed != compareTo.currentlyHavingBIOSDeployed)
            {
                return(false);
            }
            if (currentlyBeingAVMServer != compareTo.currentlyBeingAVMServer)
            {
                return(false);
            }
            if (vmDeployState != compareTo.vmDeployState)
            {
                return(false);
            }
            if (bladeID != compareTo.bladeID)
            {
                return(false);
            }
            if (kernelDebugKey != compareTo.kernelDebugKey)
            {
                return(false);
            }
            if (kernelDebugPort != compareTo.kernelDebugPort)
            {
                return(false);
            }

            return(base.Equals(obj));
        }
Пример #4
0
        public static hypervisor_vmware_FreeNAS createHypForVM(vmSpec vmSpec, bladeSpec vmServerSpec, snapshotDetails snapshotInfo, NASParams nas, clientExecutionMethod exec = clientExecutionMethod.smbWithWMI)
        {
            userDesc usernameToUse = vmSpec.credentials.First();

            return(new hypervisor_vmware_FreeNAS(
                       new hypSpec_vmware(
                           vmSpec.friendlyName, vmServerSpec.bladeIP, vmServerSpec.ESXiUsername, vmServerSpec.ESXiPassword,
                           usernameToUse.username, usernameToUse.password, snapshotInfo.friendlyName, snapshotInfo.path,
                           vmSpec.kernelDebugPort, vmSpec.kernelDebugKey, vmSpec.VMIP
                           ),
                       nas.IP, nas.username, nas.password,
                       exec));
        }
Пример #5
0
 protected override NASAccess getNasForDevice(bladeSpec vmServer)
 {
     if (cachedNAS == null)
     {
         lock (cachedNASLock)
         {
             if (cachedNAS == null)
             {
                 cachedNAS = FreeNasGroup.getOrMake(Settings.Default.iscsiServerIP, Settings.Default.iscsiServerUsername, Settings.Default.iscsiServerPassword);
             }
         }
     }
     return(cachedNAS);
 }
Пример #6
0
        // FIXME: code duplication
        public lockableBladeSpec getBladeByIP(string IP, bladeLockType readLock, bladeLockType writeLock, bool permitAccessDuringBIOS = false, bool permitAccessDuringDeployment = false)
        {
            bladeLockType origReadLock = readLock | writeLock;

            readLock = origReadLock;

            // We need to lock IP addressess, since we're searching by them.
            readLock = readLock | bladeLockType.lockIPAddresses;
            readLock = readLock | bladeLockType.lockvmDeployState;
            readLock = readLock | bladeLockType.lockBIOS;

            lockableBladeSpec toRet = null;

            try
            {
                toRet = new lockableBladeSpec(IP, readLock, writeLock);

                string sqlCommand = "select * from bladeOwnership " +
                                    "join bladeConfiguration on ownershipKey = bladeConfiguration.ownershipID " +
                                    "where bladeIP = $bladeIP";
                using (SQLiteCommand cmd = new SQLiteCommand(sqlCommand, conn))
                {
                    cmd.Parameters.AddWithValue("$bladeIP", IP);
                    using (SQLiteDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            bladeSpec newSpec = new bladeSpec(conn, reader, readLock, writeLock);
                            toRet.setSpec(newSpec);

                            if ((!permitAccessDuringDeployment) &&
                                newSpec.vmDeployState != VMDeployStatus.notBeingDeployed &&
                                newSpec.vmDeployState != VMDeployStatus.failed &&
                                newSpec.vmDeployState != VMDeployStatus.readyForDeployment)
                            {
                                throw new Exception("Attempt to access blade during VM deployment");
                            }
                            if ((!permitAccessDuringBIOS) && newSpec.currentlyHavingBIOSDeployed)
                            {
                                throw new Exception("Attempt to access blade during BIOS deployment");
                            }

                            if ((origReadLock & bladeLockType.lockvmDeployState) == 0 &&
                                (writeLock & bladeLockType.lockvmDeployState) == 0)
                            {
                                toRet.downgradeLocks(bladeLockType.lockvmDeployState, bladeLockType.lockNone);
                            }

                            if ((origReadLock & bladeLockType.lockBIOS) == 0 &&
                                (writeLock & bladeLockType.lockBIOS) == 0)
                            {
                                toRet.downgradeLocks(bladeLockType.lockBIOS, bladeLockType.lockNone);
                            }

                            leakCheckerInspector.monitorDisposable(toRet);
                            return(toRet);
                        }
                        // No records returned.
                        throw new bladeNotFoundException();
                    }
                }
            }
            catch (Exception)
            {
                if (toRet != null)
                {
                    toRet.Dispose();
                }
                throw;
            }
        }
Пример #7
0
 public hypervisor_mocked_ilo(bladeSpec spec, hostStateManagerMocked.mockedExecutionDelegate onMockedExecution)
     : base(null, onMockedExecution)
 {
     _spec = new hypSpec_iLo(spec.bladeIP, Settings.Default.vmUsername, Settings.Default.vmPassword, spec.iLOIP, Settings.Default.iloUsername, Settings.Default.iloPassword, null, null, null, spec.currentSnapshot, null, spec.kernelDebugPort, null);
 }
Пример #8
0
 public hypervisor_mocked_vmware(vmSpec spec, bladeSpec parentSpec, hostStateManagerMocked.mockedExecutionDelegate onMockedExecution)
     : base(null, onMockedExecution)
 {
     _spec = new hypSpec_vmware(spec.friendlyName, parentSpec.bladeIP, Settings.Default.esxiUsername, Settings.Default.esxiPassword, Settings.Default.vmUsername, Settings.Default.vmPassword, spec.currentSnapshot, null, spec.kernelDebugPort, spec.kernelDebugKey, spec.VMIP);
 }
Пример #9
0
 protected override NASAccess getNasForDevice(bladeSpec vmServer)
 {
     return(nas);
 }