Encode UUIDs as ByteStrings
[ganeti-github.git] / src / Ganeti / Objects / Nic.hs
1 {-# LANGUAGE TemplateHaskell, FunctionalDependencies #-}
2
3 {-| Implementation of the Ganeti Instance config object.
4
5 -}
6
7 {-
8
9 Copyright (C) 2014 Google Inc.
10 All rights reserved.
11
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are
14 met:
15
16 1. Redistributions of source code must retain the above copyright notice,
17 this list of conditions and the following disclaimer.
18
19 2. Redistributions in binary form must reproduce the above copyright
20 notice, this list of conditions and the following disclaimer in the
21 documentation and/or other materials provided with the distribution.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35 -}
36
37 module Ganeti.Objects.Nic where
38
39 import qualified Data.ByteString.UTF8 as UTF8
40
41 import Ganeti.THH
42 import Ganeti.THH.Field
43 import Ganeti.Types
44
45 $(buildParam "Nic" "nicp"
46 [ simpleField "mode" [t| NICMode |]
47 , simpleField "link" [t| String |]
48 , simpleField "vlan" [t| String |]
49 ])
50
51 $(buildObject "PartialNic" "nic" $
52 [ simpleField "mac" [t| String |]
53 , optionalField $ simpleField "ip" [t| String |]
54 , simpleField "nicparams" [t| PartialNicParams |]
55 , optionalField $ simpleField "network" [t| String |]
56 , optionalField $ simpleField "name" [t| String |]
57 ] ++ uuidFields)
58
59 instance UuidObject PartialNic where
60 uuidOf = UTF8.toString . nicUuid
61
62