Document the decission why optimisation is turned off
[ganeti-github.git] / src / Ganeti / Objects / Instance.hs
1 {-# LANGUAGE TemplateHaskell, FunctionalDependencies #-}
2 {-# OPTIONS_GHC -O0 #-}
3 -- We have to disable optimisation here, as some versions of ghc otherwise
4 -- fail to compile this code, at least within reasonable memory limits (40g).
5
6 {-| Implementation of the Ganeti Instance config object.
7
8 -}
9
10 {-
11
12 Copyright (C) 2014 Google Inc.
13 All rights reserved.
14
15 Redistribution and use in source and binary forms, with or without
16 modification, are permitted provided that the following conditions are
17 met:
18
19 1. Redistributions of source code must retain the above copyright notice,
20 this list of conditions and the following disclaimer.
21
22 2. Redistributions in binary form must reproduce the above copyright
23 notice, this list of conditions and the following disclaimer in the
24 documentation and/or other materials provided with the distribution.
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
27 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
30 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
38 -}
39
40 module Ganeti.Objects.Instance where
41
42 import qualified Data.ByteString.UTF8 as UTF8
43 import Data.Monoid
44
45 import Ganeti.JSON (emptyContainer)
46 import Ganeti.Objects.Nic
47 import Ganeti.THH
48 import Ganeti.THH.Field
49 import Ganeti.Types
50 import Ganeti.Utils (parseUnitAssumeBinary)
51
52 $(buildParam "Be" "bep"
53 [ specialNumericalField 'parseUnitAssumeBinary
54 $ simpleField "minmem" [t| Int |]
55 , specialNumericalField 'parseUnitAssumeBinary
56 $ simpleField "maxmem" [t| Int |]
57 , simpleField "vcpus" [t| Int |]
58 , simpleField "auto_balance" [t| Bool |]
59 , simpleField "always_failover" [t| Bool |]
60 , simpleField "spindle_use" [t| Int |]
61 ])
62
63 $(buildObjectWithForthcoming "Instance" "inst" $
64 [ simpleField "name" [t| String |]
65 , simpleField "primary_node" [t| String |]
66 , simpleField "os" [t| String |]
67 , simpleField "hypervisor" [t| Hypervisor |]
68 , defaultField [| emptyContainer |]
69 $ simpleField "hvparams" [t| HvParams |]
70 , defaultField [| mempty |]
71 $ simpleField "beparams" [t| PartialBeParams |]
72 , defaultField [| emptyContainer |]
73 $ simpleField "osparams" [t| OsParams |]
74 , defaultField [| emptyContainer |]
75 $ simpleField "osparams_private" [t| OsParamsPrivate |]
76 , simpleField "admin_state" [t| AdminState |]
77 , simpleField "admin_state_source" [t| AdminStateSource |]
78 , defaultField [| [] |]
79 $ simpleField "nics" [t| [PartialNic] |]
80 , defaultField [| [] |]
81 $ simpleField "disks" [t| [String] |]
82 , simpleField "disks_active" [t| Bool |]
83 , optionalField $ simpleField "network_port" [t| Int |]
84 ]
85 ++ timeStampFields
86 ++ uuidFields
87 ++ serialFields
88 ++ tagsFields)
89
90 instance TimeStampObject Instance where
91 cTimeOf = instCtime
92 mTimeOf = instMtime
93
94 instance UuidObject Instance where
95 uuidOf = UTF8.toString . instUuid
96
97 instance SerialNoObject Instance where
98 serialOf = instSerial
99
100 instance TagsObject Instance where
101 tagsOf = instTags
102
103 instance ForthcomingObject Instance where
104 isForthcoming = instForthcoming