示例#1
0
    def main(self, argv):
        self.parser = self.get_base_parser()
        (options, args) = self.parser.parse_known_args(argv)

        if options.help:
            self.do_help(options)
            return 0

        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        nodes = ['node1', 'node2']
        nodeinfo = {'node1':{'bmc':'10.0.0.1', 'bmcip':'10.0.0.1', 'username':'******', 'password': '******'},
                    'node2':{'bmc':'10.0.0.2', 'bmcip':'10.0.0.2', 'username':'******', 'password': '******'}}

        s.connect(options.sock)
        req = {'module': 'openbmc',
               'command': 'rpower',
               'args': ['state'],
               'cwd': os.getcwd(),
               'nodes': nodes,
               'nodeinfo': nodeinfo,
               'envs': {'debugmode': 1}}

        buf = json.dumps(req)
        s.send(utils.int2bytes(len(buf)))
        s.send(buf)
        while True:
            sz = s.recv(4)
            if len(sz) == 0:
                break
            sz = utils.bytes2int(sz)
            data = s.recv(sz)
            print(data)
示例#2
0
文件: client.py 项目: xcat2/xcat-core
    def main(self, argv):
        self.parser = self.get_base_parser()
        (options, args) = self.parser.parse_known_args(argv)

        if options.help:
            self.do_help(options)
            return 0

        s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        nodes = ['node1', 'node2']
        nodeinfo = {'node1':{'bmc':'10.0.0.1', 'bmcip':'10.0.0.1', 'username':'******', 'password': '******'},
                    'node2':{'bmc':'10.0.0.2', 'bmcip':'10.0.0.2', 'username':'******', 'password': '******'}}

        s.connect(options.sock)
        req = {'module': 'openbmc',
               'command': 'rpower',
               'args': ['state'],
               'cwd': os.getcwd(),
               'nodes': nodes,
               'nodeinfo': nodeinfo,
               'envs': {'debugmode': 1}}

        buf = json.dumps(req)
        s.send(utils.int2bytes(len(buf)))
        s.send(buf.encode('utf-8'))
        while True:
            sz = s.recv(4)
            if len(sz) == 0:
                break
            sz = utils.bytes2int(sz)
            data = s.recv(sz).decode('utf-8')
            print(data)
示例#3
0
 def _send(self, d):
     buf = json.dumps(d)
     self.sem.acquire()
     self.sock.sendall(utils.int2bytes(len(buf)) + buf)
     self.sem.release()
示例#4
0
文件: server.py 项目: xcat2/xcat-core
 def _send(self, d):
     buf = json.dumps(d)
     self.sem.acquire()
     self.sock.sendall(utils.int2bytes(len(buf)) + buf.encode('utf-8'))
     self.sem.release()