blob: 27efb8ff833cca9a2a76135cc656c3f393d06a51 [file] [log] [blame]
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -07001/*
2 * Copyright (c) 2018 - present. Boling Consulting Solutions (bcsw.net)
Matteo Scandolof9d43412021-01-12 11:11:34 -08003 * Copyright 2020-present Open Networking Foundation
4
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -07005 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
Matteo Scandolof9d43412021-01-12 11:11:34 -08008
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -07009 * http://www.apache.org/licenses/LICENSE-2.0
Matteo Scandolof9d43412021-01-12 11:11:34 -080010
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070011 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
Matteo Scandolof9d43412021-01-12 11:11:34 -080017
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070018package generated
19
20import "github.com/deckarep/golang-set"
21
Matteo Scandolof9d43412021-01-12 11:11:34 -080022// SoftwareImageClassID is the 16-bit ID for the OMCI
23// Managed entity Software image
24const SoftwareImageClassID ClassID = ClassID(7)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070025
26var softwareimageBME *ManagedEntityDefinition
27
28// SoftwareImage (class ID #7)
29// This ME models an executable software image stored in the ONU (documented here as its
30// fundamental usage). It may also be used to represent an opaque vendor-specific file
31// (vendorspecific usage).
32//
33// Fundamental usage
34//
35// The ONU automatically creates two instances of this ME upon the creation of each ME that
36// contains independently manageable software, either the ONU itself or an individual circuit pack.
37// It populates ME attributes according to data within the ONU or the circuit pack.
38//
39// Some pluggable equipment may not contain software. Others may contain software that is
40// intrinsically bound to the ONU's own software image. No software image ME need exist for such
41// equipment, though it may be convenient for the ONU to create them to support software version
42// audit from the OLT. In this case, the dependent MEs would support only the get action.
43//
44// A slot may contain various equipment over its lifetime, and if software image MEs exist, the ONU
45// must automatically create and delete them as the equipped configuration changes. The identity of
46// the software image is tied to the cardholder.
47//
48// When an ONU controller packs are duplicated, each can be expected to contain two software image
49// MEs, managed through reference to the individual controller packs themselves. When this occurs,
50// the ONU should not have a global pair of software images MEs (instance 0), since an action
51// (download, activate, commit) directed to instance 0 would be ambiguous.
52//
53// Relationships
54// Two instances of the software image ME are associated with each instance of the ONU or
55// cardholder whose software is independently managed.
56//
57// Attributes
58// Managed Entity Id
59// Managed entity ID: This attribute uniquely identifies each instance of this ME. The first byte
60// indicates the physical location of the equipment hosting the software image, either the ONU (0)
61// or a cardholder (1..254). The second byte distinguishes between the two software image ME
Matteo Scandolof9d43412021-01-12 11:11:34 -080062// instances (0..1). (R) (mandatory) (2-bytes)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070063//
64// Version
65// Version: This string attribute identifies the version of the software. (R) (mandatory)
Matteo Scandolof9d43412021-01-12 11:11:34 -080066// (14-bytes)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070067//
68// Is Committed
69// Is committed: This attribute indicates whether the associated software image is committed (1) or
70// uncommitted (0). By definition, the committed software image is loaded and executed upon reboot
71// of the ONU or circuit pack. During normal operation, one software image is always committed,
72// while the other is uncommitted. Under no circumstances are both software images allowed to be
73// committed at the same time. On the other hand, both software images could be uncommitted at the
74// same time if both were invalid. Upon ME instantiation, instance 0 is initialized to committed,
75// while instance 1 is initialized to uncommitted (i.e., the ONU ships from the factory with image
Matteo Scandolof9d43412021-01-12 11:11:34 -080076// 0 committed). (R) (mandatory) (1-byte)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070077//
78// Is Active
79// Is active: This attribute indicates whether the associated software image is active (1) or
80// inactive (0). By definition, the active software image is one that is currently loaded and
81// executing in the ONU or circuit pack. Under normal operation, one software image is always
82// active while the other is inactive. Under no circumstances are both software images allowed to
83// be active at the same time. On the other hand, both software images could be inactive at the
Matteo Scandolof9d43412021-01-12 11:11:34 -080084// same time if both were invalid. (R) (mandatory) (1-byte)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070085//
86// Is Valid
87// Is valid: This attribute indicates whether the associated software image is valid (1) or invalid
88// (0). By definition, a software image is valid if it has been verified to be an executable code
89// image. The verification mechanism is not subject to standardization; however, it should include
90// at least a data integrity check [e.g., a cyclic redundancy check (CRC)] of the entire code
91// image. Upon ME instantiation or software download completion, the ONU validates the associated
Matteo Scandolof9d43412021-01-12 11:11:34 -080092// code image and sets this attribute according to the result. (R) (mandatory) (1-byte)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -070093//
94// Product Code
95// Product code: This attribute provides a way for a vendor to indicate product code information on
96// a file. It is a character string, padded with trailing nulls if it is shorter than 25 bytes. (R)
97// (optional) (25 bytes)
98//
99// Image Hash
100// Image hash: This attribute is an MD5 hash of the software image. It is computed at completion of
Matteo Scandolof9d43412021-01-12 11:11:34 -0800101// the end download action. (R) (optional) (16-bytes)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700102//
103type SoftwareImage struct {
104 ManagedEntityDefinition
105 Attributes AttributeValueMap
106}
107
108func init() {
109 softwareimageBME = &ManagedEntityDefinition{
110 Name: "SoftwareImage",
111 ClassID: 7,
112 MessageTypes: mapset.NewSetWith(
113 ActivateSoftware,
114 CommitSoftware,
115 DownloadSection,
116 EndSoftwareDownload,
117 Get,
118 StartSoftwareDownload,
119 ),
Matteo Scandolof9d43412021-01-12 11:11:34 -0800120 AllowedAttributeMask: 0xfc00,
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700121 AttributeDefinitions: AttributeDefinitionMap{
Matteo Scandolof9d43412021-01-12 11:11:34 -0800122 0: Uint16Field("ManagedEntityId", PointerAttributeType, 0x0000, 0, mapset.NewSetWith(Read), false, false, false, 0),
123 1: MultiByteField("Version", StringAttributeType, 0x8000, 14, toOctets("ICAgICAgICAgICAgICA="), mapset.NewSetWith(Read), true, false, false, 1),
124 2: ByteField("IsCommitted", EnumerationAttributeType, 0x4000, 0, mapset.NewSetWith(Read), true, false, false, 2),
125 3: ByteField("IsActive", EnumerationAttributeType, 0x2000, 0, mapset.NewSetWith(Read), true, false, false, 3),
126 4: ByteField("IsValid", EnumerationAttributeType, 0x1000, 0, mapset.NewSetWith(Read), true, false, false, 4),
127 5: MultiByteField("ProductCode", OctetsAttributeType, 0x0800, 25, toOctets("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="), mapset.NewSetWith(Read), true, true, false, 5),
128 6: MultiByteField("ImageHash", StringAttributeType, 0x0400, 16, toOctets("AAAAAAAAAAAAAAAAAAAAAA=="), mapset.NewSetWith(Read), true, true, false, 6),
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700129 },
Matteo Scandolof9d43412021-01-12 11:11:34 -0800130 Access: CreatedByOnu,
131 Support: UnknownSupport,
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700132 }
133}
134
Matteo Scandolof9d43412021-01-12 11:11:34 -0800135// NewSoftwareImage (class ID 7) creates the basic
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700136// Managed Entity definition that is used to validate an ME of this type that
Matteo Scandolof9d43412021-01-12 11:11:34 -0800137// is received from or transmitted to the OMCC.
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700138func NewSoftwareImage(params ...ParamData) (*ManagedEntity, OmciErrors) {
Matteo Scandolof9d43412021-01-12 11:11:34 -0800139 return NewManagedEntity(*softwareimageBME, params...)
Matteo Scandoloa6a3aee2019-11-26 13:30:14 -0700140}