def instantiate_h2hOutboundTransaction(loop, ip_addr, dst_id):
    import yaml, CETPSecurity, ConnectionTable, PolicyManager

    cesid = "cesa.lte."
    cetp_policies = "config_cesa/cetp_policies.json"
    filename = "config_cesa/config_cesa_ct.yaml"
    config_file = open(filename)
    ces_conf = yaml.load(config_file)
    ces_params = ces_conf['CESParameters']
    conn_table = ConnectionTable.ConnectionTable()
    cetpstate_mgr = ConnectionTable.CETPStateTable(
    )  # Records the established CETP transactions (both H2H & C2C). Required for preventing the re-allocation already in-use SST & DST (in CETP transaction).
    cetp_security = CETPSecurity.CETPSecurity(loop, conn_table, ces_params)
    interfaces = PolicyManager.FakeInterfaceDefinition(cesid)
    policy_mgr = PolicyManager.PolicyManager(
        cesid, policy_file=cetp_policies
    )  # Shall ideally fetch the policies from Policy Management System (of Hassaan)    - And will be called, policy_sys_agent
    host_register = PolicyManager.HostRegister()

    h2h = H2HTransactionOutbound(loop=loop, cb=None, host_ip=ip_addr, src_id="", dst_id=dst_id, l_cesid="cesa.lte.", r_cesid="cesblte.", cetp_h2h=None, \
                                                ces_params=ces_params, policy_mgr=policy_mgr, cetpstate_mgr=cetpstate_mgr, host_register=host_register, \
                                                conn_table=conn_table, interfaces=interfaces, cetp_security=cetp_security)
    cb_args = ("SomeQ", ("10.0.3.111", 55443))
    cb = (test_cb, cb_args)
    h2h.cb = cb

    return h2h
def getLocalCETP(loop):
    import yaml, CETPSecurity, ConnectionTable, PolicyManager

    cesid                  = "cesa.lte."
    cetp_policies          = "config_cesa/cetp_policies.json"
    filename               = "config_cesa/config_cesa_ct.yaml"
    config_file            = open(filename)
    ces_conf               = yaml.load(config_file)
    ces_params             = ces_conf['CESParameters']
    conn_table             = ConnectionTable.ConnectionTable()
    cetpstate_mgr          = ConnectionTable.CETPStateTable()                                       # Records the established CETP transactions (both H2H & C2C). Required for preventing the re-allocation already in-use SST & DST (in CETP transaction).
    cetp_security          = CETPSecurity.CETPSecurity(loop, conn_table, ces_params)
    interfaces             = PolicyManager.FakeInterfaceDefinition(cesid)
    policy_mgr             = PolicyManager.PolicyManager(cesid, policy_file=cetp_policies)          # Shall ideally fetch the policies from Policy Management System (of Hassaan)    - And will be called, policy_sys_agent
    host_register          = PolicyManager.HostRegister()
    #cetp_mgr               = cetpManager.CETPManager(cetp_policies, cesid, ces_params, loop=loop)
    cetp_mgr               = MockCETPManager()
    local_h2h              = CETPH2HLocal(l_cesid=cesid, cetpstate_mgr=cetpstate_mgr, policy_mgr=policy_mgr, cetp_mgr=cetp_mgr, \
                                         cetp_security=cetp_security, host_register=host_register, conn_table=conn_table)
    return local_h2h
def instantiate_h2hInboundTransaction(sstag, dstag):
    import yaml, CETPSecurity, ConnectionTable, PolicyManager

    cesid = "cesb.lte."
    cetp_policies = "config_cesb/cetp_policies.json"
    filename = "config_cesb/config_cesb_ct.yaml"
    config_file = open(filename)
    ces_conf = yaml.load(config_file)
    ces_params = ces_conf['CESParameters']
    conn_table = ConnectionTable.ConnectionTable()
    cetpstate_mgr = ConnectionTable.CETPStateTable(
    )  # Records the established CETP transactions (both H2H & C2C). Required for preventing the re-allocation already in-use SST & DST (in CETP transaction).
    cetp_security = CETPSecurity.CETPSecurity(loop, conn_table, ces_params)
    interfaces = PolicyManager.FakeInterfaceDefinition(cesid)
    policy_mgr = PolicyManager.PolicyManager(
        cesid, policy_file=cetp_policies
    )  # Shall ideally fetch the policies from Policy Management System (of Hassaan)    - And will be called, policy_sys_agent
    host_register = PolicyManager.HostRegister()

    ih2h = H2HTransactionInbound(sstag=sstag, dstag=dstag, l_cesid=cesid, r_cesid="cesa.lte.", policy_mgr=policy_mgr, cetpstate_mgr=cetpstate_mgr, \
                                 interfaces=interfaces, conn_table=conn_table, cetp_security=cetp_security, ces_params=ces_params)
    return ih2h
Beispiel #4
0
 def create(self, data):
     connection = ConnectionTable(data)
     cursor = self.db.query().insert(connection).execute()
     return cursor.lastrowid