Beispiel #1
0
 def __init__(self):
     DEVICE.__init__(self)
     self.sreader = asyncio.StreamReader(self.uart)
     self.swriter = asyncio.StreamWriter(self.uart, {})
     self.data = b''
     self.prompt_timeout = self.config['Ctd']['Prompt_Timeout']
     self.warmup_interval = self.config['Warmup_Interval']
Beispiel #2
0
 def __init__(self):
     DEVICE.__init__(self)
     self.sreader = asyncio.StreamReader(self.uart)
     self.swriter = asyncio.StreamWriter(self.uart, {})
     self.data = b''
     self.warmup_interval = self.config['Warmup_Interval']
     self.fix = None
     self.fixed = timesync
     self.displacement = 0
Beispiel #3
0
 def __init__(self):
     DEVICE.__init__(self)
     self.sreader = asyncio.StreamReader(self.uart)
     self.swriter = asyncio.StreamWriter(self.uart, {})
     self.data = b''
     self.break_timeout = self.config['Adcp']['Break_Timeout']
     self.instrument_config = self.config['Adcp']['Instrument_Config']
     self.deployment_config = self.config['Adcp']['Deployment_Config']
     self.deployment_delay = self.config['Adcp']['Deployment_Delay']
Beispiel #4
0
 def __init__(self):
     DEVICE.__init__(self)
     self.sreader = asyncio.StreamReader(self.uart)
     self.swriter = asyncio.StreamWriter(self.uart, {})
     self.data = b''
     self.warmup_interval = self.config['Warmup_Interval']
     self.data_length = self.config['Data_Length']
     self.string_label = self.config['String_Label']
     self.records = 0
Beispiel #5
0
 def __init__(self, *args, **kwargs):
     self.config_file = __name__ + "." + constants.CONFIG_TYPE
     DEVICE.__init__(self, *args, **kwargs)
     data_tasks = ["log"]
     if "tasks" in kwargs:
         if any(elem in data_tasks for elem in kwargs["tasks"]):
             if self.main():
                 for task in kwargs["tasks"]:
                     eval("self." + task + "()", {"self": self})
         else:
             for task in kwargs["tasks"]:
                 eval("self." + task + "()", {"self": self})
Beispiel #6
0
    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE()

        self._device.register(self._ets)
        self._device.weave(self._ets)

        if printGroat:
            Logger().info(self._ets.getGrOAT("gad"))
            Logger().info(self._ets.getGrOAT("go"))

        self._device.init()
