LGTM, thanks.
On Mon, Oct 7, 2013 at 4:37 PM, Jose A. Lopes <[email protected]> wrote: > Add constants related to the Haskell type 'ReplaceDisksMode'. The > data type declaration for 'ReplaceDisksMode' is also moved from > 'Ganeti.OpParams' to 'Ganeti.Types' because it used to be used only by > the opcodes and now it is also needed for the constants. > > Signed-off-by: Jose A. Lopes <[email protected]> > --- > lib/constants.py | 16 +++++----------- > src/Ganeti/HsConstants.hs | 18 ++++++++++++++++++ > src/Ganeti/OpParams.hs | 9 --------- > src/Ganeti/Types.hs | 14 ++++++++++++++ > 4 files changed, 37 insertions(+), 20 deletions(-) > > diff --git a/lib/constants.py b/lib/constants.py > index f154f5f..f8bc699 100644 > --- a/lib/constants.py > +++ b/lib/constants.py > @@ -525,17 +525,11 @@ DISK_USERSPACE = _constants.DISK_USERSPACE > DISK_KERNELSPACE = _constants.DISK_KERNELSPACE > DISK_VALID_ACCESS_MODES = _constants.DISK_VALID_ACCESS_MODES > > -# disk replacement mode > -REPLACE_DISK_PRI = "replace_on_primary" # replace disks on primary > -REPLACE_DISK_SEC = "replace_on_secondary" # replace disks on secondary > -REPLACE_DISK_CHG = "replace_new_secondary" # change secondary node > -REPLACE_DISK_AUTO = "replace_auto" > -REPLACE_MODES = compat.UniqueFrozenset([ > - REPLACE_DISK_PRI, > - REPLACE_DISK_SEC, > - REPLACE_DISK_CHG, > - REPLACE_DISK_AUTO, > - ]) > +REPLACE_DISK_PRI = _constants.REPLACE_DISK_PRI > +REPLACE_DISK_SEC = _constants.REPLACE_DISK_SEC > +REPLACE_DISK_CHG = _constants.REPLACE_DISK_CHG > +REPLACE_DISK_AUTO = _constants.REPLACE_DISK_AUTO > +REPLACE_MODES = _constants.REPLACE_MODES > > # Instance export mode > EXPORT_MODE_LOCAL = _constants.EXPORT_MODE_LOCAL > diff --git a/src/Ganeti/HsConstants.hs b/src/Ganeti/HsConstants.hs > index a6424a6..440d2e0 100644 > --- a/src/Ganeti/HsConstants.hs > +++ b/src/Ganeti/HsConstants.hs > @@ -510,6 +510,24 @@ diskRdwr = Types.diskModeToRaw DiskRdWr > diskAccessSet :: FrozenSet String > diskAccessSet = ConstantUtils.mkSet $ map Types.diskModeToRaw [minBound..] > > +-- * Disk replacement mode > + > +replaceDiskAuto :: String > +replaceDiskAuto = Types.replaceDisksModeToRaw ReplaceAuto > + > +replaceDiskChg :: String > +replaceDiskChg = Types.replaceDisksModeToRaw ReplaceNewSecondary > + > +replaceDiskPri :: String > +replaceDiskPri = Types.replaceDisksModeToRaw ReplaceOnPrimary > + > +replaceDiskSec :: String > +replaceDiskSec = Types.replaceDisksModeToRaw ReplaceOnSecondary > + > +replaceModes :: FrozenSet String > +replaceModes = > + ConstantUtils.mkSet $ map Types.replaceDisksModeToRaw [minBound..] > + > -- * Instance export mode > > exportModeLocal :: String > diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs > index ed06a02..a9aae86 100644 > --- a/src/Ganeti/OpParams.hs > +++ b/src/Ganeti/OpParams.hs > @@ -301,15 +301,6 @@ forceNonNeg i = case mkNonNegative i of > > -- ** Disks > > --- | Replace disks type. > -$(declareSADT "ReplaceDisksMode" > - [ ("ReplaceOnPrimary", 'C.replaceDiskPri) > - , ("ReplaceOnSecondary", 'C.replaceDiskSec) > - , ("ReplaceNewSecondary", 'C.replaceDiskChg) > - , ("ReplaceAuto", 'C.replaceDiskAuto) > - ]) > -$(makeJSONInstance ''ReplaceDisksMode) > - > -- | Disk index type (embedding constraints on the index value via a > -- smart constructor). > newtype DiskIndex = DiskIndex { unDiskIndex :: Int } > diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs > index c6d9f04..5a788be 100644 > --- a/src/Ganeti/Types.hs > +++ b/src/Ganeti/Types.hs > @@ -143,6 +143,8 @@ module Ganeti.Types > , storageFieldToRaw > , DiskAccessMode(..) > , diskAccessModeToRaw > + , ReplaceDisksMode(..) > + , replaceDisksModeToRaw > ) where > > import Control.Monad (liftM) > @@ -779,3 +781,15 @@ $(THH.declareLADT ''String "DiskAccessMode" > , ( "DiskKernelspace", "kernelspace") > ]) > $(THH.makeJSONInstance ''DiskAccessMode) > + > +-- | Replace disks type. > +$(THH.declareLADT ''String "ReplaceDisksMode" > + [ -- Replace disks on primary > + ("ReplaceOnPrimary", "replace_on_primary") > + -- Replace disks on secondary > + , ("ReplaceOnSecondary", "replace_on_secondary") > + -- Change secondary node > + , ("ReplaceNewSecondary", "replace_new_secondary") > + , ("ReplaceAuto", "replace_auto") > + ]) > +$(THH.makeJSONInstance ''ReplaceDisksMode) > -- > 1.8.4 > > -- Thomas Thrainer | Software Engineer | [email protected] | Google Germany GmbH Dienerstr. 12 80331 München Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Graham Law, Christine Elizabeth Flores
