Example #1
0
 def NS(self):
     ip = get_ip_address()
     if ip==None:
         print("Not connected to the internet")            
         return
     subprocess.call(
         "python -m Pyro4.naming --host "+ip+" --port 8080", shell=True)
Example #2
0
def main_single(target, prefix, i):
    """
    Either calls 'wdctl status' or
    logs out the client specified by the interface prefix + i.
    """
    binary = "../../src/wdctl"
    ip = common.get_ip_address(prefix + str(i))
    mac = common.get_mac_address(prefix + str(i))
    args = [["status"], ["reset", ip], ["reset", mac]]
    call = [binary]
    call.extend(random.choice(args))
    ret = subprocess.call(call)
    print "fire_wdctl.py: Return code %s" % ret
def main_single(target, prefix, i):
    """
    Either calls 'wdctl status' or
    logs out the client specified by the interface prefix + i.
    """
    binary = "../../src/wdctl"
    ip = common.get_ip_address(prefix + str(i))
    mac = common.get_mac_address(prefix + str(i))
    args = [["status"], ["reset", ip], ["reset", mac]]
    call = [binary]
    call.extend(random.choice(args))
    ret = subprocess.call(call)
    print "fire_wdctl.py: Return code %s" % ret
Example #4
0
def main():
    ip = get_ip_address()
    if ip == None:
        print("Not connected to the internet")
        return -1
    client = Client(
        ip)  # Debo obtener la direccion ip para pasarla como parametro

    # COSAS DE LA INTERFAZ

    app = QtWidgets.QApplication([])
    servers = find_servers()
    application = mywindow(servers)
    application.show()
    sys.exit(app.exec())
Example #5
0
def execute():
    # Name server
    nameServer = NameServer()
    server_ip = get_ip_address()
    config = str(server_ip) + "\n9090"
    g = open("config.txt","w+")
    g.write(config)
    g.close()
    if server_ip!=None:
        idAssignation = Server(server_ip, 9090)
    else:
        print("Not connected to the internet")
    # Aqui inicio el name server thread y el thread de asignacion
    NS = threading.Thread(target=nameServer.NS)
    NS.start()
    print('started NS')
    idAssignationServer = threading.Thread(target=idAssignation.IDAssignation())
    idAssignationServer.start()
    print('started id assignation server')
Example #6
0
    def _retrieve_cluster_info(self):
        """Retrieves information about hosts in the cluster from the local sleep proxy plugin daemon"""
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        buf = ''    
        try:
            # Connect to server and send data
            sock.connect((common.get_ip_address(), common.CLUSTER_STATE_SERVER_PORT))
            while True:
                bytes = sock.recv(8192)
                if not bytes: # end of transfer
                    break            
                buf += bytes
        except:
            err_msg = "Could not receive cluster state from local sleep proxy"
            logging.exception(err_msg)
            raise
        finally:
            sock.close()

        return cPickle.loads(buf)   
Example #7
0
def main_single(target, prefix, i):
    source = common.get_ip_address(prefix + str(i))
    # source_address requires python 2.7
    # urllib2 does not nicely expose source_address, so use
    # lower-level API
    conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
    conn.connect()
    conn.request("GET", "/")
    try:
        resp = conn.getresponse()
        resp.read()
        conn.close()
    except BadStatusLine as e:
        print "Got BadStatusLine for /: %s" % e
    conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
    conn.connect()
    token = str(uuid.uuid4())
    conn.request("GET", "/wifidog/auth?token=" + token)
    try:
        resp = conn.getresponse()
        # this causes wifidog to ask our mock auth server if the token is
        # correct
        resp.read()
        conn.close()
    except BadStatusLine as e:
        print "Got BadStatusLine for login: %s" % e
    # log out sometimes
    if random.choice([True, False, False]):
        conn = HTTPConnection(target,
                              PORT,
                              timeout=10,
                              source_address=(source, 0))
        conn.connect()
        conn.request("GET", "/wifidog/auth?logout=1&token=" + token)
        try:
            resp = conn.getresponse()
            resp.read()
            conn.close()
        except BadStatusLine as e:
            print "Got BadStatusLine for logout: %s" % e
Example #8
0
def main_single(target, prefix, i):
    source = common.get_ip_address(prefix + str(i))
    # source_address requires python 2.7
    # urllib2 does not nicely expose source_address, so use
    # lower-level API
    conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
    conn.connect()
    conn.request("GET", "/")
    try:
        resp = conn.getresponse()
        resp.read()
        conn.close()
    except BadStatusLine as e:
        print "Got BadStatusLine for /: %s" % e
    conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
    conn.connect()
    token = str(uuid.uuid4())
    conn.request("GET", "/wifidog/auth?token=" + token)
    try:
        resp = conn.getresponse()
        # this causes wifidog to ask our mock auth server if the token is
        # correct
        resp.read()
        conn.close()
    except BadStatusLine as e:
        print "Got BadStatusLine for login: %s" % e
    # log out sometimes
    if random.choice([True, False, False]):
        conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
        conn.connect()
        conn.request("GET", "/wifidog/auth?logout=1&token=" + token)
        try:
            resp = conn.getresponse()
            resp.read()
            conn.close()
        except BadStatusLine as e:
            print "Got BadStatusLine for logout: %s" % e
Example #9
0
import random

import common


