Exemple #1
0
class RackOpt():
    def __init__(self, host=edog_host, port=edog_port, sql_url=sql_url):
        self.rs = RestSql(host=host, who='rack', port=port, url=sql_url)

    def __call__(self):
        return self

    def select(self,
               what='*',
               where=None,
               limit=None,
               orderby=None,
               headers={}):
        rslt = self.rs.select(what=what,
                              where=where,
                              limit=limit,
                              orderby=orderby,
                              headers=headers)
        if rslt == {'result': 'empty'} or not rslt:
            return []
        return rslt

    def insert(self, name, headers={}):
        """
        :param what: {"name":"rack1" }
        """
        what = {'name': name}
        return self.rs.insert(what=what, headers=headers)

    def update(self, what, where, headers={}):
        """
        :param what: {"name":"rack2"},
        :param where: {"id":"1"}

        :returns: { id:0 }, id of the node updated.
        """
        return self.rs.update(what=what, where=where, headers=headers)

    def delete(self, where, headers={}):
        """
        :param where: {"id":0}

        :returns: { id:0 }
        """
        return self.rs.delete(where=where, headers=headers)
Exemple #2
0
Fichier : node.py Projet : e42s/uss
class RackOpt():
    def __init__(self, host=edog_host, port=edog_port, sql_url=sql_url):
        self.rs = RestSql(host=host, who='rack', port=port, url=sql_url)

    def __call__(self):
        return self

    def select(self, what='*', where=None, limit=None, orderby=None, headers={}):
        rslt = self.rs.select(what=what, where=where, limit=limit, orderby=orderby, headers=headers)
        if rslt == {'result':'empty'} or not rslt:
            return []
        return rslt

    def insert(self, name, headers={}):
        """
        :param what: {"name":"rack1" }
        """
        what = {'name':name}
        return self.rs.insert(what=what, headers=headers)

    def update(self, what, where, headers={}):
        """
        :param what: {"name":"rack2"},
        :param where: {"id":"1"}

        :returns: { id:0 }, id of the node updated.
        """
        return self.rs.update(what=what, where=where, headers=headers)

    def delete(self, where, headers={}):
        """
        :param where: {"id":0}

        :returns: { id:0 }
        """
        return self.rs.delete(where=where, headers=headers)
Exemple #3
0
Fichier : node.py Projet : e42s/uss
class NodeOpt():
    def __init__(self, host=edog_host, port=edog_port, sql_url=sql_url, misc_url=misc_url):
        self.rs = RestSql(host=host, who='node', port=port, url=sql_url)

    def __call__(self):
        return self

    def select(self, what='*', where=None, limit=None, orderby=None, headers={}):
        rslt = self.rs.select(what=what, where=where, limit=limit, orderby=orderby, headers=headers)
        if rslt == {'result':'empty'} or not rslt:
            return []
        return rslt

    def insert(self, what, headers={}):
        """
        :param what: { "ip":"192.168.1.1", "hostname":"node1", "user":"******", "passwd":"root", "rack":"1" }
        """
        return self.rs.insert(what=what, headers=headers)

    def update(self, what, where, headers={}):
        """
        :param what: {"hostname":"node2", "password":"******"},
        :param where: {"ip":"192.168.1.1"}

        :returns: { id:0 }, id of the node updated.
        """
        return self.rs.update(what=what, where=where, headers=headers)

    def delete(self, where, headers={}):
        """
        :param where: {"id":0}

        :returns: { id:0 }
        """
        return self.rs.delete(where=where, headers=headers)

    def moni(self, id=None, limit={}, headers={}):
        """
        Modify self.moni_dict and return it as this function's return value.

        :param id: node id
        :param headers: HTTP Request headers

        :returns: {
                        'cpu':{
                                'Intel i3, 2.4Ghz':8,
                                'Intel i7, 2.2Ghz':8
                                },
                        'cpu_used':0.21,
                        'load':[load1, load5, load15],
                        'mem':[total, used, buffers, cached],
                        'swap':[total, used],
                        'nw':[in, out],
                        'drv':[('Filesystem','1K-blocks','Use%','Mounted on'), ('/dev/sda3', 41943036, 0.69, '/media/wind')]
                    }
        """

        return rest_moni(host=edog_host, port=edog_port, id=id, limit=limit, headers=headers)

    def join(self, id, cluster_id=None):
        pass

    def exit(self, id):
        pass
Exemple #4
0
class NodeOpt():
    def __init__(self,
                 host=edog_host,
                 port=edog_port,
                 sql_url=sql_url,
                 misc_url=misc_url):
        self.rs = RestSql(host=host, who='node', port=port, url=sql_url)

    def __call__(self):
        return self

    def select(self,
               what='*',
               where=None,
               limit=None,
               orderby=None,
               headers={}):
        rslt = self.rs.select(what=what,
                              where=where,
                              limit=limit,
                              orderby=orderby,
                              headers=headers)
        if rslt == {'result': 'empty'} or not rslt:
            return []
        return rslt

    def insert(self, what, headers={}):
        """
        :param what: { "ip":"192.168.1.1", "hostname":"node1", "user":"******", "passwd":"root", "rack":"1" }
        """
        return self.rs.insert(what=what, headers=headers)

    def update(self, what, where, headers={}):
        """
        :param what: {"hostname":"node2", "password":"******"},
        :param where: {"ip":"192.168.1.1"}

        :returns: { id:0 }, id of the node updated.
        """
        return self.rs.update(what=what, where=where, headers=headers)

    def delete(self, where, headers={}):
        """
        :param where: {"id":0}

        :returns: { id:0 }
        """
        return self.rs.delete(where=where, headers=headers)

    def moni(self, id=None, limit={}, headers={}):
        """
        Modify self.moni_dict and return it as this function's return value.

        :param id: node id
        :param headers: HTTP Request headers

        :returns: {
                        'cpu':{
                                'Intel i3, 2.4Ghz':8,
                                'Intel i7, 2.2Ghz':8
                                },
                        'cpu_used':0.21,
                        'load':[load1, load5, load15],
                        'mem':[total, used, buffers, cached],
                        'swap':[total, used],
                        'nw':[in, out],
                        'drv':[('Filesystem','1K-blocks','Use%','Mounted on'), ('/dev/sda3', 41943036, 0.69, '/media/wind')]
                    }
        """

        return rest_moni(host=edog_host,
                         port=edog_port,
                         id=id,
                         limit=limit,
                         headers=headers)

    def join(self, id, cluster_id=None):
        pass

    def exit(self, id):
        pass