1 21 package ist.coach.coachEmsMibComponents.IpProtocolMonitorFactoryProviderComposition; 22 23 import ist.coach.coachEmfCommon.Utils; 24 import ist.coach.coachEmfCommon.CreateController; 25 import ist.coach.coachEmfCommon.CreateBindingInfo; 26 import ist.coach.coachEmfCommon.ExceptionMessages; 27 import ist.coach.coachEmfCommon.CreateErrorInfoTypeImpl; 28 import ist.coach.coachEmfCommon.ApplicationErrorInfoTypeImpl; 29 30 import ist.coach.coachEmsCommon.SnmpUtils; 31 import org.opennms.protocols.snmp.SnmpSMI; 32 import ist.coach.coachEmfServices.SnmpAdapter.DataType; 33 import ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError; 34 import ist.coach.coachEmsCommon.SnmpIdentifiers; 35 36 import intt.itu.itut_x780.UIDType; 37 import intt.itu.itut_x780.CreateError; 38 import intt.itu.itut_x780.ApplicationError; 39 import ist.coach.coachEmsMib.IpRoutingEntryFactory; 40 import ist.coach.coachEmsMib.IpToMACAddressFactory; 41 42 import intt.itu.itut_m3120.conditionalPackages.*; 43 import ist.coach.coachEmfServices.EmfBasicLog.*; 44 45 import org.omg.CosNaming.NameComponent ; 46 import ist.coach.coachEmsMibComponents.IpProtocolMonitorMgmt; 47 50 public class IpProtocolMonitorFactoryProviderImpl 51 extends ist.coach.coachEmsMibComponents.IpProtocolMonitorFactoryProviderComposition.IpProtocolMonitorFactoryProvider_impl 52 { 53 61 62 63 intt.itu.itut_q816.ContainmentComponent c_admin = null; 64 intt.itu.itut_q816.Containment c_query = null; 65 66 private static final String FACTORY_CLASS = "LogicalInterfaceFactory"; 67 IpProtocolMonitorMgmt facade = null; 68 private BasicLog logSupport; 69 ist.coach.coachEmfServices.SnmpAdapter.SnmpConnector connector = null; 70 71 72 80 public 81 IpProtocolMonitorFactoryProviderImpl() 82 {} 83 94 108 public void 109 configuration_complete() 110 throws org.omg.Components.InvalidConfiguration 111 { 112 116 if ((facade = get_context().get_connection_facade()) == null) 117 throw new org.omg.Components.InvalidConfiguration(); 118 119 if ((c_admin = get_context().get_connection_containment_admin()) == null) 120 throw new org.omg.Components.InvalidConfiguration(); 121 122 if ((c_query = get_context().get_connection_containment_query()) == null) 123 throw new org.omg.Components.InvalidConfiguration(); 124 125 if ((connector = get_context().get_connection_connector()) == null) 126 throw new org.omg.Components.InvalidConfiguration(); 127 128 if ((logSupport = get_context().get_connection_basic_log()) == null) 129 throw new org.omg.Components.InvalidConfiguration(); 130 131 System.err.println("IpProtocolMonitorFactoryProviderconfiguration completed..."); 132 133 134 } 135 136 147 public org.omg.CosNaming.NameComponent [] 148 create(java.lang.String nameBindingID, 149 org.omg.CosNaming.NameComponent [] superior, 150 String reqID, 151 String [] packageNameList, 152 byte[] mgmtIpAddress, 153 int snmpPort, 154 int supportedSnmpVersions 155 ) 156 throws intt.itu.itut_x780.ApplicationError, intt.itu.itut_x780.CreateError 157 { 158 162 String nameBinding_str = "ist.coach.coachEmsMib.NameBindings." + 163 nameBindingID; 164 165 CreateBindingInfo info = CreateController.checkNameBinding(nameBinding_str); 166 167 String objectKind = info.objectKind; 168 short deletePolicy = info.deletePolicy; 169 170 if (! c_query.exists(superior)) { 172 ApplicationErrorInfoTypeImpl error_code = 173 new ApplicationErrorInfoTypeImpl(); 174 error_code.error = new UIDType( 175 intt.itu.itut_x780.ApplicationErrorConst.moduleName.value, 176 intt.itu.itut_x780.ApplicationErrorConst.objectNotFound.value); 177 178 179 error_code.details = Utils.name2string(superior) + 180 ExceptionMessages.parent_object_error; 181 182 throw new ApplicationError(error_code); 183 } 184 185 187 String allocatedId = null; 188 if (reqID == null || reqID.length() == 0) { 189 190 org.omg.CosNaming.NameComponent [][] siblings = 191 c_query.getContained(superior); 192 allocatedId = CreateController.autoCreateId(siblings); 193 } 194 else 195 allocatedId = reqID; 196 197 199 org.omg.CosNaming.NameComponent [] name = CreateController.createFullName( 200 superior, 201 allocatedId, 202 Utils.name2facade(facade.facade_name()), 203 objectKind); 204 205 String [] supportedConditionalPackages = packageNameList; 207 208 Utils.pretty_log(logSupport, FACTORY_CLASS, "Factory", (short) LogSeverity._Info, 209 "proceed to create " + Utils.name2string(name)); 210 211 218 facade.create( 219 name, 220 objectKind, 221 packageNameList, 222 deletePolicy, 223 intt.itu.itut_x780.SourceIndicatorType.resourceOperation, 224 superior, 225 mgmtIpAddress, 226 supportedSnmpVersions, 227 snmpPort); 228 229 c_admin.addName(name, superior); 230 233 235 DataType[] routeTable = new DataType[0]; 236 try { 237 routeTable = this.connector.getSnmpTable( 238 SnmpIdentifiers.IP_ROUTE_TABLE_OID, 239 new String (mgmtIpAddress), 240 snmpPort, 241 SnmpIdentifiers.READ_COMMUNITY); } 243 catch(ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError snmp_ex) { 244 System.err.println("IpProtocolMonitorFactory: create>SnmpApplicationError caught: " + 245 snmp_ex.reason); 246 return name; 247 } 248 catch(Exception e) { 249 System.err.println("IpProtocolMonitorFactory: create>Exception caught: " + e.getMessage()); 250 e.printStackTrace(System.err); 251 } 252 269 int[] ipRouteDestIndexRows = { 1 }; 270 int numOfRouteColumns = 8; 272 String [] ipRouteDest = SnmpUtils.getStringColumnData(routeTable, 273 numOfRouteColumns, ipRouteDestIndexRows); 274 275 if (ipRouteDest.length > 0) { 276 IpRoutingEntryFactory ip_address_factory = 277 get_context().get_connection_ipRoutingEntryFactory(); 278 279 if (ip_address_factory != null) { 280 for(int i = 0; i < ipRouteDest.length; i ++) { 281 ip_address_factory.create("IpRoutingEntry_IpProtocolMonitor", 282 name, 283 new String (), 284 new String [0], 285 ipRouteDest[i].getBytes(), 286 mgmtIpAddress, 287 snmpPort, 288 supportedSnmpVersions 289 ); 290 291 } 292 } 293 } 294 295 297 DataType[] ipToMACTable = new DataType[0]; 299 try { 300 ipToMACTable = this.connector.getSnmpTable( 301 SnmpIdentifiers.IP_MACADDRESS_OID, 302 new String (mgmtIpAddress), 303 snmpPort, 304 SnmpIdentifiers.READ_COMMUNITY); } 306 catch(ist.coach.coachEmfServices.SnmpAdapter.SnmpApplicationError snmp_ex) { 307 System.err.println("IpProtocolMonitorFactory: create>SnmpApplicationError caught: " + 308 snmp_ex.reason); 309 return name; 310 } 311 catch(Exception e) { 312 System.err.println("IpProtocolMonitorFactory: create>Exception caught: " + e.getMessage()); 313 e.printStackTrace(System.err); 314 } 315 316 int[] iptoMACAddressIndexRows = { 1 }; 317 int numOfMacColumns = 4; 319 int[] iptoMACAddressIndexes = SnmpUtils.getIntColumnData(ipToMACTable, 320 numOfMacColumns, iptoMACAddressIndexRows); 321 322 int[] ipNetToMediaNetAddressRows = { 3 }; 323 String [] ipNetToMediaNetAddress= SnmpUtils.getStringColumnData(ipToMACTable, 324 numOfMacColumns, ipNetToMediaNetAddressRows); 325 326 if (iptoMACAddressIndexes.length > 0 && 327 ipNetToMediaNetAddressRows.length == ipNetToMediaNetAddress.length ) { 328 329 IpToMACAddressFactory ip_mac_address_factory = 331 get_context().get_connection_ipToMACAddressFactory(); 332 333 if (ip_mac_address_factory != null) { 334 for(int i = 0; i < iptoMACAddressIndexes.length; i ++) { 335 ip_mac_address_factory.create("IpToMACAddress_IpProtocolMonitor", 338 name, 339 new String ("IpToMACAddress" + (i+1)), 340 new String [0], 341 iptoMACAddressIndexes[i], 342 ipNetToMediaNetAddress[i].getBytes(), 343 mgmtIpAddress, 344 snmpPort, 345 supportedSnmpVersions 346 ); 347 348 } 349 } 350 } 351 352 376 378 Utils.pretty_log(logSupport, FACTORY_CLASS, "Factory", (short) LogSeverity._Info, 379 "successfully created " + Utils.name2string(name)); 380 return name; 381 382 } 383 389 public org.omg.CosNaming.NameComponent [] 390 create_base(java.lang.String nameBinding, 391 org.omg.CosNaming.NameComponent [] superior, 392 java.lang.String reqId) 393 throws intt.itu.itut_x780.CreateError, intt.itu.itut_x780.ApplicationError 394 { 395 return new NameComponent [0]; 399 } 400 } 401 | Popular Tags |