blob: d56a1d06e338b449352c8900d4ca4605c475ace0 [file] [log] [blame]
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -05001#
2# Copyright 2018 the original author or authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import structlog
Matt Jeanneret72f96fc2019-02-11 10:53:05 -050017from pyvoltha.adapters.extensions.omci.tasks.onu_capabilities_task import OnuCapabilitiesTask
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050018from twisted.internet.defer import failure
19
20
21class BrcmCapabilitiesTask(OnuCapabilitiesTask):
22 """
23 OpenOMCI MIB Capabilities Task - BROADCOM ONUs
24
25 This task requests information on supported MEs via the OMCI (ME#287)
26 Managed entity.
27
28 This task should be ran after MIB Synchronization and before any MIB
29 Downloads to the ONU.
30
31 Upon completion, the Task deferred callback is invoked with dictionary
32 containing the supported managed entities and message types.
33
34 results = {
35 'supported-managed-entities': {set of supported managed entities},
36 'supported-message-types': {set of supported message types}
37 }
38 """
39 def __init__(self, omci_agent, device_id):
40 """
41 Class initialization
42
43 :param omci_agent: (OmciAdapterAgent) OMCI Adapter agent
44 :param device_id: (str) ONU Device ID
45 """
46 self.log = structlog.get_logger(device_id=device_id)
47 self.log.debug('function-entry')
48
49 super(BrcmCapabilitiesTask, self).__init__(omci_agent, device_id)
50 self._omci_managed = False # TODO: Look up capabilities/model number
51
52 @property
53 def supported_managed_entities(self):
54 """
55 Return a set of the Managed Entity class IDs supported on this ONU
56
57 None is returned if not MEs have been discovered
58
59 :return: (set of ints)
60 """
61 self.log.debug('function-entry')
62
63 if self._omci_managed:
64 return super(BrcmCapabilitiesTask, self).supported_managed_entities
65
66 # TODO: figure out why broadcom wont answer for ME 287 to get this. otherwise manually fill in
67 me_1287800f1 = [
68 2, 5, 6, 7, 11, 24, 45, 46, 47, 48, 49, 50, 51, 52, 78, 79, 84, 89, 130,
69 131, 133, 134, 135, 136, 137, 148, 157, 158, 159, 162, 163, 164, 171, 240,
70 241, 242, 256, 257, 262, 263, 264, 266, 268, 272, 273, 274, 276, 277, 278,
71 279, 280, 281, 287, 296, 297, 298, 307, 308, 309, 310, 311, 312, 321, 322,
72 329, 330, 332, 334, 336, 340, 341, 342, 343, 347, 348, 425, 426
73 ]
74 return frozenset(list(me_1287800f1))
75
76 @property
77 def supported_message_types(self):
78 """
79 Return a set of the Message Types supported on this ONU
80
81 None is returned if no message types have been discovered
82
83 :return: (set of EntityOperations)
84 """
85 self.log.debug('function-entry')
86
87 if self._omci_managed:
88 return super(BrcmCapabilitiesTask, self).supported_message_types
89
90 # TODO: figure out why broadcom wont answer for ME 287 to get this. otherwise manually fill in
Matt Jeanneret72f96fc2019-02-11 10:53:05 -050091 from pyvoltha.adapters.extensions.omci.omci_entities import EntityOperations
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050092 op_11287800f1 = [
93 EntityOperations.Create,
94 EntityOperations.CreateComplete,
95 EntityOperations.Delete,
96 EntityOperations.Set,
97 EntityOperations.Get,
98 EntityOperations.GetComplete,
99 EntityOperations.GetAllAlarms,
100 EntityOperations.GetAllAlarmsNext,
101 EntityOperations.MibUpload,
102 EntityOperations.MibUploadNext,
103 EntityOperations.MibReset,
104 EntityOperations.AlarmNotification,
105 EntityOperations.AttributeValueChange,
106 EntityOperations.Test,
107 EntityOperations.StartSoftwareDownload,
108 EntityOperations.DownloadSection,
109 EntityOperations.EndSoftwareDownload,
110 EntityOperations.ActivateSoftware,
111 EntityOperations.CommitSoftware,
112 EntityOperations.SynchronizeTime,
113 EntityOperations.Reboot,
114 EntityOperations.GetNext,
115 ]
116 return frozenset(op_11287800f1)
117
118 def perform_get_capabilities(self):
119 """
120 Perform the MIB Capabilities sequence.
121
122 The sequence is to perform a Get request with the attribute mask equal
123 to 'me_type_table'. The response to this request will carry the size
124 of (number of get-next sequences).
125
126 Then a loop is entered and get-next commands are sent for each sequence
127 requested.
128 """
129 self.log.debug('function-entry')
130
131 self.log.info('perform-get')
132
133 if self._omci_managed:
134 # Return generator deferred/results
135 return super(BrcmCapabilitiesTask, self).perform_get_capabilities()
136
137 # Fixed values, no need to query
138 try:
139 self._supported_entities = self.supported_managed_entities
140 self._supported_msg_types = self.supported_message_types
141
142 self.log.debug('get-success',
143 supported_entities=self.supported_managed_entities,
144 supported_msg_types=self.supported_message_types)
145 results = {
146 'supported-managed-entities': self.supported_managed_entities,
147 'supported-message-types': self.supported_message_types
148 }
149 self.deferred.callback(results)
150
151 except Exception as e:
152 self.log.exception('get-failed', e=e)
153 self.deferred.errback(failure.Failure(e))
154
155