Ejemplo n.º 1
0
 def start(self):
     self._cpex_lock.acquire()
     try:
         for child in self.children_nodes():
             if isinstance(child,EnergywiseSwitch):
                 if child.PROTOCOL_SNMP == child.protocol:
                     self._snmp_switches.append(child)
                 else:
                     self._cpex_switches.append(child)
                 self._all_switches.append(child)
             elif isinstance(child,EnergywiseDomain):
                 self._all_domains.append(child)
         # elif @fixme magic hook for reverse compatibility.
         if self._snmp_switches and self._cpex_switches:
             raise EConfiguration(
                 "All switches in a domain must be configurtion to use the"
                 " same protocol."
                 )
         self._cpex_switches.sort(_cpex_switch_cmp) 
     finally:
         self._cpex_lock.release()
     if not self.domain:
         self.domain = _find_domain(self)
     if self._snmp_switches:
         self.energywise_domain_usage = self.snmp_domain_usage
     elif self._cpex_switches:
         self.energywise_domain_usage = self.cpex_domain_usage
     else:
         self.energywise_domain_usage = self._empty_domain_usage
     Node.start(self)
     return
Ejemplo n.º 2
0
 def start(self):
     if self.debug:
         msg = 'Inside Start()'
         msglog.log('Energywise:', msglog.types.INFO, msg)
     if not self.running:
         if not (1024 < self.cpex_port < 65536):
             raise EConfiguration(
                 "Invalid port specified (%d). "
                 "Please enter values between 1025 and 65535 " 
                 % self.cpex_port
                 )
         self.running = 1
         self._cpex_connect = self._cpex_connect_orig
         Node.start(self)
         if self.PROTOCOL_SNMP == self.protocol:
             # Create SNMP node for this remote_agent
             self.createEnergywiseSNMPNodes()
             self.snmp_switch_agent_node = self.get_snmp_switch_agent_node()
             self.cewEntEnergyUsage_node = self.get_cewEntEnergyUsage_node()
             self.cewEntEnergyUnits_node = self.get_cewEntEnergyUnits_node()
             self.snmp_usage_map = {}
             for child in self.cewEntEnergyUsage_node.children_nodes():
                 self.snmp_usage_map[('usage', child.name)] = child
             for child in self.cewEntEnergyUnits_node.children_nodes():
                 self.snmp_usage_map[('units', child.name)] = child
             self.get_switch_usage = self.snmp_switch_usage
         else:
             self.get_switch_usage = self.cpex_switch_usage
     return
Ejemplo n.º 3
0
 def start(self):
     self._lock.acquire()
     try:
         self._restart()
     finally:
         self._lock.release()
     Node.start(self)
     return
Ejemplo n.º 4
0
 def start(self):
     self._lock.acquire()
     try:
         self._restart()
     finally:
         self._lock.release()
     Node.start(self)
     return
Ejemplo n.º 5
0
 def stop(self):
     if self.debug:
         msg = 'Inside Stop()'
         msglog.log('Energywise:', msglog.types.INFO, msg)
     if self.running:
         Node.stop(self)
         self.running = 0
         self.get_switch_usage = self._not_running
     return
Ejemplo n.º 6
0
 def __init__(self):
     Node.__init__(self)
     self._dev_name = None  # Can programmatically override BEFORE start.
     self._lock = Lock()
     self._popen = None
     self._apps = []
     self._groups = []
     self._discovery_ts = None
     return
Ejemplo n.º 7
0
 def __init__(self):
     Node.__init__(self)
     self._dev_name = None  # Can programmatically override BEFORE start.
     self._lock = Lock()
     self._popen = None
     self._apps = []
     self._groups = []
     self._discovery_ts = None
     return
Ejemplo n.º 8
0
 def stop(self):
     self._lock.acquire()
     try:
         self._reset_popen()
         self._dev_name = None
         self._discovery_ts = None
     finally:
         self._lock.release()
     Node.stop(self)
     return
Ejemplo n.º 9
0
 def stop(self):
     self._lock.acquire()
     try:
         self._reset_popen()
         self._dev_name = None
         self._discovery_ts = None
     finally:
         self._lock.release()
     Node.stop(self)
     return
Ejemplo n.º 10
0
 def configure(self, config):
     if self.debug:
         msg = 'Inside Configure api '
         msglog.log('Energywise:', msglog.types.INFO, msg )
         msg = 'sys path %s'
         msglog.log('Energywise:', msglog.types.INFO, msg %sys.path)
     Node.configure(self, config)
     set_attribute(self, 'ttl', 30, config, int)
     set_attribute(self, 'debug', 0, config, int)
     set_attribute(self, 'address', REQUIRED, config)
     set_attribute(self, 'shared_secret', REQUIRED, config)
     set_attribute(self, 'cpex_port', 43440, config, int)
     set_attribute(self, 'primary', False, config, as_boolean)
     #SNMP is taken as default for reverse compatibility
     set_attribute(self, 'protocol', 'SNMP', config, 
                   self.as_protocol_name)
     set_attribute(self, 'snmp_batch_size', 50, config, int)
     if self.debug:
         msg = 'Configured address  %s '
         msglog.log('Energywise:', msglog.types.INFO, msg %self.address)
     if not self.domain:
         self.domain = _find_domain(self)
         if self.debug:
             msg = 'Configured CPEX domain %s '
             msglog.log('Energywise:', msglog.types.INFO, msg %self.domain)
     set_attribute(self,'snmp_version', REQUIRED, config)
     if self.debug:
         msg = 'Configured snmp_version %s'
         msglog.log('Energywise:', msglog.types.INFO, msg %self.snmp_version)
     set_attribute(self,'community_name',REQUIRED, config)
     if self.debug:
         msg = 'Configured community_name %s'
         msglog.log('Energywise:', msglog.types.INFO,
                                   msg %self.community_name)
     set_attribute(self,'security_name','default', config)
     if self.debug:
         msg = 'Configured security_name %s'
         msglog.log('Energywise:', msglog.types.INFO,
                                   msg %self.security_name)
     set_attribute(self,'user_name',' ', config)
     set_attribute(self,'authentication_protocol','usmNoAuthProtocol',
                   config)
     set_attribute(self,'authentication_key',' ', config)
     set_attribute(self,'privacy_protocol','usmNoPrivProtocol', config)
     set_attribute(self,'privacy_key', ' ',config)
     return
Ejemplo n.º 11
0
 def __init__(self):
     Node.__init__(self)
     self._cpex_connect_orig = self._cpex_connect
     self._cpex_connect = self._not_running
     self.running = 0
     self.domain = ''
     self.address = REQUIRED
     self.snmp_version = REQUIRED
     self.snmp_batch_size = 50
     self.community_name = REQUIRED
     self.security_name = None
     self.username = None
     self.authentication_protocol = None
     self.authentication_key = None
     self.privacy_protocol = None
     self.privacy_key = None
     self.remote_agent = None
     self.trend_node = None
     self.period = 60
     self.debug = 0
     self.shared_secret = REQUIRED
     self.cpex_port = CPEX_DEFAULT_PORT
     self.primary = False
     self.protocol = 'SNMP'
     self.cpex_connect_retry = 60
     self.cpex_timeout = 1 # 12
     self.get_switch_usage = self._not_running
     self.cewEntEnergyUsage_node = None
     self.cewEntEnergyUnits_node = None
     self.snmp_usage_map = None
     self.snmp_switch_agent_node = None
     self._snmp_cache_lock=Lock()
     self._snmp_cache_value=None
     self._snmp_cache_time=0
     self.ttl=30 
     return
Ejemplo n.º 12
0
 def configuration(self):
     if self.debug:
         msg = 'Inside Configuration()'
         msglog.log('Energywise:', msglog.types.INFO, msg)
     config = Node.configuration(self)
     get_attribute(self, 'ttl', config, str)
     get_attribute(self, 'debug', config, str)
     get_attribute(self, 'domain', config)
     get_attribute(self, 'address', config)
     get_attribute(self, 'snmp_version', config)
     get_attribute(self, 'snmp_batch_size', config, str)
     get_attribute(self, 'community_name', config)
     get_attribute(self, 'security_name', config)
     get_attribute(self, 'user_name', config)
     get_attribute(self, 'authentication_protocol', config)
     get_attribute(self, 'authentication_key', config)
     get_attribute(self, 'privacy_protocol', config)
     get_attribute(self, 'privacy_key', config)
     get_attribute(self, 'shared_secret', config)
     get_attribute(self, 'cpex_port', config)
     get_attribute(self, 'primary', config)
     get_attribute(self, 'protocol', config)
     return config
