Search in sources :

Example 1 with ManagedFilesystemItem

use of org.platformlayer.ops.filesystem.ManagedFilesystemItem in project platformlayer by platformlayer.

the class LdapDomainController method addChildren.

@Override
protected void addChildren() throws OpsException {
    LdapDomain ldapDomain = OpsContext.get().getInstance(LdapDomain.class);
    String hostName = ldapDomain.organizationName;
    LdapDN ldapBase = LdapServerUtilities.createBaseDN(hostName);
    File dataRoot = new File("/var/ldap/data");
    File dataDir = new File(dataRoot, hostName);
    String ldapBaseOrganization = hostName;
    ManagedFilesystemItem directory = ManagedDirectory.build(dataDir, "0700").setGroup("openldap").setOwner("openldap");
    addChild(directory);
    HdbDatabaseEntry db = buildDatabase(ldapBase, dataDir, hostName);
    addChild(db);
    OrganizationLdapEntry organization = buildOrganization(ldapBase, ldapBaseOrganization);
    organization.setTop(true);
    addChild(organization);
    String ldapAdminPassword = LdapPasswords.getLdapPasswordEncoded(ldapDomain.adminPassword.plaintext());
    OrganizationalRoleLdapEntry organizationalRole = buildOrganizationalRole(ldapBase, LdapAttributes.MANAGER_CN, "LDAP Administrator", ldapAdminPassword);
    addChild(organizationalRole);
    OrganizationalUnitLdapEntry users = buildOrganizationUnit(ldapBase, LdapAttributes.LDAP_USERS_CONTAINER_OU, "Users");
    addChild(users);
    OrganizationalUnitLdapEntry groups = buildOrganizationUnit(ldapBase, LdapAttributes.LDAP_GROUPS_CONTAINER_OU, "Groups");
    addChild(groups);
}
Also used : HdbDatabaseEntry(org.platformlayer.service.openldap.ops.ldap.HdbDatabaseEntry) OrganizationLdapEntry(org.platformlayer.service.openldap.ops.ldap.OrganizationLdapEntry) LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) OrganizationalUnitLdapEntry(org.platformlayer.service.openldap.ops.ldap.OrganizationalUnitLdapEntry) ManagedFilesystemItem(org.platformlayer.ops.filesystem.ManagedFilesystemItem) File(java.io.File) OrganizationalRoleLdapEntry(org.platformlayer.service.openldap.ops.ldap.OrganizationalRoleLdapEntry) LdapDN(org.platformlayer.ops.ldap.LdapDN)

Example 2 with ManagedFilesystemItem

use of org.platformlayer.ops.filesystem.ManagedFilesystemItem in project platformlayer by platformlayer.

the class PersistIptablesScripts method addChildren.

@Override
protected void addChildren() throws OpsException {
    addChild(ManagedDirectory.build(BASE_DIR, "0644"));
    addChild(SimpleFile.build(getClass(), new File("/etc/network/if-pre-up.d/iptables-lockdown")).setFileMode("755").setUpdateAction(new FilesystemAction() {

        @Override
        public void execute(OpsTarget target, ManagedFilesystemItem managedFilesystemItem) throws OpsException {
            if (managedFilesystemItem.getNewFileWasCreated()) {
                // Set the parameters the ifup sets
                CommandEnvironment env = new CommandEnvironment();
                env.put("MODE", "start");
                env.put("IFACE", "--all");
                env.put("ADDRFAM", "meta");
                Command runLockdown = Command.build("/etc/network/if-pre-up.d/iptables-lockdown");
                runLockdown.setEnvironment(env);
                target.executeCommand(runLockdown);
            }
        }
    }));
    addChild(SimpleFile.build(getClass(), new File("/etc/network/if-up.d/iptables-ifup")).setFileMode("755"));
}
Also used : OpsTarget(org.platformlayer.ops.OpsTarget) Command(org.platformlayer.ops.Command) CommandEnvironment(org.platformlayer.ops.CommandEnvironment) ManagedFilesystemItem(org.platformlayer.ops.filesystem.ManagedFilesystemItem) File(java.io.File) SimpleFile(org.platformlayer.ops.filesystem.SimpleFile) FilesystemAction(org.platformlayer.ops.filesystem.FilesystemAction)

Aggregations

File (java.io.File)2 ManagedFilesystemItem (org.platformlayer.ops.filesystem.ManagedFilesystemItem)2 Command (org.platformlayer.ops.Command)1 CommandEnvironment (org.platformlayer.ops.CommandEnvironment)1 OpsTarget (org.platformlayer.ops.OpsTarget)1 FilesystemAction (org.platformlayer.ops.filesystem.FilesystemAction)1 SimpleFile (org.platformlayer.ops.filesystem.SimpleFile)1 LdapDN (org.platformlayer.ops.ldap.LdapDN)1 LdapDomain (org.platformlayer.service.openldap.model.LdapDomain)1 HdbDatabaseEntry (org.platformlayer.service.openldap.ops.ldap.HdbDatabaseEntry)1 OrganizationLdapEntry (org.platformlayer.service.openldap.ops.ldap.OrganizationLdapEntry)1 OrganizationalRoleLdapEntry (org.platformlayer.service.openldap.ops.ldap.OrganizationalRoleLdapEntry)1 OrganizationalUnitLdapEntry (org.platformlayer.service.openldap.ops.ldap.OrganizationalUnitLdapEntry)1