From 669d7e3d1ce8f832a7ff4b11de4f2bcab9494c27 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Fri, 20 Mar 2009 18:16:21 +0100 Subject: [PATCH] Introduce a namespace for the modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The modules are moved from the βtopβ namespace to βGaneti.HToolsβ, in compliance with standard practices. --- {src => Ganeti/HTools}/Cluster.hs | 14 +++++++------- {src => Ganeti/HTools}/Container.hs | 2 +- {src => Ganeti/HTools}/Instance.hs | 2 +- {src => Ganeti/HTools}/Node.hs | 10 +++++----- {src => Ganeti/HTools}/PeerMap.hs | 26 +++++++++++++------------- {src => Ganeti/HTools}/Rapi.hs | 4 ++-- {src => Ganeti/HTools}/Utils.hs | 4 ++-- {src => Ganeti/HTools}/Version.hs.in | 2 +- Makefile | 22 ++++++++++++++++------ src/hbal.hs => hbal.hs | 10 +++++----- src/hn1.hs => hn1.hs | 12 ++++++------ src/Makefile | 16 ---------------- 12 files changed, 59 insertions(+), 65 deletions(-) rename {src => Ganeti/HTools}/Cluster.hs (99%) rename {src => Ganeti/HTools}/Container.hs (98%) rename {src => Ganeti/HTools}/Instance.hs (98%) rename {src => Ganeti/HTools}/Node.hs (97%) rename {src => Ganeti/HTools}/PeerMap.hs (84%) rename {src => Ganeti/HTools}/Rapi.hs (98%) rename {src => Ganeti/HTools}/Utils.hs (96%) rename {src => Ganeti/HTools}/Version.hs.in (76%) rename src/hbal.hs => hbal.hs (97%) rename src/hn1.hs => hn1.hs (96%) delete mode 100644 src/Makefile diff --git a/src/Cluster.hs b/Ganeti/HTools/Cluster.hs similarity index 99% rename from src/Cluster.hs rename to Ganeti/HTools/Cluster.hs index 7b69ef5dc..c7b73501f 100644 --- a/src/Cluster.hs +++ b/Ganeti/HTools/Cluster.hs @@ -5,7 +5,7 @@ goes into the "Main" module. -} -module Cluster +module Ganeti.HTools.Cluster ( -- * Types NodeList @@ -38,10 +38,10 @@ import Data.Maybe (isNothing, fromJust) import Text.Printf (printf) import Data.Function -import qualified Container -import qualified Instance -import qualified Node -import Utils +import qualified Ganeti.HTools.Container as Container +import qualified Ganeti.HTools.Instance as Instance +import qualified Ganeti.HTools.Node as Node +import Ganeti.HTools.Utils type NodeList = Container.Container Node.Node type InstanceList = Container.Container Instance.Instance @@ -224,10 +224,10 @@ checkRemoval nl victims = -- | Computes the removals list for a given depth -computeRemovals :: Cluster.NodeList +computeRemovals :: NodeList -> [Instance.Instance] -> Int - -> [Maybe Cluster.Removal] + -> [Maybe Removal] computeRemovals nl bad_instances depth = map (checkRemoval nl) $ genNames depth bad_instances diff --git a/src/Container.hs b/Ganeti/HTools/Container.hs similarity index 98% rename from src/Container.hs rename to Ganeti/HTools/Container.hs index d72823845..0fb2c7f44 100644 --- a/src/Container.hs +++ b/Ganeti/HTools/Container.hs @@ -5,7 +5,7 @@ give the best performance for our workload. -} -module Container +module Ganeti.HTools.Container ( -- * Types Container diff --git a/src/Instance.hs b/Ganeti/HTools/Instance.hs similarity index 98% rename from src/Instance.hs rename to Ganeti/HTools/Instance.hs index f29039aa2..0e5d965cb 100644 --- a/src/Instance.hs +++ b/Ganeti/HTools/Instance.hs @@ -4,7 +4,7 @@ The instance data type holds very few fields, the algorithm intelligence is in the "Node" and "Cluster" modules. -} -module Instance where +module Ganeti.HTools.Instance where data Instance = Instance { mem :: Int -- ^ memory of the instance , dsk :: Int -- ^ disk size of instance diff --git a/src/Node.hs b/Ganeti/HTools/Node.hs similarity index 97% rename from src/Node.hs rename to Ganeti/HTools/Node.hs index 160136610..e95a60d2e 100644 --- a/src/Node.hs +++ b/Ganeti/HTools/Node.hs @@ -4,7 +4,7 @@ updated value. -} -module Node +module Ganeti.HTools.Node ( Node(failN1, idx, f_mem, f_dsk, p_mem, p_dsk, slist, plist, p_rem) -- * Constructor @@ -26,11 +26,11 @@ module Node import Data.List import Text.Printf (printf) -import qualified Container -import qualified Instance -import qualified PeerMap +import qualified Ganeti.HTools.Container as Container +import qualified Ganeti.HTools.Instance as Instance +import qualified Ganeti.HTools.PeerMap as PeerMap -import Utils +import Ganeti.HTools.Utils data Node = Node { t_mem :: Double -- ^ total memory (Mib) , f_mem :: Int -- ^ free memory (MiB) diff --git a/src/PeerMap.hs b/Ganeti/HTools/PeerMap.hs similarity index 84% rename from src/PeerMap.hs rename to Ganeti/HTools/PeerMap.hs index 284fa70f6..173c8c992 100644 --- a/src/PeerMap.hs +++ b/Ganeti/HTools/PeerMap.hs @@ -7,19 +7,19 @@ implementation should be easy in case it's needed. -} -module PeerMap ( - PeerMap, - Key, - Elem, - empty, - create, - accumArray, - PeerMap.find, - add, - remove, - maxElem - ) - where +module Ganeti.HTools.PeerMap + ( + PeerMap, + Key, + Elem, + empty, + create, + accumArray, + Ganeti.HTools.PeerMap.find, + add, + remove, + maxElem + ) where import Data.Maybe (fromMaybe) import Data.List diff --git a/src/Rapi.hs b/Ganeti/HTools/Rapi.hs similarity index 98% rename from src/Rapi.hs rename to Ganeti/HTools/Rapi.hs index 263cf13f0..e35231352 100644 --- a/src/Rapi.hs +++ b/Ganeti/HTools/Rapi.hs @@ -2,7 +2,7 @@ -} -module Rapi +module Ganeti.HTools.Rapi ( getNodes , getInstances @@ -16,7 +16,7 @@ import Data.Maybe import Control.Monad import Text.JSON import Text.Printf (printf) -import Utils () +import Ganeti.HTools.Utils () {-- Our cheap monad-like stuff. diff --git a/src/Utils.hs b/Ganeti/HTools/Utils.hs similarity index 96% rename from src/Utils.hs rename to Ganeti/HTools/Utils.hs index e092f7204..737b94a97 100644 --- a/src/Utils.hs +++ b/Ganeti/HTools/Utils.hs @@ -1,6 +1,6 @@ {-| Utility functions -} -module Utils where +module Ganeti.HTools.Utils where import Data.Either import Data.List @@ -10,7 +10,7 @@ import System import System.IO import System.Info import Text.Printf -import qualified Version +import qualified Ganeti.HTools.Version as Version import Debug.Trace diff --git a/src/Version.hs.in b/Ganeti/HTools/Version.hs.in similarity index 76% rename from src/Version.hs.in rename to Ganeti/HTools/Version.hs.in index 063bbd7b5..daffa76ca 100644 --- a/src/Version.hs.in +++ b/Ganeti/HTools/Version.hs.in @@ -1,4 +1,4 @@ -module Version +module Ganeti.HTools.Version ( version -- ^ the version of the tree ) where diff --git a/Makefile b/Makefile index 6f6254bbf..9f1f3834e 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,10 @@ HDDIR = apidoc # Haskell rules -all: version - $(MAKE) -C src +all: hbal hn1 + +hn1 hbal: Ganeti/HTools/Version.hs + ghc --make -O2 -W $@ README.html: README rst2html $< $@ @@ -25,16 +27,24 @@ doc: README.html $(HSRCS) clean: - rm -f *.o *.cmi *.cmo *.cmx *.old hn1 zn1 *.prof *.ps *.stat *.aux \ - gmon.out *.hi README.html TAGS version + rm -f *.o hn1 zn1 *.prof *.ps *.stat *.aux \ + gmon.out *.hi README.html TAGS Ganeti/HTools/Version.hs + git describe >/dev/null && rm -f version version: git describe > $@ +Ganeti/HTools/Version.hs: Ganeti/HTools/Version.hs.in version + sed -e "s/%ver%/$$(cat ../version)/" < $< > $@ + dist: version VN=$$(cat version|sed 's/^v//') ; \ ANAME="htools-$$VN.tar" ; \ - git archive --format=tar --prefix=htools-$$VN/ HEAD > $$ANAME ; \ - tar -r -f $$ANAME --transform="s,^,htools-$$VN/," version + rm -f $$ANAME $$ANAME.gz ; \ + git archive --format=tar --prefix=htools-$$VN/ HEAD > $$ANAME ; \ + tar -r -f $$ANAME --owner root --group root \ + --transform="s,^,htools-$$VN/," version ; \ + gzip -v9 $$ANAME ; \ + tar tzvf $$ANAME.gz .PHONY : all doc clean hn1 dist diff --git a/src/hbal.hs b/hbal.hs similarity index 97% rename from src/hbal.hs rename to hbal.hs index fea3f9ff5..3d3670043 100644 --- a/src/hbal.hs +++ b/hbal.hs @@ -14,11 +14,11 @@ import qualified System import Text.Printf (printf) -import qualified Container -import qualified Cluster -import qualified Version -import Rapi -import Utils +import qualified Ganeti.HTools.Container as Container +import qualified Ganeti.HTools.Cluster as Cluster +import qualified Ganeti.HTools.Version as Version +import Ganeti.HTools.Rapi +import Ganeti.HTools.Utils -- | Command line options structure. data Options = Options diff --git a/src/hn1.hs b/hn1.hs similarity index 96% rename from src/hn1.hs rename to hn1.hs index 2c8af7bba..754d926e2 100644 --- a/src/hn1.hs +++ b/hn1.hs @@ -14,12 +14,12 @@ import qualified System import Text.Printf (printf) -import qualified Container -import qualified Instance -import qualified Cluster -import qualified Version -import Utils -import Rapi +import qualified Ganeti.HTools.Container as Container +import qualified Ganeti.HTools.Instance as Instance +import qualified Ganeti.HTools.Cluster as Cluster +import qualified Ganeti.HTools.Version as Version +import Ganeti.HTools.Rapi +import Ganeti.HTools.Utils -- | Command line options structure. data Options = Options diff --git a/src/Makefile b/src/Makefile deleted file mode 100644 index aefd67b0c..000000000 --- a/src/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -all: hn1 hbal - -hn1: Version.hs - ghc --make -O2 -W hn1 - -hbal: Version.hs - ghc --make -O2 -W hbal - -clean: - rm -f *.o *.old hn1 hbal *.prof *.ps *.stat *.aux \ - *.hi README.html TAGS Version.hs - -Version.hs: Version.hs.in ../version - sed -e "s/%ver%/$$(cat ../version)/" < $< > $@ - -.PHONY : all clean hn1 hbal -- GitLab