Example #1
0
def _load_networking(self, resource_id):
    if self.debug & 0x01:
        print("_load_networking {!s} called".format(resource_id))

    if not hasattr(self, '_name2id') or not isinstance(self._name2id, dict):
        self._name2id = dict()

    xurl = "/rest/networking/{!s}".format(resource_id)
    if self.debug & 0x02:
        print("_load_networking : xurl = " + xurl)
    net_res_tree = self._getXMLetree(xurl)
    if net_res_tree is None:
        if (len(self.error_str)):
            raise IsyResponseError(self.error_str)
        else:
            raise IsyResponseError(xurl)
    net_dict = dict()
    name2rid = dict()
    for netr in net_res_tree.iter('NetRule'):
        netrule = et2d(netr)
        if 'id' in netrule:
            net_dict[netrule['id']] = netrule
            if 'name' in netrule:
                n = netrule['name']
                name2rid[n] = netrule['id']

                # name2id to replace name2var as a global lookup table
                if n in self._name2id:
                    print("Dup name2id : \"" + n + "\" : " + netrule['id'])
                    print("\tname2id ", self._name2id[n])
                else:
                    self._name2id[n] = (resource_id, netrule['id'])

    return (net_dict, name2rid)
Example #2
0
def net_resource_run(self, rrid):
    """ Calls and executes net resource

        args:
            rrid : network resource ID
    calls : /rest/networking/resources/<rrid>
    """

    rid = self._net_resource_get_id(rrid)

    if rid is None:
        raise IsyValueError("net_resource_run : bad network resources ID : " + rrid)

    xurl = "/rest/networking/resources/{!s}".format(rid)

    if self.debug & 0x02:
        print(("wol : xurl = " + xurl))
    resp = self._getXMLetree(xurl)
    # self._printXML(resp)
    if resp is None or  resp.attrib["succeeded"] != 'true':
        raise IsyResponseError("ISY network resources error : rid=" + str(rid))
Example #3
0
def net_wol(self, wid):
    """ Send Wake On LAN to registared wol ID

        args:
            wid : WOL resource ID
    calls : /rest/networking/wol/<wol_id>
    """

    wol_id = self._net_wol_get_id(wid)

    # wol_id = str(wid).upper()

    if wol_id is None:
        raise IsyValueError("bad wol ID : " + wid)

    xurl = "/rest/networking/wol/" + wol_id

    if self.debug & 0x02:
        print("wol : xurl = " + xurl)
    resp = self._getXMLetree(xurl)
    # self._printXML(resp)
    if resp.attrib["succeeded"] != 'true':
        raise IsyResponseError("ISY command error : cmd=wol wol_id=" \
            + str(wol_id))