Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
snf-ganeti
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
itminedu
snf-ganeti
Commits
bbd8efd2
Commit
bbd8efd2
authored
15 years ago
by
Iustin Pop
Browse files
Options
Downloads
Patches
Plain Diff
Some small style fixes
parent
8c9af2f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Ganeti/HTools/Instance.hs
+3
-8
3 additions, 8 deletions
Ganeti/HTools/Instance.hs
Ganeti/HTools/Node.hs
+20
-22
20 additions, 22 deletions
Ganeti/HTools/Node.hs
Ganeti/HTools/PeerMap.hs
+10
-13
10 additions, 13 deletions
Ganeti/HTools/PeerMap.hs
with
33 additions
and
43 deletions
Ganeti/HTools/Instance.hs
+
3
−
8
View file @
bbd8efd2
...
@@ -48,13 +48,11 @@ data Instance = Instance { name :: String -- ^ The instance name
...
@@ -48,13 +48,11 @@ data Instance = Instance { name :: String -- ^ The instance name
,
mem
::
Int
-- ^ Memory of the instance
,
mem
::
Int
-- ^ Memory of the instance
,
dsk
::
Int
-- ^ Disk size of instance
,
dsk
::
Int
-- ^ Disk size of instance
,
vcpus
::
Int
-- ^ Number of VCPUs
,
vcpus
::
Int
-- ^ Number of VCPUs
,
running
::
Bool
-- ^ Whether the instance
,
running
::
Bool
-- ^ Is the instance running?
-- is running
,
runSt
::
String
-- ^ Original (text) run status
,
runSt
::
String
-- ^ Original (text) run status
,
pNode
::
T
.
Ndx
-- ^ Original primary node
,
pNode
::
T
.
Ndx
-- ^ Original primary node
,
sNode
::
T
.
Ndx
-- ^ Original secondary node
,
sNode
::
T
.
Ndx
-- ^ Original secondary node
,
idx
::
T
.
Idx
-- ^ Internal index for
,
idx
::
T
.
Idx
-- ^ Internal index
-- book-keeping
,
util
::
T
.
DynUtil
-- ^ Dynamic resource usage
,
util
::
T
.
DynUtil
-- ^ Dynamic resource usage
}
deriving
(
Show
)
}
deriving
(
Show
)
...
@@ -82,10 +80,7 @@ create name_init mem_init dsk_init vcpus_init run_init pn sn =
...
@@ -82,10 +80,7 @@ create name_init mem_init dsk_init vcpus_init run_init pn sn =
,
mem
=
mem_init
,
mem
=
mem_init
,
dsk
=
dsk_init
,
dsk
=
dsk_init
,
vcpus
=
vcpus_init
,
vcpus
=
vcpus_init
,
running
=
case
run_init
of
,
running
=
run_init
==
"running"
||
run_init
==
"ERROR_up"
"running"
->
True
"ERROR_up"
->
True
_
->
False
,
runSt
=
run_init
,
runSt
=
run_init
,
pNode
=
pn
,
pNode
=
pn
,
sNode
=
sn
,
sNode
=
sn
...
...
This diff is collapsed.
Click to expand it.
Ganeti/HTools/Node.hs
+
20
−
22
View file @
bbd8efd2
...
@@ -67,7 +67,7 @@ import qualified Ganeti.HTools.Types as T
...
@@ -67,7 +67,7 @@ import qualified Ganeti.HTools.Types as T
-- * Type declarations
-- * Type declarations
-- | The node type.
-- | The node type.
data
Node
=
Node
{
name
::
String
-- ^ The node name
data
Node
=
Node
{
name
::
String
-- ^ The node name
,
tMem
::
Double
-- ^ Total memory (MiB)
,
tMem
::
Double
-- ^ Total memory (MiB)
,
nMem
::
Int
-- ^ Node memory (MiB)
,
nMem
::
Int
-- ^ Node memory (MiB)
,
fMem
::
Int
-- ^ Free memory (MiB)
,
fMem
::
Int
-- ^ Free memory (MiB)
...
@@ -80,7 +80,7 @@ data Node = Node { name :: String -- ^ The node name
...
@@ -80,7 +80,7 @@ data Node = Node { name :: String -- ^ The node name
,
sList
::
[
T
.
Idx
]
-- ^ List of secondary instance indices
,
sList
::
[
T
.
Idx
]
-- ^ List of secondary instance indices
,
idx
::
T
.
Ndx
-- ^ Internal index for book-keeping
,
idx
::
T
.
Ndx
-- ^ Internal index for book-keeping
,
peers
::
PeerMap
.
PeerMap
-- ^ Pnode to instance mapping
,
peers
::
PeerMap
.
PeerMap
-- ^ Pnode to instance mapping
,
failN1
::
Bool
-- ^ Whether the node has failed n1
,
failN1
::
Bool
-- ^ Whether the node has failed n1
,
rMem
::
Int
-- ^ Maximum memory needed for
,
rMem
::
Int
-- ^ Maximum memory needed for
-- failover by primaries of this node
-- failover by primaries of this node
,
pMem
::
Double
-- ^ Percent of free memory
,
pMem
::
Double
-- ^ Percent of free memory
...
@@ -235,8 +235,7 @@ setFmem :: Node -> Int -> Node
...
@@ -235,8 +235,7 @@ setFmem :: Node -> Int -> Node
setFmem
t
new_mem
=
setFmem
t
new_mem
=
let
new_n1
=
new_mem
<=
rMem
t
let
new_n1
=
new_mem
<=
rMem
t
new_mp
=
fromIntegral
new_mem
/
tMem
t
new_mp
=
fromIntegral
new_mem
/
tMem
t
in
in
t
{
fMem
=
new_mem
,
failN1
=
new_n1
,
pMem
=
new_mp
}
t
{
fMem
=
new_mem
,
failN1
=
new_n1
,
pMem
=
new_mp
}
-- | Removes a primary instance.
-- | Removes a primary instance.
removePri
::
Node
->
Instance
.
Instance
->
Node
removePri
::
Node
->
Instance
.
Instance
->
Node
...
@@ -251,9 +250,9 @@ removePri t inst =
...
@@ -251,9 +250,9 @@ removePri t inst =
new_ucpu
=
uCpu
t
-
Instance
.
vcpus
inst
new_ucpu
=
uCpu
t
-
Instance
.
vcpus
inst
new_rcpu
=
fromIntegral
new_ucpu
/
tCpu
t
new_rcpu
=
fromIntegral
new_ucpu
/
tCpu
t
new_load
=
utilLoad
t
`
T
.
subUtil
`
Instance
.
util
inst
new_load
=
utilLoad
t
`
T
.
subUtil
`
Instance
.
util
inst
in
t
{
pList
=
new_plist
,
fMem
=
new_mem
,
fDsk
=
new_dsk
,
in
t
{
pList
=
new_plist
,
fMem
=
new_mem
,
fDsk
=
new_dsk
failN1
=
new_failn1
,
pMem
=
new_mp
,
pDsk
=
new_dp
,
,
failN1
=
new_failn1
,
pMem
=
new_mp
,
pDsk
=
new_dp
uCpu
=
new_ucpu
,
pCpu
=
new_rcpu
,
utilLoad
=
new_load
}
,
uCpu
=
new_ucpu
,
pCpu
=
new_rcpu
,
utilLoad
=
new_load
}
-- | Removes a secondary instance.
-- | Removes a secondary instance.
removeSec
::
Node
->
Instance
.
Instance
->
Node
removeSec
::
Node
->
Instance
.
Instance
->
Node
...
@@ -267,19 +266,18 @@ removeSec t inst =
...
@@ -267,19 +266,18 @@ removeSec t inst =
new_peem
=
old_peem
-
Instance
.
mem
inst
new_peem
=
old_peem
-
Instance
.
mem
inst
new_peers
=
PeerMap
.
add
pnode
new_peem
old_peers
new_peers
=
PeerMap
.
add
pnode
new_peem
old_peers
old_rmem
=
rMem
t
old_rmem
=
rMem
t
new_rmem
=
if
old_peem
<
old_rmem
then
new_rmem
=
if
old_peem
<
old_rmem
old_rmem
then
old_rmem
else
else
computeMaxRes
new_peers
computeMaxRes
new_peers
new_prem
=
fromIntegral
new_rmem
/
tMem
t
new_prem
=
fromIntegral
new_rmem
/
tMem
t
new_failn1
=
fMem
t
<=
new_rmem
new_failn1
=
fMem
t
<=
new_rmem
new_dp
=
fromIntegral
new_dsk
/
tDsk
t
new_dp
=
fromIntegral
new_dsk
/
tDsk
t
old_load
=
utilLoad
t
old_load
=
utilLoad
t
new_load
=
old_load
{
T
.
dskWeight
=
T
.
dskWeight
old_load
-
new_load
=
old_load
{
T
.
dskWeight
=
T
.
dskWeight
old_load
-
T
.
dskWeight
(
Instance
.
util
inst
)
}
T
.
dskWeight
(
Instance
.
util
inst
)
}
in
t
{
sList
=
new_slist
,
fDsk
=
new_dsk
,
peers
=
new_peers
,
in
t
{
sList
=
new_slist
,
fDsk
=
new_dsk
,
peers
=
new_peers
failN1
=
new_failn1
,
rMem
=
new_rmem
,
pDsk
=
new_dp
,
,
failN1
=
new_failn1
,
rMem
=
new_rmem
,
pDsk
=
new_dp
pRem
=
new_prem
,
utilLoad
=
new_load
}
,
pRem
=
new_prem
,
utilLoad
=
new_load
}
-- | Adds a primary instance.
-- | Adds a primary instance.
addPri
::
Node
->
Instance
.
Instance
->
T
.
OpResult
Node
addPri
::
Node
->
Instance
.
Instance
->
T
.
OpResult
Node
...
@@ -300,9 +298,9 @@ addPri t inst =
...
@@ -300,9 +298,9 @@ addPri t inst =
else
else
let
new_plist
=
iname
:
pList
t
let
new_plist
=
iname
:
pList
t
new_mp
=
fromIntegral
new_mem
/
tMem
t
new_mp
=
fromIntegral
new_mem
/
tMem
t
r
=
t
{
pList
=
new_plist
,
fMem
=
new_mem
,
fDsk
=
new_dsk
,
r
=
t
{
pList
=
new_plist
,
fMem
=
new_mem
,
fDsk
=
new_dsk
failN1
=
new_failn1
,
pMem
=
new_mp
,
pDsk
=
new_dp
,
,
failN1
=
new_failn1
,
pMem
=
new_mp
,
pDsk
=
new_dp
uCpu
=
new_ucpu
,
pCpu
=
new_pcpu
,
utilLoad
=
new_load
}
,
uCpu
=
new_ucpu
,
pCpu
=
new_pcpu
,
utilLoad
=
new_load
}
in
T
.
OpGood
r
in
T
.
OpGood
r
-- | Adds a secondary instance.
-- | Adds a secondary instance.
...
@@ -324,11 +322,11 @@ addSec t inst pdx =
...
@@ -324,11 +322,11 @@ addSec t inst pdx =
in
if
new_dsk
<=
0
||
mDsk
t
>
new_dp
then
T
.
OpFail
T
.
FailDisk
in
if
new_dsk
<=
0
||
mDsk
t
>
new_dp
then
T
.
OpFail
T
.
FailDisk
else
if
new_failn1
&&
not
(
failN1
t
)
then
T
.
OpFail
T
.
FailMem
else
if
new_failn1
&&
not
(
failN1
t
)
then
T
.
OpFail
T
.
FailMem
else
let
new_slist
=
iname
:
sList
t
else
let
new_slist
=
iname
:
sList
t
r
=
t
{
sList
=
new_slist
,
fDsk
=
new_dsk
,
r
=
t
{
sList
=
new_slist
,
fDsk
=
new_dsk
peers
=
new_peers
,
failN1
=
new_failn1
,
,
peers
=
new_peers
,
failN1
=
new_failn1
rMem
=
new_rmem
,
pDsk
=
new_dp
,
,
rMem
=
new_rmem
,
pDsk
=
new_dp
pRem
=
new_prem
,
utilLoad
=
new_load
}
,
pRem
=
new_prem
,
utilLoad
=
new_load
}
in
T
.
OpGood
r
in
T
.
OpGood
r
-- * Stats functions
-- * Stats functions
...
...
This diff is collapsed.
Click to expand it.
Ganeti/HTools/PeerMap.hs
+
10
−
13
View file @
bbd8efd2
...
@@ -64,20 +64,16 @@ pmCompare a b = (compare `on` snd) b a
...
@@ -64,20 +64,16 @@ pmCompare a b = (compare `on` snd) b a
-- | Add or update (via a custom function) an element.
-- | Add or update (via a custom function) an element.
addWith
::
(
Elem
->
Elem
->
Elem
)
->
Key
->
Elem
->
PeerMap
->
PeerMap
addWith
::
(
Elem
->
Elem
->
Elem
)
->
Key
->
Elem
->
PeerMap
->
PeerMap
addWith
fn
k
v
lst
=
addWith
fn
k
v
lst
=
let
r
=
lookup
k
lst
case
lookup
k
lst
of
in
Nothing
->
insertBy
pmCompare
(
k
,
v
)
lst
case
r
of
Just
o
->
insertBy
pmCompare
(
k
,
fn
o
v
)
(
remove
k
lst
)
Nothing
->
insertBy
pmCompare
(
k
,
v
)
lst
Just
o
->
insertBy
pmCompare
(
k
,
fn
o
v
)
(
remove
k
lst
)
-- | Create a PeerMap from an association list, with possible duplicates
-- | Create a PeerMap from an association list, with possible duplicates
accumArray
::
(
Elem
->
Elem
->
Elem
)
-- ^ function used to merge the elements
accumArray
::
(
Elem
->
Elem
->
Elem
)
-- ^ function used to merge the elements
->
[(
Key
,
Elem
)]
-- ^ source data
->
[(
Key
,
Elem
)]
-- ^ source data
->
PeerMap
-- ^ results
->
PeerMap
-- ^ results
accumArray
fn
lst
=
accumArray
_
[]
=
empty
case
lst
of
accumArray
fn
((
k
,
v
)
:
xs
)
=
addWith
fn
k
v
$
accumArray
fn
xs
[]
->
empty
(
k
,
v
)
:
xs
->
addWith
fn
k
v
$
accumArray
fn
xs
-- * Basic operations
-- * Basic operations
...
@@ -91,9 +87,9 @@ add = addWith (flip const)
...
@@ -91,9 +87,9 @@ add = addWith (flip const)
-- | Remove an element from a peermap
-- | Remove an element from a peermap
remove
::
Key
->
PeerMap
->
PeerMap
remove
::
Key
->
PeerMap
->
PeerMap
remove
k
c
=
case
c
of
remove
_
[]
=
[]
[]
->
[]
remove
k
((
x
@
(
x'
,
_
))
:
xs
)
=
if
k
==
x'
(
x
@
(
x'
,
_
))
:
xs
->
if
k
==
x'
then
xs
then
xs
else
x
:
remove
k
xs
else
x
:
remove
k
xs
-- | Find the maximum element.
-- | Find the maximum element.
...
@@ -101,4 +97,5 @@ remove k c = case c of
...
@@ -101,4 +97,5 @@ remove k c = case c of
-- Since this is a sorted list, we just get the value at the head of
-- Since this is a sorted list, we just get the value at the head of
-- the list, or zero for a null list
-- the list, or zero for a null list
maxElem
::
PeerMap
->
Elem
maxElem
::
PeerMap
->
Elem
maxElem
c
=
if
null
c
then
0
else
snd
.
head
$
c
maxElem
(
x
:
_
)
=
snd
x
maxElem
_
=
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment