blob: 80e646320a8804a04c641440f4b584b51ae6ae52 [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
Matt Jeanneret2e3cb8d2019-11-16 09:22:41 -050016from __future__ import absolute_import
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 """
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050046 super(BrcmCapabilitiesTask, self).__init__(omci_agent, device_id)
47 self._omci_managed = False # TODO: Look up capabilities/model number
48
49 @property
50 def supported_managed_entities(self):
51 """
52 Return a set of the Managed Entity class IDs supported on this ONU
53
54 None is returned if not MEs have been discovered
55
56 :return: (set of ints)
57 """
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050058
59 if self._omci_managed:
60 return super(BrcmCapabilitiesTask, self).supported_managed_entities
61
62 # TODO: figure out why broadcom wont answer for ME 287 to get this. otherwise manually fill in
63 me_1287800f1 = [
64 2, 5, 6, 7, 11, 24, 45, 46, 47, 48, 49, 50, 51, 52, 78, 79, 84, 89, 130,
65 131, 133, 134, 135, 136, 137, 148, 157, 158, 159, 162, 163, 164, 171, 240,
66 241, 242, 256, 257, 262, 263, 264, 266, 268, 272, 273, 274, 276, 277, 278,
67 279, 280, 281, 287, 296, 297, 298, 307, 308, 309, 310, 311, 312, 321, 322,
68 329, 330, 332, 334, 336, 340, 341, 342, 343, 347, 348, 425, 426
69 ]
70 return frozenset(list(me_1287800f1))
71
72 @property
73 def supported_message_types(self):
74 """
75 Return a set of the Message Types supported on this ONU
76
77 None is returned if no message types have been discovered
78
79 :return: (set of EntityOperations)
80 """
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050081
82 if self._omci_managed:
83 return super(BrcmCapabilitiesTask, self).supported_message_types
84
85 # TODO: figure out why broadcom wont answer for ME 287 to get this. otherwise manually fill in
Matt Jeanneret72f96fc2019-02-11 10:53:05 -050086 from pyvoltha.adapters.extensions.omci.omci_entities import EntityOperations
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -050087 op_11287800f1 = [
88 EntityOperations.Create,
89 EntityOperations.CreateComplete,
90 EntityOperations.Delete,
91 EntityOperations.Set,
92 EntityOperations.Get,
93 EntityOperations.GetComplete,
94 EntityOperations.GetAllAlarms,
95 EntityOperations.GetAllAlarmsNext,
96 EntityOperations.MibUpload,
97 EntityOperations.MibUploadNext,
98 EntityOperations.MibReset,
99 EntityOperations.AlarmNotification,
100 EntityOperations.AttributeValueChange,
101 EntityOperations.Test,
102 EntityOperations.StartSoftwareDownload,
103 EntityOperations.DownloadSection,
104 EntityOperations.EndSoftwareDownload,
105 EntityOperations.ActivateSoftware,
106 EntityOperations.CommitSoftware,
107 EntityOperations.SynchronizeTime,
108 EntityOperations.Reboot,
109 EntityOperations.GetNext,
110 ]
111 return frozenset(op_11287800f1)
112
113 def perform_get_capabilities(self):
114 """
115 Perform the MIB Capabilities sequence.
116
117 The sequence is to perform a Get request with the attribute mask equal
118 to 'me_type_table'. The response to this request will carry the size
119 of (number of get-next sequences).
120
121 Then a loop is entered and get-next commands are sent for each sequence
122 requested.
123 """
Matt Jeanneretf1e9c5d2019-02-08 07:41:29 -0500124
125 self.log.info('perform-get')
126
127 if self._omci_managed:
128 # Return generator deferred/results
129 return super(BrcmCapabilitiesTask, self).perform_get_capabilities()
130
131 # Fixed values, no need to query
132 try:
133 self._supported_entities = self.supported_managed_entities
134 self._supported_msg_types = self.supported_message_types
135
136 self.log.debug('get-success',
137 supported_entities=self.supported_managed_entities,
138 supported_msg_types=self.supported_message_types)
139 results = {
140 'supported-managed-entities': self.supported_managed_entities,
141 'supported-message-types': self.supported_message_types
142 }
143 self.deferred.callback(results)
144
145 except Exception as e:
146 self.log.exception('get-failed', e=e)
147 self.deferred.errback(failure.Failure(e))
148
149