[PATCH master] Rename Confd.hs to Confd/Types.hs

2 views
Skip to first unread message

Iustin Pop

unread,
Nov 8, 2012, 6:02:11 AM11/8/12
to ganeti...@googlegroups.com, Iustin Pop
This should be the last module rename, promise!

We rename this to conform to the other hierarchies (e.g. Query), and
to not have both Confd.hs and Confd/*.hs.

Signed-off-by: Iustin Pop <ius...@google.com>
---
Makefile.am | 2 +-
htest/Test/Ganeti/Confd/Utils.hs | 2 +-
htools/Ganeti/Confd.hs | 167 --------------------------------------
htools/Ganeti/Confd/Server.hs | 2 +-
htools/Ganeti/Confd/Types.hs | 167 ++++++++++++++++++++++++++++++++++++++
htools/Ganeti/Confd/Utils.hs | 2 +-
6 files changed, 171 insertions(+), 171 deletions(-)
delete mode 100644 htools/Ganeti/Confd.hs
create mode 100644 htools/Ganeti/Confd/Types.hs

diff --git a/Makefile.am b/Makefile.am
index d3103ab..d6bf864 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -422,8 +422,8 @@ HS_LIB_SRCS = \
htools/Ganeti/BasicTypes.hs \
htools/Ganeti/Common.hs \
htools/Ganeti/Compat.hs \
- htools/Ganeti/Confd.hs \
htools/Ganeti/Confd/Server.hs \
+ htools/Ganeti/Confd/Types.hs \
htools/Ganeti/Confd/Utils.hs \
htools/Ganeti/Config.hs \
htools/Ganeti/Daemon.hs \
diff --git a/htest/Test/Ganeti/Confd/Utils.hs b/htest/Test/Ganeti/Confd/Utils.hs
index f596ae3..e279e2d 100644
--- a/htest/Test/Ganeti/Confd/Utils.hs
+++ b/htest/Test/Ganeti/Confd/Utils.hs
@@ -36,7 +36,7 @@ import Test.Ganeti.TestHelper
import Test.Ganeti.TestCommon

import qualified Ganeti.BasicTypes as BasicTypes
-import qualified Ganeti.Confd as Confd
+import qualified Ganeti.Confd.Types as Confd
import qualified Ganeti.Confd.Utils as Confd.Utils
import qualified Ganeti.Constants as C
import qualified Ganeti.Hash as Hash
diff --git a/htools/Ganeti/Confd.hs b/htools/Ganeti/Confd.hs
deleted file mode 100644
index 6746f86..0000000
--- a/htools/Ganeti/Confd.hs
+++ /dev/null
@@ -1,167 +0,0 @@
-{-# LANGUAGE TemplateHaskell #-}
-
-{-| Implementation of the Ganeti confd types.
-
--}
-
-{-
-
-Copyright (C) 2011, 2012 Google Inc.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301, USA.
-
--}
-
-module Ganeti.Confd
- ( C.confdProtocolVersion
- , C.confdMaxClockSkew
- , C.confdConfigReloadTimeout
- , C.confdConfigReloadRatelimit
- , C.confdMagicFourcc
- , C.confdDefaultReqCoverage
- , C.confdClientExpireTimeout
- , C.maxUdpDataSize
- , ConfdRequestType(..)
- , ConfdReqQ(..)
- , ConfdReqField(..)
- , ConfdReplyStatus(..)
- , ConfdNodeRole(..)
- , ConfdErrorType(..)
- , ConfdRequest(..)
- , ConfdReply(..)
- , ConfdQuery(..)
- , SignedMessage(..)
- ) where
-
-import Text.JSON
-
-import qualified Ganeti.Constants as C
-import Ganeti.THH
-import Ganeti.JSON
-
-{-
- Note that we re-export as is from Constants the following simple items:
- - confdProtocolVersion
- - confdMaxClockSkew
- - confdConfigReloadTimeout
- - confdConfigReloadRatelimit
- - confdMagicFourcc
- - confdDefaultReqCoverage
- - confdClientExpireTimeout
- - maxUdpDataSize
-
--}
-
-$(declareIADT "ConfdRequestType"
- [ ("ReqPing", 'C.confdReqPing )
- , ("ReqNodeRoleByName", 'C.confdReqNodeRoleByname )
- , ("ReqNodePipList", 'C.confdReqNodePipList )
- , ("ReqNodePipByInstPip", 'C.confdReqNodePipByInstanceIp )
- , ("ReqClusterMaster", 'C.confdReqClusterMaster )
- , ("ReqMcPipList", 'C.confdReqMcPipList )
- , ("ReqInstIpsList", 'C.confdReqInstancesIpsList )
- , ("ReqNodeDrbd", 'C.confdReqNodeDrbd )
- ])
-$(makeJSONInstance ''ConfdRequestType)
-
-$(declareSADT "ConfdReqField"
- [ ("ReqFieldName", 'C.confdReqfieldName )
- , ("ReqFieldIp", 'C.confdReqfieldIp )
- , ("ReqFieldMNodePip", 'C.confdReqfieldMnodePip )
- ])
-$(makeJSONInstance ''ConfdReqField)
-
--- Confd request query fields. These are used to narrow down queries.
--- These must be strings rather than integers, because json-encoding
--- converts them to strings anyway, as they're used as dict-keys.
-
-$(buildObject "ConfdReqQ" "confdReqQ"
- [ renameField "Ip" .
- optionalField $ simpleField C.confdReqqIp [t| String |]
- , renameField "IpList" .
- defaultField [| [] |] $
- simpleField C.confdReqqIplist [t| [String] |]
- , renameField "Link" . optionalField $
- simpleField C.confdReqqLink [t| String |]
- , renameField "Fields" . defaultField [| [] |] $
- simpleField C.confdReqqFields [t| [ConfdReqField] |]
- ])
-
--- | Confd query type. This is complex enough that we can't
--- automatically derive it via THH.
-data ConfdQuery = EmptyQuery
- | PlainQuery String
- | DictQuery ConfdReqQ
- deriving (Show, Read, Eq)
-
-instance JSON ConfdQuery where
- readJSON o = case o of
- JSNull -> return EmptyQuery
- JSString s -> return . PlainQuery . fromJSString $ s
- JSObject _ -> fmap DictQuery (readJSON o::Result ConfdReqQ)
- _ -> fail $ "Cannot deserialise into ConfdQuery\
- \ the value '" ++ show o ++ "'"
- showJSON cq = case cq of
- EmptyQuery -> JSNull
- PlainQuery s -> showJSON s
- DictQuery drq -> showJSON drq
-
-$(declareIADT "ConfdReplyStatus"
- [ ( "ReplyStatusOk", 'C.confdReplStatusOk )
- , ( "ReplyStatusError", 'C.confdReplStatusError )
- , ( "ReplyStatusNotImpl", 'C.confdReplStatusNotimplemented )
- ])
-$(makeJSONInstance ''ConfdReplyStatus)
-
-$(declareIADT "ConfdNodeRole"
- [ ( "NodeRoleMaster", 'C.confdNodeRoleMaster )
- , ( "NodeRoleCandidate", 'C.confdNodeRoleCandidate )
- , ( "NodeRoleOffline", 'C.confdNodeRoleOffline )
- , ( "NodeRoleDrained", 'C.confdNodeRoleDrained )
- , ( "NodeRoleRegular", 'C.confdNodeRoleRegular )
- ])
-$(makeJSONInstance ''ConfdNodeRole)
-
-
--- Note that the next item is not a frozenset in Python, but we make
--- it a separate type for safety
-
-$(declareIADT "ConfdErrorType"
- [ ( "ConfdErrorUnknownEntry", 'C.confdErrorUnknownEntry )
- , ( "ConfdErrorInternal", 'C.confdErrorInternal )
- , ( "ConfdErrorArgument", 'C.confdErrorArgument )
- ])
-$(makeJSONInstance ''ConfdErrorType)
-
-$(buildObject "ConfdRequest" "confdRq"
- [ simpleField "protocol" [t| Int |]
- , simpleField "type" [t| ConfdRequestType |]
- , defaultField [| EmptyQuery |] $ simpleField "query" [t| ConfdQuery |]
- , simpleField "rsalt" [t| String |]
- ])
-
-$(buildObject "ConfdReply" "confdReply"
- [ simpleField "protocol" [t| Int |]
- , simpleField "status" [t| ConfdReplyStatus |]
- , simpleField "answer" [t| JSValue |]
- , simpleField "serial" [t| Int |]
- ])
-
-$(buildObject "SignedMessage" "signedMsg"
- [ simpleField "hmac" [t| String |]
- , simpleField "msg" [t| String |]
- , simpleField "salt" [t| String |]
- ])
diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs
index 2e9b4db..35aab41 100644
--- a/htools/Ganeti/Confd/Server.hs
+++ b/htools/Ganeti/Confd/Server.hs
@@ -50,7 +50,7 @@ import Ganeti.Errors
import Ganeti.Daemon
import Ganeti.JSON
import Ganeti.Objects
-import Ganeti.Confd
+import Ganeti.Confd.Types
import Ganeti.Confd.Utils
import Ganeti.Config
import Ganeti.Hash
diff --git a/htools/Ganeti/Confd/Types.hs b/htools/Ganeti/Confd/Types.hs
new file mode 100644
index 0000000..4ac4eae
--- /dev/null
+++ b/htools/Ganeti/Confd/Types.hs
@@ -0,0 +1,167 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+{-| Implementation of the Ganeti confd types.
+
+-}
+
+{-
+
+Copyright (C) 2011, 2012 Google Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.
+
+-}
+
+module Ganeti.Confd.Types
+ ( C.confdProtocolVersion
+ , C.confdMaxClockSkew
+ , C.confdConfigReloadTimeout
+ , C.confdConfigReloadRatelimit
+ , C.confdMagicFourcc
+ , C.confdDefaultReqCoverage
+ , C.confdClientExpireTimeout
+ , C.maxUdpDataSize
+ , ConfdRequestType(..)
+ , ConfdReqQ(..)
+ , ConfdReqField(..)
+ , ConfdReplyStatus(..)
+ , ConfdNodeRole(..)
+ , ConfdErrorType(..)
+ , ConfdRequest(..)
+ , ConfdReply(..)
+ , ConfdQuery(..)
+ , SignedMessage(..)
+ ) where
+
+import Text.JSON
+
+import qualified Ganeti.Constants as C
+import Ganeti.THH
+import Ganeti.JSON
+
+{-
+ Note that we re-export as is from Constants the following simple items:
+ - confdProtocolVersion
+ - confdMaxClockSkew
+ - confdConfigReloadTimeout
+ - confdConfigReloadRatelimit
+ - confdMagicFourcc
+ - confdDefaultReqCoverage
+ - confdClientExpireTimeout
+ - maxUdpDataSize
+
+-}
+
+$(declareIADT "ConfdRequestType"
+ [ ("ReqPing", 'C.confdReqPing )
+ , ("ReqNodeRoleByName", 'C.confdReqNodeRoleByname )
+ , ("ReqNodePipList", 'C.confdReqNodePipList )
+ , ("ReqNodePipByInstPip", 'C.confdReqNodePipByInstanceIp )
+ , ("ReqClusterMaster", 'C.confdReqClusterMaster )
+ , ("ReqMcPipList", 'C.confdReqMcPipList )
+ , ("ReqInstIpsList", 'C.confdReqInstancesIpsList )
+ , ("ReqNodeDrbd", 'C.confdReqNodeDrbd )
+ ])
+$(makeJSONInstance ''ConfdRequestType)
+
+$(declareSADT "ConfdReqField"
+ [ ("ReqFieldName", 'C.confdReqfieldName )
+ , ("ReqFieldIp", 'C.confdReqfieldIp )
+ , ("ReqFieldMNodePip", 'C.confdReqfieldMnodePip )
+ ])
+$(makeJSONInstance ''ConfdReqField)
+
+-- Confd request query fields. These are used to narrow down queries.
+-- These must be strings rather than integers, because json-encoding
+-- converts them to strings anyway, as they're used as dict-keys.
+
+$(buildObject "ConfdReqQ" "confdReqQ"
+ [ renameField "Ip" .
+ optionalField $ simpleField C.confdReqqIp [t| String |]
+ , renameField "IpList" .
+ defaultField [| [] |] $
+ simpleField C.confdReqqIplist [t| [String] |]
+ , renameField "Link" . optionalField $
+ simpleField C.confdReqqLink [t| String |]
+ , renameField "Fields" . defaultField [| [] |] $
+ simpleField C.confdReqqFields [t| [ConfdReqField] |]
+ ])
+
+-- | Confd query type. This is complex enough that we can't
+-- automatically derive it via THH.
+data ConfdQuery = EmptyQuery
+ | PlainQuery String
+ | DictQuery ConfdReqQ
+ deriving (Show, Read, Eq)
+
+instance JSON ConfdQuery where
+ readJSON o = case o of
+ JSNull -> return EmptyQuery
+ JSString s -> return . PlainQuery . fromJSString $ s
+ JSObject _ -> fmap DictQuery (readJSON o::Result ConfdReqQ)
+ _ -> fail $ "Cannot deserialise into ConfdQuery\
+ \ the value '" ++ show o ++ "'"
+ showJSON cq = case cq of
+ EmptyQuery -> JSNull
+ PlainQuery s -> showJSON s
+ DictQuery drq -> showJSON drq
+
+$(declareIADT "ConfdReplyStatus"
+ [ ( "ReplyStatusOk", 'C.confdReplStatusOk )
+ , ( "ReplyStatusError", 'C.confdReplStatusError )
+ , ( "ReplyStatusNotImpl", 'C.confdReplStatusNotimplemented )
+ ])
+$(makeJSONInstance ''ConfdReplyStatus)
+
+$(declareIADT "ConfdNodeRole"
+ [ ( "NodeRoleMaster", 'C.confdNodeRoleMaster )
+ , ( "NodeRoleCandidate", 'C.confdNodeRoleCandidate )
+ , ( "NodeRoleOffline", 'C.confdNodeRoleOffline )
+ , ( "NodeRoleDrained", 'C.confdNodeRoleDrained )
+ , ( "NodeRoleRegular", 'C.confdNodeRoleRegular )
+ ])
+$(makeJSONInstance ''ConfdNodeRole)
+
+
+-- Note that the next item is not a frozenset in Python, but we make
+-- it a separate type for safety
+
+$(declareIADT "ConfdErrorType"
+ [ ( "ConfdErrorUnknownEntry", 'C.confdErrorUnknownEntry )
+ , ( "ConfdErrorInternal", 'C.confdErrorInternal )
+ , ( "ConfdErrorArgument", 'C.confdErrorArgument )
+ ])
+$(makeJSONInstance ''ConfdErrorType)
+
+$(buildObject "ConfdRequest" "confdRq"
+ [ simpleField "protocol" [t| Int |]
+ , simpleField "type" [t| ConfdRequestType |]
+ , defaultField [| EmptyQuery |] $ simpleField "query" [t| ConfdQuery |]
+ , simpleField "rsalt" [t| String |]
+ ])
+
+$(buildObject "ConfdReply" "confdReply"
+ [ simpleField "protocol" [t| Int |]
+ , simpleField "status" [t| ConfdReplyStatus |]
+ , simpleField "answer" [t| JSValue |]
+ , simpleField "serial" [t| Int |]
+ ])
+
+$(buildObject "SignedMessage" "signedMsg"
+ [ simpleField "hmac" [t| String |]
+ , simpleField "msg" [t| String |]
+ , simpleField "salt" [t| String |]
+ ])
diff --git a/htools/Ganeti/Confd/Utils.hs b/htools/Ganeti/Confd/Utils.hs
index 01c7ee7..f79e6e8 100644
--- a/htools/Ganeti/Confd/Utils.hs
+++ b/htools/Ganeti/Confd/Utils.hs
@@ -37,7 +37,7 @@ import qualified Data.ByteString as B
import qualified Text.JSON as J

import Ganeti.BasicTypes
-import Ganeti.Confd
+import Ganeti.Confd.Types
import Ganeti.Hash
import qualified Ganeti.Constants as C
import qualified Ganeti.Path as Path
--
1.7.7.3

Iustin Pop

unread,
Nov 8, 2012, 6:06:53 AM11/8/12
to ganeti...@googlegroups.com, Iustin Pop
This should be the last module rename, promise!

We rename this to conform to the other hierarchies (e.g. Query), and
to not have both Confd.hs and Confd/*.hs.

Signed-off-by: Iustin Pop <ius...@google.com>
---
Now generated with -M…

Makefile.am | 2 +-
htest/Test/Ganeti/Confd/Utils.hs | 2 +-
htools/Ganeti/Confd/Server.hs | 2 +-
htools/Ganeti/{Confd.hs => Confd/Types.hs} | 2 +-
htools/Ganeti/Confd/Utils.hs | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
rename htools/Ganeti/{Confd.hs => Confd/Types.hs} (99%)
diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs
index 2e9b4db..35aab41 100644
--- a/htools/Ganeti/Confd/Server.hs
+++ b/htools/Ganeti/Confd/Server.hs
@@ -50,7 +50,7 @@ import Ganeti.Errors
import Ganeti.Daemon
import Ganeti.JSON
import Ganeti.Objects
-import Ganeti.Confd
+import Ganeti.Confd.Types
import Ganeti.Confd.Utils
import Ganeti.Config
import Ganeti.Hash
diff --git a/htools/Ganeti/Confd.hs b/htools/Ganeti/Confd/Types.hs
similarity index 99%
rename from htools/Ganeti/Confd.hs
rename to htools/Ganeti/Confd/Types.hs
index 6746f86..4ac4eae 100644
--- a/htools/Ganeti/Confd.hs
+++ b/htools/Ganeti/Confd/Types.hs
@@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

-}

-module Ganeti.Confd
+module Ganeti.Confd.Types
( C.confdProtocolVersion
, C.confdMaxClockSkew
, C.confdConfigReloadTimeout

Guido Trotter

unread,
Nov 8, 2012, 7:36:51 AM11/8/12
to Iustin Pop, Ganeti Development
LGTM

Thanks,

Guido
--
Guido Trotter
SRE - Corp Computing Services (aka Horsepower)
Google Germany
Reply all
Reply to author
Forward
0 new messages