예제 #1
0
파일: cnsmo.py 프로젝트: ethigue/cnsmo
 def __configure_system_state(self):
     self.__logger.debug("Starting system state client...")
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(address=self.__address, service_id=self.__name, service_type=self.__type,
                                                                                   service_status=self.__status, subscriptions=[],
                                                                                   callback=self.update_service)
     self.__system_state_manager.start()
     self.__logger.debug("Started system state client")
     print("State up to date")
예제 #2
0
    def __init__(self):
        call = threading.Thread
        self.client = SystemStateFactory.generate_system_state_client("localhost:6379", "Client",
                                                                      "Ready", ["Client2"], self.client_pipe)

        self.client2 = SystemStateFactory.generate_system_state_client("localhost:6379", "Client2",
                                                                      "Ready", ["Client"], self.client_pipe)

        self.manager = SystemStateFactory.generate_system_state_manager("localhost:6379")

        t = call(target=self.manager.start)
        t.start()
        time.sleep(0.5)
        t2 = call(target=self.client2.start)
        t2.start()
        time.sleep(0.5)
        t3 =  call(target=(self.client.start))
        t3.start()
예제 #3
0
    def setUp(self):
        """
        Initializes all service managers (without starting them), and the vpn_manager. Starts the vpn_manager
        :return:
        """
        self.git_branch_name = "test/dyn-vpn-orch-workflow"

        redis_address = "localhost:6379"

        setup_id = randint(1, 999999)
        print("SETTING UP TEST %s ...." % str(setup_id))

        self.system_state = SystemStateFactory.generate_system_state_manager(
            "localhost:6379")
        system_state_t = threading.Thread(target=self.system_state.start)
        system_state_t.start()
        time.sleep(1)

        service_id = "VPNConfigurer-234-" + str(setup_id)

        self.deploy_configurator = self.make_service_deployer(
            redis_address, service_id, "VPNConfigManager", BashDeployer(None),
            self.get_configurator_app_request(service_id))

        service_id = "VPNServerService-234-" + str(setup_id)
        self.deploy_server = self.make_service_deployer(
            redis_address, service_id, "VPNServer", BashDeployer(None),
            self.get_server_app_request(service_id))

        service_id = "ClientVPN-1-234-" + str(setup_id)
        self.deploy_client1 = self.make_service_deployer(
            redis_address, service_id, "VPNClient", BashDeployer(None),
            self.get_client1_app_request(service_id))

        service_id = "ClientVPN-2-234-" + str(setup_id)
        self.deploy_client2 = self.make_service_deployer(
            redis_address, service_id, "VPNClient", BashDeployer(None),
            self.get_client2_app_request(service_id))

        self.vpn_manager = VPNManager(redis_address)
        self.vpn_manager.start()

        self.client1_manager = None
        self.client2_manager = None
        self.configurator_manager = None
        self.server_manager = None
        print("SETUP COMPLETE")
예제 #4
0
    def setUp(self):
        self.git_branch_name = "test/dyn-vpn-orch-workflow"

        redis_address = "localhost:6379"

        system_state = SystemStateFactory.generate_system_state_manager("localhost:6379")
        system_state_t = threading.Thread(target=system_state.start)
        system_state_t.start()
        time.sleep(1)

        # Configuring each service in a different Thread to make things feel real
        self.configurator_t = threading.Thread(target=self.deploy_service, args=
            (redis_address, "VPNConfigurer-234", "VPNConfigManager", BashDeployer(None), self.get_configurator_app_request()))

        self.server_t = threading.Thread(target=self.deploy_service, args=
            (redis_address, "VPNServerService-234", "VPNServer", BashDeployer(None), self.get_server_app_request()))

        self.client1_t = threading.Thread(target=self.deploy_service, args=
            (redis_address, "ClientVPN-1-234", "VPNClient", BashDeployer(None), self.get_client1_app_request()))

        self.client2_t = threading.Thread(target=self.deploy_service, args=
            (redis_address, "ClientVPN-2-234", "VPNClient", BashDeployer(None), self.get_client2_app_request()))

        self.vpn_manager = VPNManager(redis_address)
        self.vpn_manager_t = threading.Thread(target=self.vpn_manager.start)


        self.vpn_manager.start()
        time.sleep(5)
        self.configurator_t.start()
        time.sleep(1)
        self.server_t.start()
        time.sleep(1)
        self.client1_t.start()
        time.sleep(1)
        self.client2_t.start()
        time.sleep(3)
