def tutorial_cfg_cmd(): """ Configure some command templates. """ master = Master() cmd = Command() cmd.abs_cmd = 'hwinfo' cmd.act_cmd = 'lscpu' master.cfg_cmd('10.65.7.131', cmd) cmd.abs_cmd = 'hwinfo' cmd.act_cmd = 'lscpu' master.cfg_cmd('10.137.59.22', cmd) cmd.abs_cmd = 'networkinfo' cmd.act_cmd = 'ifconfig' master.cfg_cmd('10.65.7.131', cmd) cmd.abs_cmd = 'networkinfo' cmd.act_cmd = 'ifconfig' master.cfg_cmd('10.137.59.22', cmd)
def tutorial_exec_cmd(): """ Configure one command and execute it to show network interface information on device(here we use linux server instead of real device) """ master = Master() cmd = Command() cmd.abs_cmd = 'networkinfo' cmd.act_cmd = 'ifconfig' master.cfg_cmd('10.137.59.22', cmd) para_list = [] identity1 = Identity() identity1.ip = '10.137.59.22' identity1.dev_id = 'tianyi.dty' identity1.dev_pw = 'Mtfbwy626488' telnetPro = ('telnet_server_control', 'TelnetServerControl') para_list.append(('cmd', 'networkinfo', identity1, telnetPro)) result = master.execute(para_list) print 'result:' print result
def tutorial_exec_script(): """ Configure two types of comamands, then execute a script to show hardware and network information on device (here we use linux server instead of real device) """ master = Master() cmd = Command() cmd.abs_cmd = 'hwinfo' cmd.act_cmd = 'lscpu' master.cfg_cmd('10.65.7.131', cmd) cmd.abs_cmd = 'hwinfo' cmd.act_cmd = 'lscpu' master.cfg_cmd('10.137.59.22', cmd) cmd.abs_cmd = 'networkinfo' cmd.act_cmd = 'ifconfig' master.cfg_cmd('10.65.7.131', cmd) para_list = [('script', 'script-linux.py')] result = master.execute(para_list) print 'result:' print result
def tutorial_exec_script2(): """ Configure two commands which have the same abstract command on different devices. Then execute a script which contains both these commands to show network interface information on device(here we use linux server instead of real device) """ master = Master() cmd = Command() cmd.abs_cmd = 'show' cmd.act_cmd = 'show -hw' master.cfg_cmd('1.1.1.1', cmd) cmd.abs_cmd = 'ps' cmd.act_cmd = 'ps -hw' master.cfg_cmd('1.1.1.1', cmd) cmd.abs_cmd = 'show' cmd.act_cmd = 'show -cisco' master.cfg_cmd('192.168.0.1', cmd) para_list = [('script', 'script-diffdev.py')] result = master.execute(para_list) print 'result:' print result
def main(): storage = BasicFileSystemStorage(STORAGE_PARENT, use_datetime=True) with UdpConnection.create(SERVER_PORT, CLIENT_PORT, timeout=SERVER_TIMEOUT) as connection: master = Master(connection, storage) # Let's familiarize ourselves with all the clients: print('Registering clients') master.discover_clients() # Run several times (how many times we want to take pictures). for i in range(RUN_EXPERIMENT_TIMES): print('Taking picture', i) # Notify all clients to take a picture. # The id we will use to identify the image is from i connection.broadcast(CommandType.TAKE_PICTURE, TakePictureParams(i)) # Wait until next time to take a picture time.sleep(WAIT_BETWEEN_PICS_SEC) # Collect results: print('Collecting results') master.collect_pictures() print('Done')
import json from master.master import Master config = "" with open('./configuration.json', 'r') as f: config = json.load(f) master = Master(config) master.start()
def ready(self): Master() # Initialize the singleton
def server(self): return Master()