Beispiel #7
0
def get_interface_list(_id: str = "",
                       name: str = "",
                       dynamic: str = "",
                       include: str = "",
                       exclude: str = "",
                       builtin: str = "",
                       comment: str = ""):

    try:

        filters_dict = {
            ".id": _id,
            "name": name,
            "dynamic": dynamic,
            "include": include,
            "exclude": exclude,
            "builtin": builtin,
            "comment": comment
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "list")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #8
0
def get_interface_bridge_vlan(_id: str = "",
                              bridge: str = "",
                              vlan_ids: str = "",
                              tagged: str = "",
                              untagged: str = "",
                              current_tagged: str = "",
                              current_untagged: str = "",
                              dynamic: str = "",
                              disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "bridge": bridge,
            "vlan-ids": vlan_ids,
            "tagged": tagged,
            "untagged": untagged,
            "current-tagged": current_tagged,
            "current-untagged": current_untagged,
            "dynamic": dynamic,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bridge", "vlan")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #9
0
def get_interface_bridge_msti(_id: str = "",
                              identifier: str = "",
                              bridge: str = "",
                              priority: str = "",
                              vlan_mapping: str = "",
                              disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "identifier": identifier,
            "bridge": bridge,
            "priority": priority,
            "vlan-mapping": vlan_mapping,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bridge", "msti")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #10
0
def get_interface(_id: str = "",
                  name: str = "",
                  default_name: str = "",
                  _type: str = "",
                  mtu: str = "",
                  actual_mtu: str = "",
                  l2mtu: str = "",
                  max_l2mtu: str = "",
                  mac_address: str = "",
                  last_link_up_time: str = "",
                  link_downs: str = "",
                  rx_byte: str = "",
                  tx_byte: str = "",
                  rx_packet: str = "",
                  tx_packet: str = "",
                  tx_queue_drop: str = "",
                  fp_rx_byte: str = "",
                  fp_tx_byte: str = "",
                  fp_rx_packet: str = "",
                  fp_tx_packet: str = "",
                  running: str = "",
                  disabled: str = ""):

    try:

        filters_dict = {
            ".id": _id,
            "name": name,
            "default-name": default_name,
            "type": _type,
            "mtu": mtu,
            "actual-mtu": actual_mtu,
            "l2mtu": l2mtu,
            "max-l2mtu": max_l2mtu,
            "mac-address": mac_address,
            "last-link-up-time": last_link_up_time,
            "link-downs": link_downs,
            "rx-byte": rx_byte,
            "tx-byte": tx_byte,
            "rx-packet": rx_packet,
            "tx-packet": tx_packet,
            "tx-queue-drop": tx_queue_drop,
            "fp-rx-byte": fp_rx_byte,
            "fp-tx-byte": fp_tx_byte,
            "fp-rx-packet": fp_rx_packet,
            "fp-tx-packet": fp_tx_packet,
            "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
def startAllDevices():
    print 'Starting DEVICE Mapping..'
    tenant_deviceIdsList = TENANT().getDevicesIds(BASE_URL, session)
    deviceInstanceList = []
    # Instantiate device objects then set device credentials
    for i in range(0, len(tenant_deviceIdsList)):
        deviceInstance = DEVICE(BASE_URL, session, tenant_deviceIdsList[i])
        deviceInstanceList.append(deviceInstance)
        print 'Device ' + str(i + 1) + ' mapped.'
    print 'Finished mapping devices.'
    return deviceInstanceList
def get_interface_bonding(_id: str = "",
                          name: str = "",
                          mtu: str = "",
                          mac_address: str = "",
                          arp: str = "",
                          arp_timeout: str = "",
                          slaves: str = "",
                          mode: str = "",
                          primary: str = "",
                          link_monitoring: str = "",
                          arp_interval: str = "",
                          arp_ip_targets: str = "",
                          mii_interval: str = "",
                          down_delay: str = "",
                          up_delay: str = "",
                          lacp_rate: str = "",
                          transmit_hash_policy: str = "",
                          min_links: str = "",
                          running: str = "",
                          disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "name": name,
            "mtu": mtu,
            "mac-address": mac_address,
            "arp": arp,
            "arp-timeout": arp_timeout,
            "slaves": slaves,
            "mode": mode,
            "primary": primary,
            "link-monitoring": link_monitoring,
            "arp-interval": arp_interval,
            "arp-ip-targets": arp_ip_targets,
            "mii-interval": mii_interval,
            "down-delay": down_delay,
            "up-delay": up_delay,
            "lacp-rate": lacp_rate,
            "transmit-hash-policy": transmit_hash_policy,
            "min-links": min_links,
            "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bonding")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #13
0
    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE(self.ets, self._deviceIndAddr)

        self.ets.register(self._device)

        if printGroat:
            logger.info(ets.getGrOAT(self._device, "gad"))
            logger.info(ets.getGrOAT(self._device, "go"))
Beispiel #14
0
    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE(self._deviceIndAddr)

        ETS().register(self._device)
        ETS().weave(self._device)

        if printGroat:
            Logger().info(ETS().getGrOAT(self._device, "gad"))
            Logger().info(ETS().getGrOAT(self._device, "go"))
Beispiel #15
0
 def __init__(self):
     DEVICE.__init__(self)
     self.sreader = asyncio.StreamReader(self.uart)
     self.swriter = asyncio.StreamWriter(self.uart, {})
     self.data = b''
     self.semaphore = Semaphore()  # Data/Sms semaphore.
     self.disconnect = disconnect
     self.at_timeout = self.config['Modem']['At_Timeout']
     self.init_ats = self.config['Modem']['Init_Ats']
     self.init_timeout = self.config['Modem']['Init_Timeout']
     self.call_ats = self.config['Modem']['Call_Ats']
     self.hangup_ats = self.config['Modem']['Hangup_Ats']
     self.at_delay = self.config['Modem']['At_Delay']
     self.call_attempt = self.config['Modem']['Call_Attempt']
     self.call_delay = self.config['Modem']['Call_Delay']
     self.call_timeout = self.config['Modem']['Call_Timeout']
     self.ymodem_delay = self.config['Modem']['Ymodem_Delay']
     self.keep_alive = self.config['Modem']['Keep_Alive']
     self.sms_ats1 = self.config['Modem']['Sms_Ats1']
     self.sms_ats2 = self.config['Modem']['Sms_Ats2']
     self.sms_timeout = self.config['Modem']['Sms_Timeout']
     self.trigger = trigger
     YMODEM.__init__(self, self.agetc, self.aputc)
def get_interface_vrrp(_id: str = "",
                       name: str = "",
                       mtu: str = "",
                       mac_address: str = "",
                       arp: str = "",
                       arp_timeout: str = "",
                       interface: str = "",
                       vrid: str = "",
                       priority: str = "",
                       interval: str = "",
                       preemption_mode: str = "",
                       authentication: str = "",
                       password: str = "",
                       on_backup: str = "",
                       on_master: str = "",
                       version: str = "",
                       v3_protocol: str = "",
                       invalid: str = "",
                       running: str = "",
                       disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "name": name,
            "mtu": mtu,
            "mac-address": mac_address,
            "arp": arp,
            "arp-timeout": arp_timeout,
            "interface": interface,
            "vrid": vrid,
            "priority": priority,
            "interval": interval,
            "preemption-mode": preemption_mode,
            "v3-protocol": v3_protocol,
            "invalid": invalid,
            "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "vrrp")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #17
0
    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE()

        self._device.register(self._ets)
        self._device.weave(self._ets)

        if printGroat:
            Logger().info(self._ets.getGrOAT("gad"))
            Logger().info(self._ets.getGrOAT("go"))

        self._device.init()
Beispiel #18
0
def get_interface_bridge(_id: str = "",
                         name: str = "",
                         mtu: str = "",
                         actual_mtu: str = "",
                         l2mtu: str = "",
                         arp: str = "",
                         arp_timeout: str = "",
                         mac_address: str = "",
                         protocol_mode: str = "",
                         fast_forward: str = "",
                         igmp_snooping: str = "",
                         auto_mac: str = "",
                         ageing_time: str = "",
                         vlan_filtering: str = "",
                         dhcp_snooping: str = "",
                         running: str = "",
                         disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "name": name,
            "mtu": mtu,
            "actual-mtu": actual_mtu,
            "l2mtu": l2mtu,
            "arp": arp,
            "arp-timeout": arp_timeout,
            "mac-address": mac_address,
            "protocol-mode": protocol_mode,
            "fast-forward": fast_forward,
            "igmp-snooping": igmp_snooping,
            "auto-mac": auto_mac,
            "ageing-time": ageing_time,
            "vlan-filtering": vlan_filtering,
            "dhcp-snooping": dhcp_snooping,
            "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bridge")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
def get_interface_wireless_access_list(_id: str = "",
                                       mac_address: str = "",
                                       interface: str = "",
                                       signal_range: str = "",
                                       allow_signal_out_of_range: str = "",
                                       authentication: str = "",
                                       forwarding: str = "",
                                       ap_tx_limit: str = "",
                                       client_tx_limit: str = "",
                                       private_algo: str = "",
                                       private_key: str = "",
                                       private_pre_shared_key: str = "",
                                       management_protection_key: str = "",
                                       vlan_mode: str = "",
                                       vlan_id: str = "",
                                       disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "mac-address": mac_address,
            "interface": interface,
            "signal-range": signal_range,
            "allow-signal-out-of-range": allow_signal_out_of_range,
            "authentication": authentication,
            "forwarding": forwarding,
            "ap-tx-limit": ap_tx_limit,
            "client-tx-limit": client_tx_limit,
            "private-algo": private_algo,
            "private-key": private_key,
            "private-pre-shared-key": private_pre_shared_key,
            "management-protection-key": management_protection_key,
            "vlan-mode": vlan_mode,
            "vlan-id": vlan_id,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "wireless", "access-list")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #20
0
class MODEM(DEVICE, YMODEM):

    def __init__(self, , *args, **kwargs):
        self.config_file = __name__ + "." + constants.CONFIG_TYPE
        DEVICE.__init__(self, *args, **kwargs)
        self.sending = False
        self.connected = False
        self.sent = False
        self.received = False
        self.timeout = 1
        self.file_paths = []
        self.unsent_files = utils.unsent_files
        self.pre_ats = self.config["Modem"]["Pre_Ats"]
        self.post_ats = self.config["Modem"]["Post_Ats"]
        self.ats_delay = self.config["Modem"]["Ats_Delay"]
        self.call_attempt = self.config["Modem"]["Call_Attempt"]
        self.call_delay = self.config["Modem"]["Call_Delay"]
        self.call_timeout = self.config["Modem"]["Call_Timeout"]
        YMODEM.__init__(self, self._getc, self._putc, mode="Ymodem1k")
Beispiel #21
0
def get_interface_bridge_host(
    _id: str = "", mac_address: str = "", interface: str = "", bridge: str = "", on_interface: str = "",
    age: str = "", invalid: str = "", dynamic: str = "", local: str = "", external: str = "", disabled: str = ""
    ):
    try:
        filters_dict = {
            ".id": _id, "mac-address": mac_address, "interface": interface, "bridge": bridge,
            "on-interface": on_interface, "age": age, "invalid": invalid, "dynamic": dynamic, "local": local,
            "external": external, "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bridge", "host")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
def get_interface_ipip(_id: str = "",
                       name: str = "",
                       mtu: str = "",
                       actual_mtu: str = "",
                       local_address: str = "",
                       remote_address: str = "",
                       current_remote_address: str = "",
                       keepalive: str = "",
                       dscp: str = "",
                       clamp_tcp_mss: str = "",
                       dont_fragment: str = "",
                       allow_fast_path: str = "",
                       running: str = "",
                       disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            "name": name,
            "mtu": mtu,
            "actual-mtu": actual_mtu,
            "local-address": local_address,
            "remote-address": remote_address,
            "current-remote-address": current_remote_address,
            "keepalive": keepalive,
            "dscp": dscp,
            "clamp-tcp-mss": clamp_tcp_mss,
            "dont-fragment": dont_fragment,
            "allow-fast-path": allow_fast_path,
            "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "ipip")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #23
0
def get_interface_wireless_registration_table(
    _id: str = "", interface: str = "", radio_name: str = "", mac_address: str = "", ap: str = "", wds: str = "",
    bridge: str = "", rx_rate: str = "", tx_rate: str = "", packets: str = "", bytes: str = "", frames: str = "",
    frame_bytes: str = "", hw_frames: str = "", hw_frame_bytes: str = "", tx_frames_timed_out: str = "",
    uptime: str = "", last_activity: str = "", signal_strength: str = "", signal_to_noise: str = "",
    signal_strength_ch0: str = "", signal_strength_ch1: str = "", tx_signal_strength_ch0: str = "",
    tx_signal_strength_ch1: str = "", strength_at_rates: str = "", tx_signal_strength: str = "", tx_ccq: str = "",
    rx_ccq: str = "", p_throughput: str = "", nstreme: str = "", framing_mode: str = "", routeros_version: str = "",
    last_ip: str = "", ap_tx_limit: str = "", client_tx_limit: str = "", _802_1x_port_enabled: str = "",
    authentication_type: str = "", encryption: str = "", group_encryption: str = "", management_protection: str = "",
    compression: str = "", wmm_enabled: str = "", tx_rate_set: str = ""
    ):
    try:
        filters_dict = {
            ".id": _id, "interface": interface, "radio-name": radio_name, "mac-address": mac_address, "ap": ap, "wds": wds,
            "bridge": bridge, "rx-rate": rx_rate, "tx-rate": tx_rate, "packets": packets, "bytes": bytes, "frames": frames,
            "frame-bytes": frame_bytes, "hw-frames": hw_frames, "hw-frame-bytes": hw_frame_bytes,
            "tx-frames-timed-out": tx_frames_timed_out, "uptime": uptime, "last-activity": last_activity,
            "signal-strength": signal_strength, "signal-to-noise": signal_to_noise,
            "signal-strength-ch0": signal_strength_ch0, "signal-strength-ch1": signal_strength_ch1,
            "tx-signal-strength-ch0": tx_signal_strength_ch0, "tx-signal-strength-ch1": tx_signal_strength_ch1,
            "strength-at-rates": strength_at_rates, "tx-signal-strength": tx_signal_strength,
            "tx-ccq": tx_ccq, "rx-ccq": rx_ccq, "p-throughput": p_throughput, "nstreme": nstreme, "framing-mode": framing_mode,
            "routeros-version": routeros_version, "last-ip": last_ip, "ap-tx-limit": ap_tx_limit,
            "client-tx-limit": client_tx_limit, "802.1x-port-enabled": _802_1x_port_enabled,
            "authentication-type": authentication_type, "encryption": encryption, "group-encryption": group_encryption,
            "management-protection": management_protection, "compression": compression, "wmm-enabled": wmm_enabled,
            "tx-rate-set": tx_rate_set
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "wireless", "registration-table")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
def get_interface_list_member(_id: str = "",
                              _list: str = "",
                              interface: str = "",
                              dynamic: str = "",
                              disabled: str = ""):
    try:

        filters_dict = {
            ".id": _id,
            "list": _list,
            "interface": interface,
            "dynamic": dynamic,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "list", "member")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #25
0
class DeviceRunner(object):
    """
    """
    def __init__(self, loggerLevel, devicePath, mapPath):
        """
        """
        super(DeviceRunner, self).__init__()

        sys.path.insert(0, devicePath)

        # Load user 'settings' module
        from settings import DEVICE_NAME, DEVICE_IND_ADDR

        # Init the logger
        # DO NOT USE LOGGER BEFORE THIS POINT!
        if loggerLevel is not None:
            config.LOGGER_LEVEL = loggerLevel

        Logger("%s-%s" % (DEVICE_NAME, DEVICE_IND_ADDR), config.LOGGER_LEVEL)
        Logger().info("Logger level is '%s'" % config.LOGGER_LEVEL)

        Logger().info("Device path is '%s'" % devicePath)
        Logger().info("Device name is '%s'" % DEVICE_NAME)

        deviceIndAddr = DEVICE_IND_ADDR
        if not isinstance(deviceIndAddr, IndividualAddress):
            deviceIndAddr = IndividualAddress(deviceIndAddr)
        if deviceIndAddr.isNull:
            Logger().warning("Device Individual Address is null")
        else:
            Logger().info("Device Individual Address is '%s'" % DEVICE_IND_ADDR)

        # Retreive 'map' module
        GAD_MAP = {}
        if mapPath != "$PKNYX_MAP_PATH":
            if os.path.exists(mapPath):

                # Load 'map' module from mapPath
                try:
                    fp, pathname, description = imp.find_module('map', mapPath)
                except ImportError:
                    Logger().critical("Can't find 'map' module in %s" % mapPath)
                    sys.exit(1)
                try:
                    mapModule = imp.load_module("map", fp, pathname, description)
                finally:
                    if fp:
                        fp.close()
                GAD_MAP = mapModule.GAD_MAP
            else:
                Logger().warning("Specified map path does not exists (%s)" % mapPath)

        # Create KNX stack
        self._stack = Stack(DEVICE_IND_ADDR)
        self._ets = ETS(self._stack, gadMap=GAD_MAP)

    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE()

        self._device.register(self._ets)
        self._device.weave(self._ets)

        if printGroat:
            Logger().info(self._ets.getGrOAT("gad"))
            Logger().info(self._ets.getGrOAT("go"))

        self._device.init()

    def run(self, detach):
        """
        """
        Logger().trace("Device.run()")

        self.check()

        Logger().info("Detaching is '%s'" % detach)

        Scheduler().start()
        self._stack.mainLoop()  # blocking call
        Scheduler().stop()

        self._device.shutdown()
Beispiel #26
0
class DeviceRunner(object):
    """
    """
    def __init__(self, loggerLevel, devicePath, gadMapPath):
        """
        """
        super(DeviceRunner, self).__init__()

        sys.path.insert(0, devicePath)

        # Load user 'settings' module
        from settings import DEVICE_NAME, DEVICE_IND_ADDR

        # Init the logger
        if loggerLevel is not None:
            config.LOGGER_LEVEL = loggerLevel

        # DO NOT USE LOGGER BEFORE THIS POINT!
        Logger("%s-%s" % (DEVICE_NAME, DEVICE_IND_ADDR))
        Logger().info("Logger level is '%s'" % config.LOGGER_LEVEL)

        Logger().info("Device path is '%s'" % devicePath)
        Logger().info("Device name is '%s'" % DEVICE_NAME)

        self._deviceIndAddr = DEVICE_IND_ADDR
        if not isinstance(self._deviceIndAddr, IndividualAddress):
            self._deviceIndAddr = IndividualAddress(self._deviceIndAddr)
        if self._deviceIndAddr.isNull:
            Logger().warning("Device Individual Address is null")
        else:
            Logger().info("Device Individual Address is '%s'" % self._deviceIndAddr)

        # Load GAD map table
        mapper = GroupAddressTableMapper()
        mapper.loadFrom(gadMapPath)

    def _doubleFork(self):
        """ Double fork.
        """
        if os.fork() != 0:  # launch child and ...
            os._exit(0)     # kill off parent
        os.setsid()
        os.chdir("/")
        os.umask(0)
        if os.fork() != 0:  # fork again so we are not a session leader
            os._exit(0)

        # Close stdxxx
        sys.stdin.close()
        sys.__stdin__ = sys.stdin
        sys.stdout.close()
        sys.stdout = sys.__stdout__ = _NullDevice()
        sys.stderr.close()
        sys.stderr = sys.__stderr__ = _NullDevice()

        # ??? does not work if enable
        #for fd in xrange(4, 1024):
            #try:
                #os.close(fd)
            #except OSError:
                #pass

    def check(self, printGroat=False):
        """
        """

        # Create device from user 'device' module
        from device import DEVICE
        self._device = DEVICE(self._deviceIndAddr)

        ETS().register(self._device)
        ETS().weave(self._device)

        if printGroat:
            Logger().info(ETS().getGrOAT(self._device, "gad"))
            Logger().info(ETS().getGrOAT(self._device, "go"))

    def run(self, dameon=False):
        """
        """
        Logger().trace("Device.run()")

        self.check()

        if dameon:
            Logger().info("Run process as daemon...")
            self._doubleFork()

        self._device.start()
        Scheduler().start()
        time.sleep(1)  # wait for things to start
        try:
            self._device.mainLoop()

        except KeyboardInterrupt:
            Logger().warning("Device execution canceled (SIGTERM)")

        except:
            Logger().exception("deviceRunner.run()")

        finally:
            Scheduler().stop()
            self._device.stop()
            self._device.shutdown()
Beispiel #27
0
def get_interface_wireless(
    _id: str = "", default_name: str = "", name: str = "", mtu: str = "", l2mtu: str = "", mac_address: str = "",
    arp: str = "", arp_timeout: str = "", disable_running_check: str = "", interface_type: str = "",
    radio_name: str = "", mode: str = "", ssid: str = "", area: str = "", frequency_mode: str = "",
    country: str = "", installation: str = "", antenna_gain: str = "", frequency: str = "", band: str = "",
    channel_width: str = "", secondary_channel: str = "", scan_list: str = "", wireless_protocol: str = "",
    rate_set: str = "", supported_rates_ag: str = "", max_station_count: str = "", distance: str = "",
    tx_power_mode: str = "", noise_floor_threshold: str = "", nv2_noise_floor_offset: str = "",
    vlan_mode: str = "", vlan_id: str = "", wds_mode: str = "", wds_default_bridge: str = "",
    wds_default_cost: str = "", wds_cost_range: str = "", wds_ignore_ssid: str = "",
    update_stats_interval: str = "", bridge_mode: str = "", default_authentication: str = "",
    default_forwarding: str = "", default_ap_tx_limit: str = "", default_client_tx_limit: str = "",
    wmm_support: str = "", hide_ssid: str = "", security_profile: str = "", interworking_profile: str = "",
    wps_mode: str = "", station_roaming: str = "", disconnect_timeout: str = "", on_fail_retry_time: str = "",
    preamble_mode: str = "", compression: str = "", allow_sharedkey: str = "", station_bridge_clone_mac: str = "",
    ampdu_priorities: str = "", guard_interval: str = "", ht_supported_mcs: str = "", ht_basic_mcs: str = "",
    tx_chains: str = "", rx_chains: str = "", amsdu_limit: str = "", amsdu_threshold: str = "",
    tdma_period_size: str = "", nv2_queue_count: str = "", nv2_qos: str = "", nv2_cell_radius: str = "",
    nv2_security: str = "", nv2_preshared_key: str = "", nv2_mode: str = "", nv2_downlink_ratio: str = "",
    nv2_sync_secret: str = "", hw_retries: str = "", frame_lifetime: str = "", adaptive_noise_immunity: str = "",
    hw_fragmentation_threshold: str = "", hw_protection_mode: str = "", hw_protection_threshold: str = "",
    frequency_offset: str = "", rate_selection: str = "", multicast_helper: str = "", multicast_buffering: str = "",
    keepalive_frames: str = "", skip_dfs_channels: str = "", running: str = "", disabled: str = ""    
    ):
    try:
        filters_dict = {
            ".id": _id, "default-name": default_name, "name": name, "mtu": mtu, "l2mtu": l2mtu,
            "mac-address": mac_address, "arp": arp, "arp-timeout": arp_timeout,
            "disable-running-check": disable_running_check, "interface-type": interface_type,
            "radio-name": radio_name, "mode": mode, "ssid": ssid, "frequency-mode": frequency_mode,
            "country": country, "installation": installation, "antenna-gain": antenna_gain, "frequency": frequency,
            "band": band, "channel-width": channel_width, "secondary-channel": secondary_channel,
            "scan-list": scan_list, "wireless-protocol": wireless_protocol, "rate-set": rate_set,
            "supported-rates-a/g": supported_rates_ag, "max-station-count": max_station_count,
            "distance": distance, "tx-power-mode": tx_power_mode, "noise-floor-threshold": noise_floor_threshold,
            "nv2-noise-floor-offset": nv2_noise_floor_offset, "vlan-mode": vlan_mode, "vlan-id": vlan_id,
            "wds-mode": wds_mode, "wds-default-bridge": wds_default_bridge, "wds-default-cost": wds_default_cost,
            "wds-cost-range": wds_cost_range, "wds-ignore-ssid": wds_ignore_ssid,
            "update-stats-interval": update_stats_interval, "bridge-mode": bridge_mode,
            "default-authentication": default_authentication, "default-forwarding": default_forwarding,
            "default-ap-tx-limit": default_ap_tx_limit, "default-client-tx-limit": default_client_tx_limit,
            "wmm-support": wmm_support, "hide-ssid": hide_ssid, "security-profile": security_profile,
            "interworking-profile": interworking_profile, "wps-mode": wps_mode, "station-roaming": station_roaming,
            "disconnect-timeout": disconnect_timeout, "on-fail-retry-time": on_fail_retry_time,
            "preamble-mode": preamble_mode, "compression": compression, "allow-sharedkey": allow_sharedkey,
            "station-bridge-clone-mac": station_bridge_clone_mac, "ampdu-priorities": ampdu_priorities,
            "guard-interval": guard_interval, "ht-supported-mcs": ht_supported_mcs, "ht-basic-mcs": ht_basic_mcs,
            "tx-chains": tx_chains, "rx-chains": rx_chains, "amsdu-limit": amsdu_limit, "amsdu-threshold": amsdu_threshold,
            "tdma-period-size": tdma_period_size, "nv2-queue-count": nv2_queue_count, "nv2-qos": nv2_qos,
            "nv2-cell-radius": nv2_cell_radius, "nv2-security": nv2_security, "nv2-preshared-key": nv2_preshared_key,
            "nv2-mode": nv2_mode, "nv2-downlink-ratio": nv2_downlink_ratio, "nv2-sync-secret": nv2_sync_secret,
            "hw-retries": hw_retries, "frame-lifetime": frame_lifetime, "adaptive-noise-immunity": adaptive_noise_immunity,
            "hw-fragentation-threshold": hw_fragmentation_threshold, "hw-protection-mode": hw_protection_mode,
            "hw-protection-threshold": hw_protection_threshold, "frequency-offset": frequency_offset,
            "rate-selection": rate_selection, "multicast-helper": multicast_helper, "multicast-buffering": multicast_buffering,
            "keepalive-frames": keepalive_frames, "skip-dfs-channels": skip_dfs_channels, "running": running,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "wireless")
        #data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
def startDeviceInstance(deviceID):
    print 'Starting DEVICE Mapping..'
    # Instantiate device object by ID and then set device credentials
    deviceInstance = DEVICE(BASE_URL, session, deviceID)
    print 'Finished mapping device.'
    return deviceInstance
Beispiel #29
0
def get_interface_bridge_port(_id: str = "",
                              nextid: str = "",
                              interface: str = "",
                              bridge: str = "",
                              priority: str = "",
                              path_cost: str = "",
                              internal_path_cost: str = "",
                              edge: str = "",
                              point_to_point: str = "",
                              learn: str = "",
                              horizon: str = "",
                              auto_isolate: str = "",
                              restricted_role: str = "",
                              restricted_tcn: str = "",
                              pvid: str = "",
                              frame_types: str = "",
                              ingress_filtering: str = "",
                              unknown_unicast_flood: str = "",
                              unknown_multicast_flood: str = "",
                              broadcast_flood: str = "",
                              tag_stacking: str = "",
                              bpdu_guard: str = "",
                              trusted: str = "",
                              multicast_router: str = "",
                              fast_leave: str = "",
                              status: str = "",
                              port_number: str = "",
                              role: str = "",
                              edge_port: str = "",
                              edge_port_discovery: str = "",
                              point_to_point_port: str = "",
                              external_fdb_status: str = "",
                              sending_rstp: str = "",
                              learning: str = "",
                              forwarding: str = "",
                              debug_info: str = "",
                              inactive: str = "",
                              dynamic: str = "",
                              disabled: str = ""):
    try:
        filters_dict = {
            ".id": _id,
            ".nextid": nextid,
            "interface": interface,
            "bridge": bridge,
            "priority": priority,
            "path-cost": path_cost,
            "internal-path-cost": internal_path_cost,
            "edge": edge,
            "point-to-point": point_to_point,
            "learn": learn,
            "frame-types": frame_types,
            "ingress-filtering": ingress_filtering,
            "unknown-unicast-flood": unknown_unicast_flood,
            "unknown-multicast-flood": unknown_multicast_flood,
            "broadcast-flood": broadcast_flood,
            "tag-stacking": tag_stacking,
            "bpdu-guard": bpdu_guard,
            "trusted": trusted,
            "multicast-router": multicast_router,
            "fast-leave": fast_leave,
            "status": status,
            "port-number": port_number,
            "role": role,
            "edge-port": edge_port,
            "edge-port-discovery": edge_port_discovery,
            "point-to-point-port": point_to_point_port,
            "external-fdb-status": external_fdb_status,
            "sending-rstp": sending_rstp,
            "learning": learning,
            "forwarding": forwarding,
            "debug-info": debug_info,
            "inactive": inactive,
            "dynamic": dynamic,
            "disabled": disabled
        }

        filters_list = get_filters_list(filters_dict=filters_dict)

        data = DEVICE.path("interface", "bridge", "port")
        data = data.select(*filters_dict.keys()).where(*filters_list)

        return tuple(data)

    except Exception as e:
        return {"error": e}
Beispiel #30
0
 def __init__(self):
     DEVICE.__init__(self)