예제 #5
0
 def __configure_system_state(self):
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(address=self.__address, service_id=self.__name, service_type=self.__type,
                                                                                   service_status=self.__status, subscriptions=[],
                                                                                   callback=self.update_service)
     self.__system_state_manager.start()
     print "State up to date"
예제 #6
0
    def __init__(self):

        self.client = SystemStateFactory.generate_system_state_client(
            "localhost:6379", "Client1", "Client", "Ready", ["Client2"],
            self.pipe)
        self.client.start()
예제 #7
0
파일: vpn.py 프로젝트: ethigue/cnsmo
 def __configure_system_state(self):
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(
         self.__bind_address, "myVpn", "VPNManager", self.__status,
         ["VPNServer", "VPNClient", "VPNConfigManager"],
         self.process_advertisement)
예제 #8
0
    def __init__(self):

        self.manager = SystemStateFactory.generate_system_state_manager("localhost:6379")
        self.manager.start()
예제 #9
0
 def __configure_system_state(self):
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(self.__bind_address, "myLb", "LBManager",
                                                                                   self.__status, ["LBServer", "LBConfigManager"],
                                                                                   self.register_service)
예제 #10
0
파일: vpn.py 프로젝트: dana-i2cat/cnsmo
 def __configure_system_state(self):
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(self.__bind_address, "myVpn", "VPNManager",
                                                                                   self.__status, ["VPNServer", "VPNClient", "VPNConfigManager"],
                                                                                   self.process_advertisement)
예제 #11
0
def main():
    """
    This is the second proof of concept of the CYCLONE CNSMO architecture
    The idea is the following:
    :We have a distributed  system state, which is actually implmemented.
    :We also have the VPN Manager which is a kind of orchestrator for different services
    :the credentialManager service represents the entity that will provide the config files and stuff
    :The Server is meant to be the service that will deploy the VPN server daemon

    the credential and server services are both configured with a basic bash deployer. That means
    that any launched app in that service, will be spawned via bash.
    For simplicity this PoC just launches to python REST servers that only respond with dummy responses.
    :return:
    """
    #Configuring the System State Manager, it listen to new services
    system_state = SystemStateFactory.generate_system_state_manager(
        "localhost:6379")
    t = threading.Thread(target=system_state.start)
    t.start()
    time.sleep(1)  #Sleeping for synchronization

    #The bash deployer to be used by the Server and the credential manager
    bash_deployer = BashDeployer(None)

    #Configuring the VPN Orchestrator in a different Thread to make things feel real
    vpn = VPNManager("localhost:6379")
    t2 = threading.Thread(target=vpn.start)
    t2.start()
    time.sleep(1)  #Sleeping for synch

    #At this point the VPN Manager is advertising himself to the SystemState,
    #There is a Main topic called Discovery.
    #By default the VPN Orchestrator is susbcribed to Client, Server and Credential MAnager Topics

    #Configuring the Server Manager
    server = CNSMOManager("localhost:6379", "server_123", "Server",
                          bash_deployer, None)

    #Configuring the Credential Manager
    credential = CNSMOManager("localhost:6379", "cert_123",
                              "CredentialManager", bash_deployer, None)

    #Launching the server in another thread to make things feel real
    t3 = threading.Thread(target=server.start)
    t3.start()
    time.sleep(1)

    #Launching the credential manager in a different thread to make things feel real
    t4 = threading.Thread(target=credential.start)
    t4.start()
    time.sleep(1)

    #Now we simulate that we are composing a server service for the ServerManager
    server.compose_service(**get_server_app_request().dictionarize())
    #...And launch it
    server.launch_service("server_123")
    time.sleep(
        0.5
    )  # Again, for synch, this is just to help to read the logs in the correct order

    #Let's compose a service for the credential manager as well
    credential.compose_service(**get_cert_app_request().dictionarize())
    #...And of course, launch it
    credential.launch_service("cert_123")

    #We sleep here in order to let the servers spawn correctly...
    time.sleep(0.5)
    #to finally deploy the VPN...
    vpn.deploy()