def main_single(target, prefix, i):
    """
    Either calls 'wdctl status' or
    logs out the client specified by the interface prefix + i.
    """
    binary = "../../src/wdctl"
    ip = common.get_ip_address(prefix + str(i))
    mac = common.get_mac_address(prefix + str(i))
    args = [["status"], ["reset", ip], ["reset", mac]]
    call = [binary]
    call.extend(random.choice(args))
    ret = subprocess.call(call)
    print "fire_wdctl.py: Return code %s" % ret


if __name__ == "__main__":
    parser = common.get_argparser()
    args = parser.parse_args()

    target = common.get_ip_address(args.target_interface)
    p = Pool(int(args.process_count))
    partial = functools.partial(main_single, target,
                                args.source_interface_prefix)
    while True:
        p.map(partial, list(xrange(int(args.source_interface_count))))
Example #10
0
def main(targetIF, prefix, maxI):
    target = common.get_ip_address(targetIF)
    for i in xrange(int(maxI)):
        main_single(target, prefix, i)
Example #11
0
        resp = conn.getresponse()
        # this causes wifidog to ask our mock auth server if the token is
        # correct
        resp.read()
        conn.close()
    except BadStatusLine as e:
        print "Got BadStatusLine for login: %s" % e
    # log out sometimes
    if random.choice([True, False, False]):
        conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
        conn.connect()
        conn.request("GET", "/wifidog/auth?logout=1&token=" + token)
        try:
            resp = conn.getresponse()
            resp.read()
            conn.close()
        except BadStatusLine as e:
            print "Got BadStatusLine for logout: %s" % e


if __name__ == "__main__":

    parser = common.get_argparser()
    args = parser.parse_args()

    target = common.get_ip_address(args.target_interface)
    p = Pool(int(args.process_count))
    partial = functools.partial(main_single, target, args.source_interface_prefix)
    while True:
        p.map(partial, list(xrange(int(args.source_interface_count))))
Example #12
0
def main(targetIF, prefix, maxI):
    target = common.get_ip_address(targetIF)
    for i in xrange(int(maxI)):
        main_single(target, prefix, i)
Example #13
0
class mywindow(QtWidgets.QMainWindow):

    client_ip = get_ip_address()
    servers = ""

    def __init__(self, servers):

        super(mywindow, self).__init__()

        self.servers = servers

        self.ui = Ui_MainWindow()

        self.ui.setupUi(self)

        self.ui.pushButton_2.clicked.connect(
            self.btnCommit)  ## BOTON DE COMMIT
        self.ui.pushButton_3.clicked.connect(
            self.btnUpdate)  ## BOTON DE UPDATE
        self.ui.pushButton_4.clicked.connect(
            self.btnCheckout)  ## BOTON DE CHECKOUT
        self.ui.pushButton_5.clicked.connect(
            self.btnLoad)  ## BOTON DE CARGAR ARCHIVOS

        # Llenamos el array con cosas
        self.ui.comboBox.currentIndexChanged.connect(self.selectionChange)

    def btnLoad(self):
        self.ui.comboBox.clear()
        if self.ui.lineEdit_2.text() == "":
            self.ui.label_5.setText("Ingrese un nombre de usuario")
        else:
            self.ui.comboBox.addItem("None")
            files_names = self.servers.getFileNames(self.ui.lineEdit_2.text())
            print("FILES:")
            print(files_names)
            if len(files_names) == 0:
                self.ui.label_5.setText("No hay archivos para este usuario")
            else:
                self.ui.comboBox.addItems(files_names)
                self.ui.label_5.setText("Archivos cargados")

    def btnUpdate(self):
        if self.ui.lineEdit_2.text() == "":
            self.ui.label_5.setText("Ingrese un nombre de usuario")
        else:
            if self.ui.comboBox.currentText() == "None":
                self.ui.label_2.setText("Selecione un archivo")
            else:
                self.ui.label_2.setText("Se hizo update del archivo: " +
                                        self.ui.comboBox.currentText())
                update(self.ui.comboBox.currentText(),
                       self.ui.lineEdit_2.text(), self.servers)

    def btnCheckout(self):
        if self.ui.lineEdit_2.text() == "":
            self.ui.label_5.setText("Ingrese un nombre de usuario")
        else:
            if self.ui.comboBox.currentText() == "None":
                self.ui.label_2.setText("Selecione un archivo")
            else:
                self.ui.label_2.setText("Se hizo checkout del archivo: " +
                                        self.ui.comboBox.currentText())
                checkout(self.ui.comboBox.currentText(),
                         self.ui.lineEdit_2.text(),
                         self.ui.comboBox_2.currentText(), self.servers)

    def btnCommit(self):
        if self.ui.lineEdit_2.text() == "":
            self.ui.label_5.setText("Ingrese un nombre de usuario")
        else:
            try:
                self.ui.label_5.setText("Commit del archivo: " +
                                        self.ui.lineEdit.text())
                commit(self.ui.lineEdit.text(), self.ui.lineEdit_2.text(),
                       self.servers)
                self.ui.lineEdit.setText("")
            except:
                self.ui.label_5.setText("Error con el archivo")

    def selectionChange(self):
        self.ui.label_2.setText("Selecciono la opcion: " +
                                self.ui.comboBox.currentText())
        self.ui.comboBox_2.clear()
        versiones = self.servers.getTimeVersions(
            self.ui.comboBox.currentText(), self.ui.lineEdit_2.text())
        print("VERSIONES::!:!!:!:")
        print(versiones)
        self.ui.comboBox_2.addItems(versiones)