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)
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)
def _send(self, d): buf = json.dumps(d) self.sem.acquire() self.sock.sendall(utils.int2bytes(len(buf)) + buf) self.sem.release()
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()