Ejemplo n.º 1
0
def main(argv = sys.argv):
    Logging.log_init('rsp2_bridge_wrapper', 'rsp2_bridge_wrapper', 0,
                     Logging.component_id(Logging.LCI_RSP), Logging.LOG_DEBUG,
                     Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)

    build_vmware_db()
    set_up_signal_handlers()

    enable_vmware_bridging()

    # Spin waiting for signals.
    while (True):
        signal.pause()
def main(argv = sys.argv):
    Logging.log_init('vmware_ws_interface_wrapper', 'vmware_ws_interface_wrapper', 0,
                     Logging.component_id(Logging.LCI_VSP), Logging.LOG_DEBUG,
                     Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)

    interfaceName = ""

    try:
        opts, args = getopt.getopt(sys.argv[1:], "hpi:", ["help", "print","interface="])
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)
Ejemplo n.º 3
0
def main():
    """!
    Entry point of the wrapper, intialize logger and signal handler. Starts
    vmware-vmx and starts monitoring it 
    """
    
    Logging.log_init('vmware_vmx_wrapper', 'vmware_vmx_wrapper', 0,
                     Logging.component_id(Logging.LCI_VSP), Logging.LOG_DEBUG,
                     Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)
     
    Logging.log(Logging.LOG_INFO, 
                "vsp_vmware_vmx_wrapper started")
    
    signal.signal(signal.SIGINT, terminate_term_handler)
    signal.signal(signal.SIGTERM, terminate_term_handler)
    signal.signal(signal.SIGQUIT, terminate_quit_handler)
    signal.signal(signal.SIGUSR1, terminate_usr1_handler)
    
    #get the esxi dir
    esxi_dir = Vsp.get_esxi_dir()
    
    vmx_conf_file_path = "%s/%s" %(esxi_dir, ESXI_VMX_NAME)
      
    #Check if the vm configuration exists
    if not os.path.exists(vmx_conf_file_path): 
        Logging.log(Logging.LOG_ERR, 
                    "VM configuration %s doesn't exist" % vmx_conf_file_path)
        sys.exit(1)

    # Check if vmware-vmx is already running. The fuction returns None if no
    # process_id exists or if there's multiple process_ids associated with
    # the vmx_conf. However, it's not possible to launch two running vmware_vmx
    # using the same vmx_conf. The chance this returns None b/c of multiple
    # process ids is almost nonexistant. 
    proc_id = Vsp.get_vmx_proc_id(vmx_conf_file_path)

    #Start vmware-vmx if an instance has not been started
    if proc_id == None:

        # Clean up the "shutting down" file used for ESXi HPN dependency
        if os.path.exists(SHUTDOWN_MARKER):
            os.remove(SHUTDOWN_MARKER)
        cleanup_locks(esxi_dir)
        start_vmware_vmx(vmx_conf_file_path)

    #Get the new process id
    proc_id = Vsp.get_vmx_proc_id(vmx_conf_file_path)

    monitor_vmware_vmx(proc_id)
Ejemplo n.º 4
0
def main():
    """!
    Entry point to the watchdog. Initialize logger and starts attempting to
    communicate with ESXi
    """
    global g_mgmtd_pid

    g_mgmtd_pid = None

    mgmtd_pids = []

    Logging.log_init('esxi_watchdog', 'esxi_watchdog', 0,
                     Logging.component_id(Logging.LCI_VSP), Logging.LOG_DEBUG,
                     Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)

    Logging.log(Logging.LOG_INFO, "esxi watchdog started")

    # Bug 117274: It may happen that we get multiple pids for mgmtd process,
    # pidof ran between fork-exec call, retry to allow mgmtd to settle
    for i in range(1, MAX_MGMTD_SETTLE_RETRY):
        mgmtd_pids = Vsp.get_pids('mgmtd')
        if len(mgmtd_pids) > 1:
            # multiple pids detected, give mgmtd sometime to settle
            time.sleep(MGMTD_SETTLE_TIMEOUT)
        else:
            g_mgmtd_pid = mgmtd_pids[0]
            break

    # Bug 112192: monitor mgmtd pid, if mgmtd crashes/exits
    # terminate watchdog as well
    if g_mgmtd_pid == None:
        # mgmtd not up kill watchdog process
        Logging.log(Logging.LOG_ERR, "Mgmtd is not ready, kill watchdog!")
        sys.exit();

    Mgmt.open()
    signal.signal(signal.SIGINT, terminate_handler)
    signal.signal(signal.SIGTERM, terminate_handler)
    signal.signal(signal.SIGQUIT, terminate_handler)

    # Invalidate the session file if it exists on startup
    if os.path.exists(SESSION_FILE):
        os.remove(SESSION_FILE)

    monitor_esxi()
    Mgmt.close()
Ejemplo n.º 5
0
import sys
import os

workDir = '/opt/tms/web2/appserver'
webwareDir = '/opt/tms/web2/webware'
libraryDirs = ['/opt/tms/web2/pythonlib']

sys.path.insert(0, webwareDir)
for dir in libraryDirs:
    sys.path.insert(0, dir)
sys.argv = []

import Logging
Logging.log_init('webasd', 'web', 0,
                 Logging.component_id(Logging.LCI_WEB), Logging.LOG_DEBUG,
                 Logging.LOG_LOCAL0, Logging.LCT_SYSLOG)
Logging.log(Logging.LOG_INFO, 'Logging initialized for webasd')

tempDir = '/var/tmp'

# tempfile package uses this
os.environ['TMPDIR'] = tempDir
# fork/exec'ed CLI uses this
os.environ['USER'] = '******'

# clean out any old temporary upload files
for name in os.listdir(tempDir):
    if name.startswith('tmp_upload_'):
        os.unlink('%s/%s' % (tempDir, name))