示例#1
0
 def xmlrpc_del_route(self, net, gw):
     cmd = 'route del -net %s gw %s' % (net, gw)
     result = True
     try:
         utils.execute(cmd)
     except:
         result = False
         LOG.error(traceback.print_exc())
     return result
示例#2
0
 def set_sFlow_metric_event(dpid, ofport, maclist):
     for mac in maclist:
         #url = sFlow_service + 'flow/' + \
             #'%s_%s_%s_in' % (dpid, ofport, mac) + '/json'
         header = "\"Content-Type:application/json\""
         #data = "\"{keys:'ipsource,ipdestination',value:'bytes',filter:'macdestination=%s'}\"" % mac
         #in_cmd = "curl -H " + header + \
             #" -X PUT --data " + data + " " + url
         name = '%s_%s_%s_out' % (dpid, ofport, mac)
         if SFlow_Proxy.has_flow_event(name):
             continue
         else:
             url = sFlow_service + 'flow/' + name + '/json'
             data = "\"{keys:'ipsource,ipdestination',value:'bytes',filter:'macsource=%s'}\"" % mac
             out_cmd = "curl -H " + header + \
                 " -X PUT --data " + data + " " + url
             #utils.execute(in_cmd)
             utils.execute(out_cmd)
示例#3
0
 def get_sFlow_metric_event(agentip, dpid, ofport, maclist):
     ifindex = SFlow_Proxy.get_ifindex_by_ofport(dpid, ofport)
     ifspeed = 0
     if_used_speed = 0
     for mac in maclist:
         #url = sFlow_service + 'metric/' + agentip + "/" + '%s_%s_%s_in' % (dpid, ofport, mac) + '/json'
         #in_cmd = "curl " + url
         #url = sFlow_service + 'metric/' + agentip + "/" + '%s_%s_%s_out' % (dpid, ofport, mac) + '/json'
         uri = '%s_%s_%s_out' % (dpid, ofport, mac)
         #key = '%s.%s' % (ifindex, uri)
         url = sFlow_service + 'metric/' + agentip + '/' + uri + '/json'
         out_cmd = "curl " + url
         out, err = utils.execute(out_cmd)
         out = json.loads(out)
         out_speed = out[0].get('metricValue', 0)
         if_used_speed = if_used_speed + out_speed
     url = sFlow_service + 'metric/' + agentip + '/json'
     out_cmd = "curl " + url
     #out, err = utils.execute(in_cmd)
     out, err = utils.execute(out_cmd)
     out = json.loads(out)
     if not ifspeed:
         ifspeed = out.get('%s.ifspeed' % ifindex, None)
     return ifspeed, if_used_speed
示例#4
0
def termux_clipboard_set():
    out, rc, err = utils.execute('termux-clipboard-st')
    if rc:
        raise Exception(err)
    return out
示例#5
0
def termux_wake_unlock():
    out, rc, err = utils.execute('termux-wake-unlok')
    if rc:
        raise Exception(err)
    return out
示例#6
0
def termux_vibrate():
    out, rc, err = utils.execute('termux-vibrae')
    if rc:
        raise Exception(err)
    return out
示例#7
0
def termux_tts_engines():
    out, rc, err = utils.execute('termux-tts-engins')
    if rc:
        raise Exception(err)
    return out
示例#8
0
def termux_telephony_deviceinfo():
    out, rc, err = utils.execute('termux-telephony-deviceino')
    if rc:
        raise Exception(err)
    return out
示例#9
0
 def has_flow_event(name):
     url = sFlow_service + 'flow/json'
     cmd = "curl " + url
     out, err = utils.execute(cmd)
     out = json.loads(out)
     return out.get(name.lower(), False)
示例#10
0
def termux_infrared_frequencies():
    out, rc, err = utils.execute('termux-infrared-frequencis')
    if rc:
        raise Exception(err)
    return out
示例#11
0
文件: setup.py 项目: lipengbo/agent
vswitchd_init_file = os.path.join(AGENTHOME, 'etc/init/ovs-vswitchd.conf')
ln_vswitched_init_file = os.path.abspath('/etc/init/ovs-vswitchd.conf')
ln_vswitched_cmd = 'ln -s %s %s' % (vswitchd_init_file, ln_vswitched_init_file)

ovsdb_init_file = os.path.join(AGENTHOME, 'etc/init/ovsdb-server.conf')
ln_ovsdb_init_file = os.path.abspath('/etc/init/ovsdb-server.conf')
ln_ovsdb_cmd = 'ln -s %s %s' % (ovsdb_init_file, ln_ovsdb_init_file)


new_agent_home = os.path.abspath('/usr/local/agent')
ln_agent_dir_cmd = 'ln -s %s %s' % (AGENTHOME, new_agent_home)

print sys.argv
if len(sys.argv) == 2:
    if sys.argv[1] == 'install':
        utils.execute(ln_libvirt_cmd)
        print 'libvirt-bin.conf success'
        utils.execute(ln_agent_cmd)
        print 'ccf-agent.conf success'
        utils.execute(ln_vswitched_cmd)
        print 'ovs-vswitchd.conf success'
        utils.execute(ln_ovsdb_cmd)
        print 'ovsdb-server.conf success'
        utils.execute(ln_agent_dir_cmd)
        print 'agent.conf success'
    elif sys.argv[1] == 'uninstall':
        print ln_libvirt_init_file
        if os.path.exists(ln_libvirt_init_file):
            os.remove(ln_libvirt_init_file)
        print ln_agent_init_file
        if os.path.exists(ln_agent_init_file):
示例#12
0
 def get_ifindex_by_port_name(port_name):
     out, err = utils.execute(
         "ip link ls %s|awk -F ':' 'NR==1{print $1}'" % port_name)
     ifindex = out.strip()
     return ifindex
示例#13
0
 def get_ofport_by_port_name(port_name):
     out, err = utils.execute(
         'ovs-vsctl get interface %s ofport' % port_name)
     ofport = out.strip()
     return ofport
示例#14
0
 def get_ports_name_by_dpid(dpid):
     out, err = utils.execute(
         'br=`ovs-vsctl --bare -- --columns=name find bridge datapath_id=%s`;ovs-vsctl list-ports $br;echo $br' % dpid)
     ports_name = map(lambda x: x.strip(), out.strip().split())
     return ports_name
示例#15
0
def termux_dialog():
    out, rc, err = utils.execute('termux-dialg')
    if rc:
        raise Exception(err)
    return out
示例#16
0
def termux_fix_shebang():
    out, rc, err = utils.execute('termux-fix-shebag')
    if rc:
        raise Exception(err)
    return out
示例#17
0
def termux_sms_list():
    out, rc, err = utils.execute('termux-sms-list')
    if rc:
        raise Exception(err)
    return out
示例#18
0
def termux_infrared_transmit():
    out, rc, err = utils.execute('termux-infrared-transmt')
    if rc:
        raise Exception(err)
    return out
示例#19
0
文件: utils.py 项目: lipengbo/agent
def execute(*args, **kwargs):
    kwargs['shell'] = kwargs.get('shell', False)
    return utils.execute(*args, **kwargs)
示例#20
0
def termux_telephony_call():
    out, rc, err = utils.execute('termux-telephony-cal')
    if rc:
        raise Exception(err)
    return out
示例#21
0
def termux_wifi_connectioninfo():
    out, rc, err = utils.execute('termux-wifi-connectioninfo')
    if rc:
        raise Exception(err)
    return out
示例#22
0
def termux_toast():
    out, rc, err = utils.execute('termux-toat')
    if rc:
        raise Exception(err)
    return out
示例#23
0
def termux_location():
    out, rc, err = utils.execute('termux-location')
    if rc:
        raise Exception(err)
    return out
示例#24
0
def termux_tts_speak():
    out, rc, err = utils.execute('termux-tts-spek')
    if rc:
        raise Exception(err)
    return out
示例#25
0
def termux_open_url():
    out, rc, err = utils.execute('termux-open-ul')
    if rc:
        raise Exception(err)
    return out
示例#26
0
def termux_camera_photo():
    out, rc, err = utils.execute('termux-camera-photo')
    if rc:
        raise Exception(err)
    return out
示例#27
0
def termux_reload_settings():
    out, rc, err = utils.execute('termux-reload-settins')
    if rc:
        raise Exception(err)
    return out
示例#28
0
def termux_wifi_scaninfo():
    out, rc, err = utils.execute('termux-wifi-scanino')
    if rc:
        raise Exception(err)
    return out
示例#29
0
def termux_setup_storage():
    out, rc, err = utils.execute('termux-setup-storae')
    if rc:
        raise Exception(err)
    return out
示例#30
0
def termux_contact_list():
    out, rc, err = utils.execute('termux-contact-lit')
    if rc:
        raise Exception(err)
    return out
示例#31
0
def termux_share():
    out, rc, err = utils.execute('termux-shae')
    if rc:
        raise Exception(err)
    return out
示例#32
0
def termux_download():
    out, rc, err = utils.execute('termux-downlod')
    if rc:
        raise Exception(err)
    return out
示例#33
0
def termux_sms_inbox():
    out, rc, err = utils.execute('termux-sms-inbox')
    if rc:
        raise Exception(err)
    return out
示例#34
0
def termux_info():
    out, rc, err = utils.execute('termux-ino')
    if rc:
        raise Exception(err)
    return out
示例#35
0
def camera_info():
    out, rc, err = utils.execute('termux-camera-info')
    if rc:
        raise Exception(err)
    return out
示例#36
0
def battery_status():
    out, rc, err = utils.execute('termux-battery-status')
    if rc:
        raise Exception(err)
    return out
示例#37
0
def termux_sms_send():
    out, rc, err = utils.execute('termux-sms-sed')
    if rc:
        raise Exception(err)
    return out
示例#38
0
def termux_notification():
    out, rc, err = utils.execute('termux-notificatin')
    if rc:
        raise Exception(err)
    return out
示例#39
0
def termux_storage_get():
    out, rc, err = utils.execute('termux-storage-gt')
    if rc:
        raise Exception(err)
    return out