def __init__(self, pnode, event_callback, create_event_subscriber, destroy_event_subscriber): """ Creates a PlatformDriver instance. @param pnode Root PlatformNode defining the platform network rooted at this platform. @param event_callback Callback to notify platform agent about events generated by this driver. This is captured in self._send_event for this class and subclasses to call as needed. @param create_event_subscriber @param destroy_event_subscriber functions to create/destroy any needed EventSubscriber's, in particular regarding the Managed Endpoint API. """ # # NOTE the "pnode" parameter may be not very "standard" but it is the # current convenient mechanism that captures the overall definition # of the corresponding platform (most of which coming from configuration) # self._pnode = pnode self._send_event = event_callback self._create_event_subscriber = create_event_subscriber self._destroy_event_subscriber = destroy_event_subscriber self._platform_id = self._pnode.platform_id if self._pnode.parent: self._parent_platform_id = self._pnode.parent.platform_id else: self._parent_platform_id = None self._platform_attributes = \ dict((a.attr_id, a.defn) for a in self._pnode.attrs.itervalues()) if log.isEnabledFor(logging.DEBUG): log.debug("%r: PlatformDriver constructor called: pnode:\n%s\n" "_platform_attributes=%s", self._platform_id, NetworkUtil._dump_pnode(self._pnode, include_subplatforms=False), self._platform_attributes) self._driver_config = None self._resource_schema = {} # The parameter dictionary. self._param_dict = {} # construct FSM and start it with initial state UNCONFIGURED: self._construct_fsm() self._fsm.start(PlatformDriverState.UNCONFIGURED)
def _configure(self, config): """ Configures this driver. In this base class it basically calls validate_driver_configuration and then assigns the given config to self._driver_config. @param driver_config Driver configuration. """ # # NOTE the "pnode" parameter may be not very "standard" but it is the # current convenient mechanism that captures the overall definition # of the corresponding platform (most of which coming from configuration) # # Use the network definition provided by RSN OMS directly. rsn_oms = CIOMSClientFactory.create_instance() network_definition = RsnOmsUtil.build_network_definition(rsn_oms) CIOMSClientFactory.destroy_instance(rsn_oms) platform_id = 'LJ01D' self._pnode = network_definition.pnodes[platform_id] #self._pnode = config.get('pnode') self._platform_id = self._pnode.platform_id if self._pnode.parent: self._parent_platform_id = self._pnode.parent.platform_id else: self._parent_platform_id = None self._platform_attributes = \ dict((a.attr_id, a.defn) for a in self._pnode.attrs.itervalues()) log.debug("%r: PlatformDriver constructor called: pnode:\n%s\n" "_platform_attributes=%s", self._platform_id, NetworkUtil._dump_pnode(self._pnode, include_subplatforms=False), self._platform_attributes) self.validate_driver_configuration(config) self._driver_config = config