Commit ac20b4ad authored by Klaus Aehlig's avatar Klaus Aehlig

Merge branch 'stable-2.11' into stable-2.12

* stable-2.11
  (no changes)

* stable-2.10
  Fixed typos
  Pass correct params in move-instance
  In CanTieredAlloc test set IPolicy
  Make genInstanceMaybeBiggerThanNode honor policy lower bound
  Also export a null ISpec
  Support instance generation within ranges
  Add a function to leave the list monad

Conflicts:
	tools/move-instance
Resolution:
	manually apply 6f918cb2 to version on 2.12
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parents 5705bba1 a56d29a6
......@@ -125,7 +125,7 @@ command.
The NICs of the instances can be specified via the ``--net``
option. By default, one NIC is created for the instance, with a
random MAC, and set up according the the cluster level NIC
random MAC, and set up according to the cluster level NIC
parameters. Each NIC can take these parameters (all optional):
mac
......@@ -140,7 +140,7 @@ ip
passed in the **network** parameter if this NIC is meant to be
connected to the said network. ``--no-conflicts-check`` can be used
to override this check. The special value **pool** causes Ganeti to
select an IP from the the network the NIC is or will be connected to.
select an IP from the network the NIC is or will be connected to.
One can pick an externally reserved IP of a network along with
``--no-conflict-check``. Note that this IP cannot be assigned to
any other instance until it gets released.
......
......@@ -39,6 +39,7 @@ module Test.Ganeti.HTools.Cluster (testHTools_Cluster) where
import Test.QuickCheck hiding (Result)
import Control.Monad (liftM)
import qualified Data.IntMap as IntMap
import Data.Maybe
......@@ -168,7 +169,8 @@ prop_Alloc_sane inst =
prop_CanTieredAlloc :: Property
prop_CanTieredAlloc =
forAll (choose (2, 5)) $ \count ->
forAll (genOnlineNode `suchThat` isNodeBig 4) $ \node ->
forAll (liftM (Node.setPolicy Types.defIPolicy)
(genOnlineNode `suchThat` isNodeBig 4)) $ \node ->
forAll (genInstanceMaybeBiggerThanNode node) $ \inst ->
let nl = makeSmallCluster node count
il = Container.empty
......
......@@ -49,6 +49,7 @@ import Control.Applicative ((<$>))
import Control.Monad (liftM)
import Test.QuickCheck hiding (Result)
import Test.Ganeti.TestHTools (nullISpec)
import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon
import Test.Ganeti.HTools.Types ()
......@@ -62,25 +63,32 @@ import qualified Ganeti.HTools.Types as Types
-- * Arbitrary instances
-- | Generates a random instance with maximum disk/mem/cpu values.
genInstanceSmallerThan :: Int -> Int -> Int -> Maybe Int ->
Gen Instance.Instance
genInstanceSmallerThan lim_mem lim_dsk lim_cpu lim_spin = do
-- | Generates a random instance with maximum and minimum disk/mem/cpu values.
genInstanceWithin :: Int -> Int -> Int -> Int
-> Int -> Int -> Int -> Maybe Int
-> Gen Instance.Instance
genInstanceWithin min_mem min_dsk min_cpu min_spin
max_mem max_dsk max_cpu max_spin = do
name <- genFQDN
mem <- choose (0, lim_mem)
dsk <- choose (0, lim_dsk)
mem <- choose (min_mem, max_mem)
dsk <- choose (min_dsk, max_dsk)
run_st <- arbitrary
pn <- arbitrary
sn <- arbitrary
vcpus <- choose (0, lim_cpu)
vcpus <- choose (min_cpu, max_cpu)
dt <- arbitrary
spindles <- case lim_spin of
Nothing -> genMaybe $ choose (0, maxSpindles)
Just ls -> liftM Just $ choose (0, ls)
spindles <- case max_spin of
Nothing -> genMaybe $ choose (min_spin, maxSpindles)
Just ls -> liftM Just $ choose (min_spin, ls)
let disk = Instance.Disk dsk spindles
return $ Instance.create
name mem dsk [disk] vcpus run_st [] True pn sn dt 1 []
-- | Generate an instance with maximum disk/mem/cpu values.
genInstanceSmallerThan :: Int -> Int -> Int -> Maybe Int
-> Gen Instance.Instance
genInstanceSmallerThan = genInstanceWithin 0 0 0 0
-- | Generates an instance smaller than a node.
genInstanceSmallerThanNode :: Node.Node -> Gen Instance.Instance
genInstanceSmallerThanNode node =
......@@ -92,12 +100,20 @@ genInstanceSmallerThanNode node =
else Nothing)
-- | Generates an instance possibly bigger than a node.
-- In any case, that instance will be bigger than the node's ipolicy's lower
-- bound.
genInstanceMaybeBiggerThanNode :: Node.Node -> Gen Instance.Instance
genInstanceMaybeBiggerThanNode node =
genInstanceSmallerThan (Node.availMem node + Types.unitMem * 2)
(Node.availDisk node + Types.unitDsk * 3)
(Node.availCpu node + Types.unitCpu * 4)
(if Node.exclStorage node
let minISpec = runListHead nullISpec Types.minMaxISpecsMinSpec
. Types.iPolicyMinMaxISpecs $ Node.iPolicy node
in genInstanceWithin (Types.iSpecMemorySize minISpec)
(Types.iSpecDiskSize minISpec)
(Types.iSpecCpuCount minISpec)
(Types.iSpecSpindleUse minISpec)
(Node.availMem node + Types.unitMem * 2)
(Node.availDisk node + Types.unitDsk * 3)
(Node.availCpu node + Types.unitCpu * 4)
(if Node.exclStorage node
then Just $ Node.fSpindles node +
Types.unitSpindle * 5
else Nothing)
......
......@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module Test.Ganeti.TestHTools
( nullIPolicy
, nullISpec
, defGroup
, defGroupList
, defGroupAssoc
......@@ -58,17 +59,21 @@ import qualified Ganeti.HTools.Types as Types
-- * Helpers
-- | An ISpec with 0 resources.
nullISpec :: Types.ISpec
nullISpec = Types.ISpec { Types.iSpecMemorySize = 0
, Types.iSpecCpuCount = 0
, Types.iSpecDiskSize = 0
, Types.iSpecDiskCount = 0
, Types.iSpecNicCount = 0
, Types.iSpecSpindleUse = 0
}
-- | Null iPolicy, and by null we mean very liberal.
nullIPolicy :: Types.IPolicy
nullIPolicy = Types.IPolicy
{ Types.iPolicyMinMaxISpecs = [Types.MinMaxISpecs
{ Types.minMaxISpecsMinSpec = Types.ISpec { Types.iSpecMemorySize = 0
, Types.iSpecCpuCount = 0
, Types.iSpecDiskSize = 0
, Types.iSpecDiskCount = 0
, Types.iSpecNicCount = 0
, Types.iSpecSpindleUse = 0
}
{ Types.minMaxISpecsMinSpec = nullISpec
, Types.minMaxISpecsMaxSpec = Types.ISpec
{ Types.iSpecMemorySize = maxBound
, Types.iSpecCpuCount = maxBound
......
......@@ -510,7 +510,7 @@ class MoveDestExecutor(object):
mrt.move.dest_disk_template,
mrt.src_instinfo, mrt.src_expinfo,
mrt.move.hvparams, mrt.move.beparams,
mrt.move.beparams, mrt.move.nics,
mrt.move.osparams, mrt.move.nics,
is_attempt_opportunistic
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment