File: sdr.py

package info (click to toggle)
python-ipmi 0.5.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,132 kB
  • sloc: python: 12,645; makefile: 2
file content (221 lines) | stat: -rw-r--r-- 6,623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright (c) 2014  Kontron Europe GmbH
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA

from . import constants
from . import register_message_class
from . import Message
from . import ByteArray
from . import UnsignedInt
from . import Timestamp
from . import Bitfield
from . import CompletionCode
from . import RemainingBytes


@register_message_class
class GetSdrRepositoryInfoReq(Message):
    __cmdid__ = constants.CMDID_GET_SDR_REPOSITORY_INFO
    __netfn__ = constants.NETFN_STORAGE


@register_message_class
class GetSdrRepositoryInfoRsp(Message):
    __cmdid__ = constants.CMDID_GET_SDR_REPOSITORY_INFO
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('sdr_version', 1),
            UnsignedInt('record_count', 2),
            UnsignedInt('free_space', 2),
            Timestamp('most_recent_addition'),
            Timestamp('most_recent_erase'),
            Bitfield('support', 1,
                     Bitfield.Bit('get_allocation_info', 1),
                     Bitfield.Bit('reserve', 1),
                     Bitfield.Bit('partial_add', 1),
                     Bitfield.Bit('delete', 1),
                     Bitfield.ReservedBit(1, 0),
                     Bitfield.Bit('update_type', 2),
                     Bitfield.Bit('overflow_flag', 1)),
    )


@register_message_class
class GetSdrRepositoryAllocationInfoReq(Message):
    __cmdid__ = constants.CMDID_GET_SDR_REPOSITORY_ALLOCATION_INFO
    __netfn__ = constants.NETFN_STORAGE


@register_message_class
class GetSdrRepositoryAllocationInfoRsp(Message):
    __cmdid__ = constants.CMDID_GET_SDR_REPOSITORY_ALLOCATION_INFO
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('number_of_units', 2),
            UnsignedInt('unit_size', 2),
            UnsignedInt('free_units', 2),
            UnsignedInt('largest_free_block', 2),
            UnsignedInt('maximum_record_size', 1)
    )


@register_message_class
class ReserveSdrRepositoryReq(Message):
    __cmdid__ = constants.CMDID_RESERVE_SDR_REPOSITORY
    __netfn__ = constants.NETFN_STORAGE


@register_message_class
class ReserveSdrRepositoryRsp(Message):
    __cmdid__ = constants.CMDID_RESERVE_SDR_REPOSITORY
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('reservation_id', 2),
    )


@register_message_class
class GetSdrReq(Message):
    __cmdid__ = constants.CMDID_GET_SDR
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            UnsignedInt('reservation_id', 2),
            UnsignedInt('record_id', 2),
            UnsignedInt('offset', 1),
            UnsignedInt('bytes_to_read', 1),
    )


@register_message_class
class GetSdrRsp(Message):
    __cmdid__ = constants.CMDID_GET_SDR
    __netfn__ = constants.NETFN_STORAGE | 1

    __fields__ = (
            CompletionCode(),
            UnsignedInt('next_record_id', 2),
            RemainingBytes('record_data'),
    )


@register_message_class
class AddSdrReq(Message):
    __cmdid__ = constants.CMDID_ADD_SDR
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            RemainingBytes('record_data'),
    )


@register_message_class
class AddSdrRsp(Message):
    __cmdid__ = constants.CMDID_ADD_SDR
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('record_id', 2),
    )


@register_message_class
class PartialAddSdrReq(Message):
    __cmdid__ = constants.CMDID_PARTIAL_ADD_SDR
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            UnsignedInt('reservation_id', 2),
            UnsignedInt('record_id', 2),
            UnsignedInt('offset', 1),
            Bitfield('status', 1,
                     Bitfield.Bit('in_progress', 4),
                     Bitfield.ReservedBit(4, 0),),
            RemainingBytes('record_data'),
    )


@register_message_class
class PartialAddSdrRsp(Message):
    __cmdid__ = constants.CMDID_PARTIAL_ADD_SDR
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('record_id', 2),
    )


@register_message_class
class DeleteSdrReq(Message):
    __cmdid__ = constants.CMDID_DELETE_SDR
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            UnsignedInt('reservation_id', 2),
            UnsignedInt('record_id', 2),
    )


@register_message_class
class DeleteSdrRsp(Message):
    __cmdid__ = constants.CMDID_DELETE_SDR
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            UnsignedInt('record_id', 2),
    )


@register_message_class
class ClearSdrRepositoryReq(Message):
    __cmdid__ = constants.CMDID_CLEAR_SDR_REPOSITORY
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            UnsignedInt('reservation_id', 2),
            ByteArray('key', 3, default=b'CLR'),
            UnsignedInt('cmd', 1)
    )


@register_message_class
class ClearSdrRepositoryRsp(Message):
    __cmdid__ = constants.CMDID_CLEAR_SDR_REPOSITORY
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            Bitfield('status', 1,
                     Bitfield.Bit('erase_in_progress', 4),
                     Bitfield.ReservedBit(4, 0),),
    )


@register_message_class
class RunInitializationAgentReq(Message):
    __cmdid__ = constants.CMDID_RUN_INITIALIZATION_AGENT
    __netfn__ = constants.NETFN_STORAGE
    __fields__ = (
            UnsignedInt('cmd', 1),
    )


@register_message_class
class RunInitializationAgentRsp(Message):
    __cmdid__ = constants.CMDID_RUN_INITIALIZATION_AGENT
    __netfn__ = constants.NETFN_STORAGE | 1
    __fields__ = (
            CompletionCode(),
            Bitfield('status', 1,
                     Bitfield.Bit('initialization_completed', 1),
                     Bitfield.ReservedBit(7, 0),),
    )