blob: 6dbed035a415c7925ab58c7c9b690f89ea293882 [file] [log] [blame]
Chip Boling8e042f62019-02-12 16:14:34 -06001#
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#
16from voltha.extensions.omci.tasks.onu_capabilities_task import OnuCapabilitiesTask
17from twisted.internet.defer import failure
18
19
20class AdtnCapabilitiesTask(OnuCapabilitiesTask):
21 """
22 OpenOMCI MIB Capabilities Task - ADTRAN ONUs
23
24 This task requests information on supported MEs via the OMCI (ME#287)
25 Managed entity.
26
27 This task should be ran after MIB Synchronization and before any MIB
28 Downloads to the ONU.
29
30 Upon completion, the Task deferred callback is invoked with dictionary
31 containing the supported managed entities and message types.
32
33 results = {
34 'supported-managed-entities': {set of supported managed entities},
35 'supported-message-types': {set of supported message types}
36 }
37 """
38 name = "Adtran ONU Capabilities Task"
39
40 def __init__(self, omci_agent, device_id):
41 """
42 Class initialization
43
44 :param omci_agent: (OpenOMCIAgent) OMCI Adapter agent
45 :param device_id: (str) ONU Device ID
46 """
47 super(AdtnCapabilitiesTask, self).__init__(omci_agent, device_id)
48
49 self.name = AdtnCapabilitiesTask.name
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 if self._omci_managed:
62 return super(AdtnCapabilitiesTask, self).supported_managed_entities
63
64 me_1287800f1 = [
65 2, 5, 6, 7, 11, 24, 45, 46, 47, 48, 49, 50, 51, 52, 79, 84, 89, 130,
66 131, 133, 134, 135, 136, 137, 148, 157, 158, 159, 171, 256, 257, 262,
67 263, 264, 266, 268, 272, 273, 274, 277, 278, 279, 280, 281, 297, 298,
68 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312,
69 329, 330, 332, 334, 336, 340, 341, 342, 343, 348, 425, 426, 65300,
70 65400, 65401, 65402, 65403, 65404, 65406, 65407, 65408, 65409, 65410,
71 65411, 65412, 65413, 65414, 65420, 65421, 65422, 65423, 65424
72 ]
73 return frozenset(list(me_1287800f1))
74
75 @property
76 def supported_message_types(self):
77 """
78 Return a set of the Message Types supported on this ONU
79
80 None is returned if no message types have been discovered
81
82 :return: (set of EntityOperations)
83 """
84 if self._omci_managed:
85 return super(AdtnCapabilitiesTask, self).supported_message_types
86
87 from voltha.extensions.omci.omci_entities import EntityOperations
88 op_11287800f1 = [
89 EntityOperations.Create,
90 EntityOperations.CreateComplete,
91 EntityOperations.Delete,
92 EntityOperations.Set,
93 EntityOperations.Get,
94 EntityOperations.GetComplete,
95 EntityOperations.GetAllAlarms,
96 EntityOperations.GetAllAlarmsNext,
97 EntityOperations.MibUpload,
98 EntityOperations.MibUploadNext,
99 EntityOperations.MibReset,
100 EntityOperations.AlarmNotification,
101 EntityOperations.AttributeValueChange,
102 EntityOperations.Test,
103 EntityOperations.StartSoftwareDownload,
104 EntityOperations.DownloadSection,
105 EntityOperations.EndSoftwareDownload,
106 EntityOperations.ActivateSoftware,
107 EntityOperations.CommitSoftware,
108 EntityOperations.SynchronizeTime,
109 EntityOperations.Reboot,
110 EntityOperations.GetNext,
111 ]
112 return frozenset(op_11287800f1)
113
114 def perform_get_capabilities(self):
115 """
116 Perform the MIB Capabilities sequence.
117
118 The sequence is to perform a Get request with the attribute mask equal
119 to 'me_type_table'. The response to this request will carry the size
120 of (number of get-next sequences).
121
122 Then a loop is entered and get-next commands are sent for each sequence
123 requested.
124 """
125 self.log.info('perform-get')
126
127 if self._omci_managed:
128 # Return generator deferred/results
129 return super(AdtnCapabilitiesTask, 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))