def new_connection(self, options, flags, transport, from_dnstr, sched):
        """Set up a new connection for the DSA based on input
        parameters.  Connection will be added to the DSA
        connect_table and will be marked as "to be added" pending
        a call to commit_connections()
        """
        dnstr = "CN=%s," % str(uuid.uuid4()) + self.dsa_dnstr

        connect = NTDSConnection(dnstr)
        connect.to_be_added = True
        connect.enabled = True
        connect.from_dnstr = from_dnstr
        connect.options = options
        connect.flags = flags

        if transport is not None:
            connect.transport_dnstr = transport.dnstr

        if sched is not None:
            connect.schedule = sched
        else:
            # Create schedule.  Attribute valuse set according to MS-TECH
            # intrasite connection creation document
            connect.schedule = drsblobs.schedule()

            connect.schedule.size = 188
            connect.schedule.bandwidth = 0
            connect.schedule.numberOfSchedules = 1

            header = drsblobs.scheduleHeader()
            header.type = 0
            header.offset = 20

            connect.schedule.headerArray = [ header ]

            # 168 byte instances of the 0x01 value.  The low order 4 bits
            # of the byte equate to 15 minute intervals within a single hour.
            # There are 168 bytes because there are 168 hours in a full week
            # Effectively we are saying to perform replication at the end of
            # each hour of the week
            data = drsblobs.scheduleSlots()
            data.slots = [ 0x01 ] * 168

            connect.schedule.dataArray = [ data ]

        self.add_connection(dnstr, connect);
        return connect
dataset/ETHPy150Open byt3bl33d3r/pth-toolkit/lib/python2.7/site-packages/samba/kcc_utils.py/DirectoryServiceAgent.new_connection/original