Esempio n. 1
0
def openchangedb_provision(lp, firstorg=None, firstou=None, mapistore=None):
    """Create the OpenChange database.

    :param lp: Loadparm context
    :param firstorg: First Organization
    :param firstou: First Organization Unit
    :param mapistore: The public folder store type (fsocpf, sqlite, etc)
    """
    names = guess_names_from_smbconf(lp, firstorg, firstou)
    
    print "Setting up openchange db"
    openchange_ldb = mailbox.OpenChangeDB(openchangedb_url(lp))
    openchange_ldb.setup()

    print "Adding root DSE"
    openchange_ldb.add_rootDSE(names.ocserverdn, names.firstorg, names.firstou)

    # Add a server object
    # It is responsible for holding the GlobalCount identifier (48 bytes)
    # and the Replica identifier
    openchange_ldb.add_server(names.ocserverdn, names.netbiosname, names.firstorg, names.firstou)

    print "[+] Public Folders"
    print "==================="
    openchange_ldb.add_public_folders(names)
Esempio n. 2
0
def openchangedb_provision(lp, firstorg=None, firstou=None, mapistore=None):
    """Create the OpenChange database.

    :param lp: Loadparm context
    :param firstorg: First Organization
    :param firstou: First Organization Unit
    :param mapistore: The public folder store type (fsocpf, sqlite, etc)
    """
    names = guess_names_from_smbconf(lp, firstorg, firstou)

    print "Setting up openchange db"
    openchange_ldb = mailbox.OpenChangeDB(openchangedb_url(lp))
    openchange_ldb.setup()

    print "Adding root DSE"
    openchange_ldb.add_rootDSE(names.ocserverdn, names.firstorg, names.firstou)

    # Add a server object
    # It is responsible for holding the GlobalCount identifier (48 bytes)
    # and the Replica identifier
    openchange_ldb.add_server(names.ocserverdn, names.netbiosname,
                              names.firstorg, names.firstou)

    print "[+] Public Folders"
    print "==================="
    openchange_ldb.add_public_folders(names)
Esempio n. 3
0
def openchangedb_migrate(lp):
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri)
        if openchangedb.migrate():
            print "Migration openchange db done"
    else:
        print "Only OpenchangeDB with MySQL as backend needs migration"
Esempio n. 4
0
def openchangedb_migrate(lp):
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri)
        if openchangedb.migrate():
            print "Migration openchange db done"
    else:
        print "Only OpenchangeDB with MySQL as backend needs migration"
Esempio n. 5
0
def openchangedb_new_organization(names, lp):
    """Create organization, servers and public folders in openchange db

    :param names: Provision names object
    :param lp: Loadparm context
    """
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri, find_setup_dir())
    else:
        openchangedb = mailbox.OpenChangeDB(uri)

    openchangedb.add_server(names)
    openchangedb.add_public_folders(names)
Esempio n. 6
0
def openchangedb_new_organization(names, lp):
    """Create organization, servers and public folders in openchange db

    :param names: Provision names object
    :param lp: Loadparm context
    """
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri, find_setup_dir())
    else:
        openchangedb = mailbox.OpenChangeDB(uri)

    openchangedb.add_server(names)
    openchangedb.add_public_folders(names)
Esempio n. 7
0
def openchangedb_deprovision(names, lp, mapistore=None):
    """Removed the OpenChange database.

    :param names: Provision names object
    :param lp: Loadparm context
    :param mapistore: The public folder store type (fsocpf, sqlite, etc)
    """

    print "Removing openchange db"
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri)
    else:
        openchangedb = mailbox.OpenChangeDB(uri)
    openchangedb.remove()
Esempio n. 8
0
def openchangedb_deprovision(names, lp, mapistore=None):
    """Removed the OpenChange database.

    :param names: Provision names object
    :param lp: Loadparm context
    :param mapistore: The public folder store type (fsocpf, sqlite, etc)
    """

    print "Removing openchange db"
    uri = openchangedb_url(lp)
    if uri.startswith('mysql'):
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri)
    else:
        openchangedb = mailbox.OpenChangeDB(uri)
    openchangedb.remove()
Esempio n. 9
0
def openchangedb_provision(names, lp, uri=None):
    """Create the OpenChange database.

    :param names: Provision names object
    :param lp: Loadparm context
    :param uri: Openchangedb destination, by default will be a ldb file inside
    private samba directory. You can specify a mysql connection string like
    mysql://user:passwd@host/db_name to use openchangedb with mysql backend
    """

    print "Setting up openchange db"
    if uri is None or len(uri) == 0 or uri.startswith('ldb'):  # LDB backend
        openchangedb = mailbox.OpenChangeDB(openchangedb_url(lp))
    elif uri.startswith('mysql'):  # MySQL backend
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri, find_setup_dir())
    else:
        print "[!] error provisioning openchangedb: Unknown uri `%s`" % uri
        return
    openchangedb.setup(names)
    openchangedb.add_server(names)
    openchangedb.add_public_folders(names)
Esempio n. 10
0
def openchangedb_provision(names, lp, uri=None):
    """Create the OpenChange database.

    :param names: Provision names object
    :param lp: Loadparm context
    :param uri: Openchangedb destination, by default will be a ldb file inside
    private samba directory. You can specify a mysql connection string like
    mysql://user:passwd@host/db_name to use openchangedb with mysql backend
    """

    print "Setting up openchange db"
    if uri is None or len(uri) == 0 or uri.startswith('ldb'):  # LDB backend
        openchangedb = mailbox.OpenChangeDB(openchangedb_url(lp))
    elif uri.startswith('mysql'):  # MySQL backend
        openchangedb = mailbox.OpenChangeDBWithMysqlBackend(uri, find_setup_dir())
    else:
        print "[!] error provisioning openchangedb: Unknown uri `%s`" % uri
        return
    openchangedb.setup(names)
    openchangedb.add_server(names)
    openchangedb.add_public_folders(names)