예제 #12
0
 def __configure_system_state(self):
     self.__system_state_manager = SystemStateFactory.generate_system_state_client(
         self.__bind_address, "myLb", "LBManager", self.__status,
         ["LBServer", "LBConfigManager"], self.register_service)
예제 #13
0
    def __init__(self):
        self.client = SystemStateFactory.generate_system_state_client("localhost:6379", "Client2",
                                                                      "Ready", ["Client1"], self.pipe)

        self.client.start()
예제 #14
0
def main():
    """
    This is the second proof of concept of the CYCLONE CNSMO architecture
    The idea is the following:
    :We have a distributed  system state, which is actually implmemented.
    :We also have the VPN Manager which is a kind of orchestrator for different services
    :the credentialManager service represents the entity that will provide the config files and stuff
    :The Server is meant to be the service that will deploy the VPN server daemon

    the credential and server services are both configured with a basic bash deployer. That means
    that any launched app in that service, will be spawned via bash.
    For simplicity this PoC just launches to python REST servers that only respond with dummy responses.
    :return:
    """
    #Configuring the System State Manager, it listen to new services
    system_state = SystemStateFactory.generate_system_state_manager("localhost:6379")
    t = threading.Thread(target=system_state.start)
    t.start()
    time.sleep(1) #Sleeping for synchronization

    #The bash deployer to be used by the Server and the credential manager
    bash_deployer = BashDeployer(None)

    #Configuring the VPN Orchestrator in a different Thread to make things feel real
    vpn = VPNManager("localhost:6379")
    t2 = threading.Thread(target=vpn.start)
    t2.start()
    time.sleep(1) #Sleeping for synch

    #At this point the VPN Manager is advertising himself to the SystemState,
    #There is a Main topic called Discovery.
    #By default the VPN Orchestrator is susbcribed to Client, Server and Credential MAnager Topics


    #Configuring the Server Manager
    server = CNSMOManager("localhost:6379", "server_123", "Server", bash_deployer, None)

    #Configuring the Credential Manager
    credential = CNSMOManager("localhost:6379", "cert_123", "CredentialManager", bash_deployer, None)

    #Launching the server in another thread to make things feel real
    t3 = threading.Thread(target=server.start)
    t3.start()
    time.sleep(1)

    #Launching the credential manager in a different thread to make things feel real
    t4 = threading.Thread(target=credential.start)
    t4.start()
    time.sleep(1)

    #Now we simulate that we are composing a server service for the ServerManager
    server.compose_service(**get_server_app_request().dictionarize())
    #...And launch it
    server.launch_service("server_123")
    time.sleep(0.5)# Again, for synch, this is just to help to read the logs in the correct order


    #Let's compose a service for the credential manager as well
    credential.compose_service(**get_cert_app_request().dictionarize())
    #...And of course, launch it
    credential.launch_service("cert_123")

    #We sleep here in order to let the servers spawn correctly...
    time.sleep(0.5)
    #to finally deploy the VPN...
    vpn.deploy()
예제 #15
0
    def __init__(self):

        self.manager = SystemStateFactory.generate_system_state_manager(
            "localhost:6379")
        self.manager.start()