Search in sources :

Example 11 with EndpointInfo

use of org.platformlayer.core.model.EndpointInfo in project platformlayer by platformlayer.

the class EndpointDnsRecord method handler.

@Handler
public void handler() throws OpsException {
    PublicEndpointBase endpoint = endpointProvider.get();
    if (OpsContext.isConfigure()) {
        // Create a DNS record
        Tag parentTag = Tag.buildParentTag(endpoint.getKey());
        List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(endpoint.getTags(), destinationPort);
        if (endpoints.isEmpty()) {
            throw new OpsException("Cannot find endpoint for port: " + destinationPort);
        }
        DnsRecord record = new DnsRecord();
        record.setDnsName(dnsName);
        for (EndpointInfo endpointInfo : endpoints) {
            record.getAddress().add(endpointInfo.publicIp);
        }
        record.getTags().add(parentTag);
        record.setKey(PlatformLayerKey.fromId(dnsName));
        try {
            platformLayerClient.putItemByTag((ItemBase) record, parentTag);
        } catch (PlatformLayerClientException e) {
            throw new OpsException("Error registering persistent instance", e);
        }
    }
}
Also used : PlatformLayerClientException(org.platformlayer.PlatformLayerClientException) EndpointInfo(org.platformlayer.core.model.EndpointInfo) OpsException(org.platformlayer.ops.OpsException) Tag(org.platformlayer.core.model.Tag) PublicEndpointBase(org.platformlayer.core.model.PublicEndpointBase) DnsRecord(org.platformlayer.dns.model.DnsRecord) Handler(org.platformlayer.ops.Handler)

Example 12 with EndpointInfo

use of org.platformlayer.core.model.EndpointInfo in project platformlayer by platformlayer.

the class GitServerController method buildTemplateModel.

@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
    LdapDomain ldapDomain = getLdapDomain();
    LdapService ldapService = getLdapService();
    LdapDN organizationDN = LdapDN.fromDomainName(ldapDomain.organizationName);
    LdapDN allUsersDN = organizationDN.childDN("ou", "Users");
    LdapDN managerDN = organizationDN.childDN("cn", "Manager");
    LdapDN groupsDN = organizationDN.childDN("ou", "Groups");
    LdapDN gitUsersDN = groupsDN.childDN("cn", "Git");
    // String authLdapUrl = "ldap://192.168.192.67:389/ou=Users,dc=com,dc=fathomscale?uid";
    // String authLDAPBindDN = "cn=Manager,dc=com,dc=fathomscale";
    // String authLDAPBindPassword = "adminsecret";
    // String requireLdapGroup = "cn=Git,ou=Groups,dc=com,dc=fathomscale";
    int port = 389;
    List<EndpointInfo> endpoints = EndpointInfo.findEndpoints(ldapService.getTags(), port);
    EndpointInfo ldapEndpoint = EndpointChooser.preferIpv4().choose(endpoints);
    if (ldapEndpoint == null) {
        throw new OpsException("Cannot find suitable LDAP endpoint");
    }
    // TODO: Maybe we should just reference an LdapGroup
    // TODO: It sucks that we're logging in here as the Manager account
    // LdapGroup -> LdapDomain -> LdapService
    String authLdapUrl = "ldap://" + ldapEndpoint.publicIp + ":389/" + allUsersDN.toLdifEncoded() + "?uid";
    String authLDAPBindDN = managerDN.toLdifEncoded();
    String authLDAPBindPassword = ldapDomain.adminPassword.plaintext();
    String requireLdapGroup = gitUsersDN.toLdifEncoded();
    model.put("AuthLDAPURL", authLdapUrl);
    model.put("AuthLDAPBindDN", authLDAPBindDN);
    model.put("AuthLDAPBindPassword", authLDAPBindPassword);
    model.put("requireLdapGroup", requireLdapGroup);
}
Also used : EndpointInfo(org.platformlayer.core.model.EndpointInfo) OpsException(org.platformlayer.ops.OpsException) LdapDomain(org.platformlayer.service.openldap.model.LdapDomain) LdapService(org.platformlayer.service.openldap.model.LdapService) LdapDN(org.platformlayer.ops.ldap.LdapDN) PublicEndpoint(org.platformlayer.ops.networks.PublicEndpoint)

Aggregations

EndpointInfo (org.platformlayer.core.model.EndpointInfo)12 OpsException (org.platformlayer.ops.OpsException)7 TagChanges (org.platformlayer.core.model.TagChanges)4 OpsProvider (org.platformlayer.ops.OpsProvider)4 Tagger (org.platformlayer.ops.tagger.Tagger)4 InetSocketAddress (java.net.InetSocketAddress)3 Handler (org.platformlayer.ops.Handler)3 PlatformLayerClient (org.platformlayer.PlatformLayerClient)2 UntypedItem (org.platformlayer.common.UntypedItem)2 ItemBase (org.platformlayer.core.model.ItemBase)2 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)2 PublicEndpointBase (org.platformlayer.core.model.PublicEndpointBase)2 DnsRecord (org.platformlayer.dns.model.DnsRecord)2 ClientAction (com.fathomdb.cli.output.ClientAction)1 InetAddress (java.net.InetAddress)1 List (java.util.List)1 Map (java.util.Map)1 PlatformLayerClientException (org.platformlayer.PlatformLayerClientException)1 AddressModel (org.platformlayer.core.model.AddressModel)1 Tag (org.platformlayer.core.model.Tag)1