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);
}
}
}
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);
}
Aggregations