Ejemplo n.º 1
0
 def activateChoice(self):
     """ Choose to stop or restart sensor after changing the config """
     logging.debugv("menu/config.py->activateChoice(self)", [])
     choices = [
             ("Stop", "Stop the sensor"),
             ("Restart", "Restart the sensor"),
             ]
     choice = self.d.menu("The configuration of the sensor has changed. What would you like to do?", choices=choices, cancel="back")
     if choice[1] == "Stop":
         manage.Manage(self.d).sensorDown()
         client.saveConf()
     elif choice[1] == "Restart":
         self.d.infobox("Bringing sensor down...")
         f.sensorDown()
         client.saveConf()
         manage.Manage(self.d).sensorUp()
     else:
         self.activateChoice()
Ejemplo n.º 2
0
def action(action):
    """ Functions that exececutes action received by server """
    logging.debugv("functions/__init__.py->action(action)", [action])
    if action == "reboot":
        logging.info("Server request: Reboot")
        reboot()
    elif action == "sshon":
        logging.info("Server request: SSH Enable")
        sshUp()
    elif action == "sshoff":
        logging.info("Server request: SSH Disable")
        sshDown()
    elif action == "start":
        logging.info("Server request: Start/Restart sensor")
        sensorDown()
        sensorUp()
    elif action == "stop":
        logging.info("Server request: Stop sensor")
        sensorDown()
        networkUp()
    elif action == "saveconf":
        logging.info("Server request: Save config")
        client.saveConf()
    elif action == "sensorupgrade":
        # apt-get install surfids-sensor
        logging.info("Server request: Sensor upgrade")
        aptUpdate()
        aptInstall()
    elif action == "aptupgrade":
        # apt-get upgrade
        logging.info("Server request: APT upgrade")
        aptUpdate()
        aptUpgrade()
    elif action == "depupgrade":
        # apt-get install <sensor dependencies>
        logging.info("Server request: Dependency upgrade")
        aptUpdate()
        depUpgrade()
    elif action == "aptcount":
        logging.info("Server request: APT count")
        aptUpdate()
        aptCount()
Ejemplo n.º 3
0
def action(action):
    """ Functions that exececutes action received by server """
    logging.debugv("functions/__init__.py->action(action)", [action])
    if action == "reboot":
        logging.info("Server request: Reboot")
        reboot()
    elif action =="sshon":
        logging.info("Server request: SSH Enable")
        sshUp()
    elif action == "sshoff":
        logging.info("Server request: SSH Disable")
        sshDown()
    elif action == "start":
        logging.info("Server request: Start/Restart sensor")
        sensorDown()
        sensorUp()
    elif action == "stop":
        logging.info("Server request: Stop sensor")
        sensorDown()
        networkUp()
    elif action == "saveconf":
        logging.info("Server request: Save config")
        client.saveConf()
    elif action == "sensorupgrade":
	# apt-get install surfids-sensor
        logging.info("Server request: Sensor upgrade")
        aptUpdate()
        aptInstall()
    elif action == "aptupgrade":
	# apt-get upgrade
        logging.info("Server request: APT upgrade")
        aptUpdate()
        aptUpgrade()
    elif action == "depupgrade":
	# apt-get install <sensor dependencies>
        logging.info("Server request: Dependency upgrade")
        aptUpdate()
        depUpgrade()
    elif action == "aptcount":
        logging.info("Server request: APT count")
        aptUpdate()
        aptCount()
Ejemplo n.º 4
0
 def activateChoice(self):
     """ Choose to stop or restart sensor after changing the config """
     logging.debugv("menu/config.py->activateChoice(self)", [])
     choices = [
         ("Stop", "Stop the sensor"),
         ("Restart", "Restart the sensor"),
     ]
     choice = self.d.menu(
         "The configuration of the sensor has changed. What would you like to do?",
         choices=choices,
         cancel="back")
     if choice[1] == "Stop":
         manage.Manage(self.d).sensorDown()
         client.saveConf()
     elif choice[1] == "Restart":
         self.d.infobox("Bringing sensor down...")
         f.sensorDown()
         client.saveConf()
         manage.Manage(self.d).sensorUp()
     else:
         self.activateChoice()
Ejemplo n.º 5
0
    # Checking sensor type
    sensortype = c.getSensorType()
    if sensortype == "":
        logging.error("Could not find a sensor type in configuration")
        raise excepts.ConfigException, "Could not find sensor type"

    # Set some general values
    bridgeID = 0
    nm = ""
    bc = ""
    gw = ""

    if c.changed:
        if c.changed == True:
            client.saveConf()

    if sensortype == "normal":
        # Steps to be taken:
        #   Create bridge
        #   Create tap
        #   Add tap + main interface to bridge
        #   Give bridge IP
        #   Remove IP from inf

        # Only use the first interface that is configured
        try:
            inf = c.getMainIf()
        except excepts.InterfaceException:
            logging.error("Could not find an interface configuration.")
            return
Ejemplo n.º 6
0
    # Checking sensor type
    sensortype = c.getSensorType()
    if sensortype == "":
        logging.error("Could not find a sensor type in configuration")
        raise excepts.ConfigException, "Could not find sensor type"

    # Set some general values
    bridgeID = 0
    nm = ""
    bc = ""
    gw = ""

    if c.changed:
        if c.changed == True:
            client.saveConf()

    if sensortype == "normal":
        # Steps to be taken:
        #   Create bridge
        #   Create tap
        #   Add tap + main interface to bridge
        #   Give bridge IP
        #   Remove IP from inf

        # Only use the first interface that is configured
        try:
            inf = c.getMainIf()
        except excepts.InterfaceException:
            logging.error("Could not find an interface configuration.")
            return