Ejemplo n.º 13
0
 def start(self):
     self._cbus = self._get_cbus()
     self._app = self._get_app()
     Node.start(self)
     return
Ejemplo n.º 14
0
 def configure(self, config):
     Node.configure(self, config)
     set_attribute(self, 'auto_discover', 1, config, as_boolean)
     set_attribute(self, 'debug', 0, config, as_boolean)
     return
Ejemplo n.º 15
0
 def configuration(self):
     config = Node.configuration(self)
     # get_attribute(self, '', config)
     return config
Ejemplo n.º 16
0
 def stop(self):
     Node.stop(self)
     self._cbus = None
     self._app = None
     return
Ejemplo n.º 17
0
 def stop(self):
     self._reinit()
     Node.stop(self)
     return
Ejemplo n.º 18
0
 def configure(self, config):
     Node.configure(self, config)
     set_attribute(self, 'group', REQUIRED, config, int)
     return
Ejemplo n.º 19
0
 def __init__(self):
     Node.__init__(self)
     self._cbus = None
     self._app = None
     self._grp = None
     return
Ejemplo n.º 20
0
 def configuration(self):
      config = Node.configuration(self)
      get_attribute(self, 'ttl', config, str)
      return config
 def __init__(self):
     Node.__init__(self)
     self.value = 0L
     return
Ejemplo n.º 22
0
 def configure(self,config):
     Node.configure(self,config)
     set_attribute(self, 'network_path', REQUIRED, config)
     return
 def __init__(self):
     Node.__init__(self)
     self.value = 0L
     return
Ejemplo n.º 24
0
 def stop(self):
     Node.stop(self)
     self._cbus = None
     self._app = None
     self._grp = None
     return
Ejemplo n.º 25
0
 def start(self):
     self._cbus = self._get_cbus()
     self._app = self._get_app()
     self._grp = self._get_grp()
     Node.start(self)
     return
Ejemplo n.º 26
0
 def configuration(self):
     config = Node.configuration(self)
     get_attribute(self, 'auto_discover', config)
     get_attribute(self, 'debug', config)
     return config
Ejemplo n.º 27
0
 def configuration(self):
     config = Node.configuration(self)
     get_attribute(self, 'network_path', config)
     return config
Ejemplo n.º 28
0
 def configure(self, config):
      Node.configure(self, config)
      set_attribute(self, 'ttl', 30, config, int)
      return
Ejemplo n.º 29
0
 def __init__(self):
     Node.__init__(self)
     self._cbus = None
     self._app = None
     return
Ejemplo n.º 30
0
 def start(self):
     Node.start(self)
     self._cbus = self._get_cbus()
     return
Ejemplo n.º 31
0
 def configuration(self):
     config = Node.configuration(self)
     get_attribute(self, "auto_discover", config)
     get_attribute(self, "debug", config)
     return config
Ejemplo n.º 32
0
 def configuration(self):
     config = Node.configuration(self)
     get_attribute(self, 'group', config)
     return config
Ejemplo n.º 33
0
 def start(self):
     self._cbus = self._get_cbus()
     Node.start(self)
     return
Ejemplo n.º 34
0
 def configure(self, config):
     Node.configure(self, config)
     set_attribute(self, "auto_discover", 1, config, as_boolean)
     set_attribute(self, "debug", 0, config, as_boolean)
     return
Ejemplo n.º 35
0
 def configure(self,config):
     Node.configure(self,config)
     # set_attribute(self, '', REQUIRED, config, int)
     return
Ejemplo n.º 36
0
 def __init__(self):
     Node.__init__(self)
     self._cbus = None
     self.network_path = None
     return
Ejemplo n.º 37
0
 def stop(self):
     Node.stop(self)
     self._cbus = None
     return