Skip to content

Commit

Permalink
Removed unnecessary orchestration code on the Dashboard Server.
Browse files Browse the repository at this point in the history
The orchestration code is no longer necessary as now the Deployer will do all the wiring thanks to SeaCloudsPolicy
Adrián Nieto authored and kiuby88 committed Mar 16, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent cf9b453 commit 37a731b
Showing 29 changed files with 210 additions and 684 deletions.
14 changes: 3 additions & 11 deletions byon/files/seaclouds-catalog.bom
Original file line number Diff line number Diff line change
@@ -61,8 +61,6 @@ brooklyn.catalog:
deployer.port: 8081
sla.host: 127.0.0.1
sla.port: 1234
monitor.manager.host: 127.0.0.1
monitor.manager.port: 8170
monitor.grafana.host: 127.0.0.1
monitor.grafana.host: 3000
planner.host: 127.0.0.1
@@ -75,8 +73,6 @@ brooklyn.catalog:
DEPLOYER_PORT: $brooklyn:config("deployer.port")
SLA_HOST: $brooklyn:config("sla.host")
SLA_PORT: $brooklyn:config("sla.port")
MONITOR_HOST: $brooklyn:config("monitor.manager.host")
MONITOR_PORT: $brooklyn:config("monitor.manager.port")
GRAFANA_HOST: $brooklyn:config("monitor.grafana.host")
GRAFANA_PORT: $brooklyn:config("monitor.grafana.host")
PLANNER_HOST: $brooklyn:config("planner.host")
@@ -99,9 +95,9 @@ brooklyn.catalog:
deployer:
host: ${DEPLOYER_HOST}
port: ${DEPLOYER_PORT}
monitor.manager:
host: ${MONITOR_HOST}
port: ${MONITOR_PORT}
monitor.grafana:
host: ${GRAFANA_HOST}
port: ${GRAFANA_PORT}
sla:
host: ${SLA_HOST}
port: ${SLA_PORT}
@@ -333,8 +329,6 @@ brooklyn.catalog:
deployer.port: $brooklyn:component("deployer").attributeWhenReady("brooklynnode.webconsole.httpPort")
sla.host: $brooklyn:component("sla-core").attributeWhenReady("host.address")
sla.port: $brooklyn:component("sla-core").attributeWhenReady("http.port")
monitor.manager.host: $brooklyn:component("monitor-manager").attributeWhenReady("host.address")
monitor.manager.port: $brooklyn:component("monitor-manager").config("monitor.manager.port")
monitor.grafana.host: $brooklyn:component("grafana").attributeWhenReady("host.address")
monitor.grafana.port: $brooklyn:component("grafana").config("grafana.port")
planner.host: $brooklyn:component("planner").attributeWhenReady("host.address")
@@ -410,8 +404,6 @@ brooklyn.catalog:
deployer.port: $brooklyn:component("deployer").attributeWhenReady("brooklynnode.webconsole.httpPort")
sla.host: $brooklyn:component("sla-core").attributeWhenReady("host.address")
sla.port: $brooklyn:component("sla-core").attributeWhenReady("http.port")
monitor.manager.host: $brooklyn:component("monitor-manager").attributeWhenReady("host.address")
monitor.manager.port: $brooklyn:component("monitor-manager").config("monitor.manager.port")
monitor.grafana.host: $brooklyn:component("grafana").attributeWhenReady("host.address")
monitor.grafana.port: $brooklyn:component("grafana").config("grafana.port")
planner.host: $brooklyn:component("planner").attributeWhenReady("host.address")
3 changes: 0 additions & 3 deletions dashboard/config.yml
Original file line number Diff line number Diff line change
@@ -13,9 +13,6 @@ deployer:
port: ${DEPLOYER_PORT}
user: ${DEPLOYER_USER}
password: ${DEPLOYER_PASSWORD}
monitor.manager:
host: ${MONITOR_HOST}
port: ${MONITOR_PORT}
monitor.grafana:
host: ${GRAFANA_HOST}
port: ${GRAFANA_PORT}
Original file line number Diff line number Diff line change
@@ -69,14 +69,14 @@ protected SwaggerBundleConfiguration getSwaggerBundleConfiguration(DashboardConf
public void run(DashboardConfiguration configuration, Environment environment) throws Exception {
// Configuring HealthChecks
DashboardHealthCheck healthCheck = new DashboardHealthCheck(configuration.getDeployerProxy(),
configuration.getMonitorProxy(), configuration.getGrafanaProxy(), configuration.getSlaProxy(), configuration.getPlannerProxy());
configuration.getGrafanaProxy(), configuration.getSlaProxy(), configuration.getPlannerProxy());
environment.healthChecks().register(healthCheck.getName(), healthCheck);

// Registering REST API Endpoints
environment.jersey().register(new CoreResource(configuration.getDeployerProxy(),
configuration.getMonitorProxy(), configuration.getGrafanaProxy(), configuration.getPlannerProxy(),
configuration.getGrafanaProxy(), configuration.getPlannerProxy(),
configuration.getSlaProxy()));
environment.jersey().register(new DeployerResource(configuration.getDeployerProxy(), configuration.getMonitorProxy(), configuration.getSlaProxy(), configuration.getPlannerProxy()));
environment.jersey().register(new DeployerResource(configuration.getDeployerProxy(), configuration.getSlaProxy()));
environment.jersey().register(new MonitorResource(configuration.getDeployerProxy()));
environment.jersey().register(new PlannerResource(configuration.getPlannerProxy()));
environment.jersey().register(new SlaResource(configuration.getSlaProxy()));
Original file line number Diff line number Diff line change
@@ -39,14 +39,10 @@ public class DashboardConfiguration extends Configuration {
@Valid
@NotNull
private PlannerProxy planner = new PlannerProxy();

@Valid
@NotNull
private DeployerProxy deployer = new DeployerProxy();

@Valid
@NotNull
private MonitorProxy monitor = new MonitorProxy();

@Valid
@NotNull
@@ -75,7 +71,7 @@ public PlannerProxy getPlannerProxy() {
public void setPlannerProxy(PlannerProxy factory) {
planner = factory;
}

@JsonProperty("deployer")
public DeployerProxy getDeployerProxy() {
return deployer;
@@ -86,11 +82,6 @@ public void setDeployerProxy(DeployerProxy factory) {
deployer = factory;
}

@JsonProperty("monitor.manager")
public MonitorProxy getMonitorProxy() {
return monitor;
}

@JsonProperty("monitor.grafana")
public void setGrafanaProxy(GrafanaProxy factory) {
grafana = factory;
@@ -101,11 +92,6 @@ public GrafanaProxy getGrafanaProxy() {
return grafana;
}

@JsonProperty("monitor.manager")
public void setMonitorConfigProxy(MonitorProxy factory) {
monitor = factory;
}

@JsonProperty("sla")
public SlaProxy getSlaProxy() {
return sla;
Original file line number Diff line number Diff line change
@@ -32,7 +32,6 @@ public class DashboardHealthCheck extends HealthCheck {
private static final String NAME = "reachability";

private final DeployerProxy deployer;
private final MonitorProxy monitor;
private final SlaProxy sla;
private final PlannerProxy planner;
private final GrafanaProxy grafana;
@@ -47,9 +46,8 @@ private boolean portIsOpen(String ip, int port) {
}
}

public DashboardHealthCheck(DeployerProxy deployer, MonitorProxy monitor, GrafanaProxy grafana, SlaProxy sla, PlannerProxy planner){
public DashboardHealthCheck(DeployerProxy deployer, GrafanaProxy grafana, SlaProxy sla, PlannerProxy planner){
this.deployer = deployer;
this.monitor = monitor;
this.grafana = grafana;
this.sla = sla;
this.planner = planner;
@@ -67,9 +65,6 @@ protected Result check() throws Exception {
return Result.unhealthy("The Deployer endpoint is not ready");
}

if(!portIsOpen(monitor.getHost(), monitor.getPort())){
return Result.unhealthy("The Monitor endpoint is not ready");
}

if(!portIsOpen(grafana.getHost(), grafana.getPort())){
return Result.unhealthy("The Monitor endpoint is not ready");
Original file line number Diff line number Diff line change
@@ -18,8 +18,10 @@
package eu.seaclouds.platform.dashboard.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.io.BaseEncoding;
import eu.atos.sla.datamodel.IGuaranteeTerm;
import eu.atos.sla.parser.data.wsag.Agreement;
import eu.seaclouds.platform.dashboard.util.ObjectMapperHelpers;
import it.polimi.tower4clouds.rules.MonitoringRule;
import it.polimi.tower4clouds.rules.MonitoringRules;
import org.apache.brooklyn.rest.domain.ApplicationSummary;
@@ -29,27 +31,26 @@
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;

import javax.xml.bind.JAXBException;
import java.io.Serializable;
import java.util.*;

public class SeaCloudsApplicationData implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(SeaCloudsApplicationData.class);

private static final String YAML_DESCRIPTION_TAG = "description";
private static final String YAML_DESCRIPTION_TAG = "template_name";
private static final String YAML_TOPOLOGY_TEMPLATE_TAG = "topology_template";
private static final String YAML_GROUPS_TEMPLATE_TAG = "groups";
private static final String YAML_POLICIES_TAG = "policies";
private static final String YAML_MONITORING_INFORMATION_TAG = "monitoringInformation";
private static final String YAML_AGREEMENT_TAG = "sla_gen_info";

private static final String YAML_ID_TAG = "id";

private static final String YAML_SEACLOUDS_POLICY_TAG = "seaclouds_configuration_policy";
private static final String YAML_SEACLOUDS_POLICY_CONFIGURATION_TAG = "configuration";
private static final String YAML_SEACLOUDS_AGREEMENT_TAG = "slaAgreement";
private static final String YAML_SEACLOUDS_RULES_TAG = "t4cRules";

private final String seaCloudsApplicationId;
private final String name;
private final Map toscaDamMap;
private final String monitoringRulesTemplateId;
private final String agreementTemplateId;
private String deployerApplicationId;
private Set<String> monitoringRulesIds;
private String agreementId;
@@ -58,60 +59,54 @@ public class SeaCloudsApplicationData implements Serializable {
private IGuaranteeTerm.GuaranteeTermStatusEnum agreementStatus;


public SeaCloudsApplicationData(String toscaDam) {
this.seaCloudsApplicationId = UUID.randomUUID().toString();
Yaml yamlParser = new Yaml();
this.toscaDamMap = (Map) yamlParser.load(toscaDam);
this.name = extractName(this.toscaDamMap);
this.monitoringRulesTemplateId = extractMonitoringRulesemplateId(this.toscaDamMap);
this.agreementTemplateId = extractAgreementTemplateId(this.toscaDamMap);

public SeaCloudsApplicationData(String toscaDam) throws JAXBException {
this((Map) new Yaml().load(toscaDam));
}

SeaCloudsApplicationData(Map toscaDamMap) {
SeaCloudsApplicationData(Map toscaDamMap) throws JAXBException {
this.seaCloudsApplicationId = UUID.randomUUID().toString();
this.toscaDamMap = toscaDamMap;
this.name = extractName(this.toscaDamMap);
this.monitoringRulesTemplateId = extractMonitoringRulesemplateId(this.toscaDamMap);
this.agreementTemplateId = extractAgreementTemplateId(this.toscaDamMap);

this.agreementId = extractAgreementId(this.toscaDamMap);
this.monitoringRulesIds = extractMonitoringRulesIds(this.toscaDamMap);
}

static String extractName(Map toscaDamMap) {
return (String) toscaDamMap.get(YAML_DESCRIPTION_TAG);
}

static String extractAgreementTemplateId(Map toscaDamMap) {
static String extractAgreementId(Map toscaDamMap) throws JAXBException {
Map topologyTemplate = (Map) toscaDamMap.get(YAML_TOPOLOGY_TEMPLATE_TAG);
Map groups = (Map) topologyTemplate.get(YAML_GROUPS_TEMPLATE_TAG);
Map monitoringInformation = (Map) groups.get(YAML_AGREEMENT_TAG);

if(monitoringInformation != null){
Map policies = (Map)((List) monitoringInformation.get(YAML_POLICIES_TAG)).get(0);
return (String) policies.get(YAML_ID_TAG);
} else{
LOG.warn("This TOSCA doesn't contain any SLA Agreement Template ID");
return null;
}
Map seaCloudsConfigurationMember = (Map) groups.get(YAML_SEACLOUDS_POLICY_TAG);
Map seaCloudsConfigurationPolicy = (Map) ((Map)((List) seaCloudsConfigurationMember.get(YAML_POLICIES_TAG)).get(0)).get(YAML_SEACLOUDS_POLICY_CONFIGURATION_TAG);

String agreementB64String = (String) seaCloudsConfigurationPolicy.get(YAML_SEACLOUDS_AGREEMENT_TAG);
String agreementString = new String(BaseEncoding.base64().decode(agreementB64String));
Agreement agreement = ObjectMapperHelpers.XmlToObject(agreementString, Agreement.class);
return agreement.getAgreementId();
}

static String extractMonitoringRulesemplateId(Map toscaDamMap) {
static Set<String> extractMonitoringRulesIds(Map toscaDamMap) throws JAXBException {
Set<String> returnSet = new HashSet<>();

Map topologyTemplate = (Map) toscaDamMap.get(YAML_TOPOLOGY_TEMPLATE_TAG);
Map groups = (Map) topologyTemplate.get(YAML_GROUPS_TEMPLATE_TAG);
Map slaGenInfo = (Map) groups.get(YAML_MONITORING_INFORMATION_TAG);

if(slaGenInfo != null){
Map policies = (Map) ((List) slaGenInfo.get(YAML_POLICIES_TAG)).get(0);
return (String) policies.get(YAML_ID_TAG);
} else{
LOG.warn("This TOSCA doesn't contain any MonitoringRules ID");
return null;
}
}
Map seaCloudsConfigurationMember = (Map) groups.get(YAML_SEACLOUDS_POLICY_TAG);
Map seaCloudsConfigurationPolicy = (Map) ((Map)((List) seaCloudsConfigurationMember.get(YAML_POLICIES_TAG)).get(0)).get(YAML_SEACLOUDS_POLICY_CONFIGURATION_TAG);

String rulesB64String = (String) seaCloudsConfigurationPolicy.get(YAML_SEACLOUDS_RULES_TAG);
String rulesString = new String(BaseEncoding.base64().decode(rulesB64String));
MonitoringRules rules = ObjectMapperHelpers.XmlToObject(rulesString, MonitoringRules.class);


for(MonitoringRule rule : rules.getMonitoringRules()){
returnSet.add(rule.getId());
}

return returnSet;
}

public void setDeployerApplicationId(ApplicationSummary application) {
this.deployerApplicationId = application.getId();
}
@@ -143,16 +138,6 @@ public String getName() {
return name;
}

@JsonProperty
public String getMonitoringRulesTemplateId() {
return monitoringRulesTemplateId;
}

@JsonProperty
public String getAgreementTemplateId() {
return agreementTemplateId;
}

@JsonProperty
public Set<String> getMonitoringRulesIds() {
return monitoringRulesIds;
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
package eu.seaclouds.platform.dashboard.proxy;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.constraints.Max;
@@ -40,7 +41,7 @@ public abstract class AbstractProxy {

private String user;
private String password;
private Client jerseyClient = ClientBuilder.newClient();
private Client jerseyClient;

@JsonProperty
public String getHost() {
@@ -83,6 +84,16 @@ public void setPassword(String password) {
}

public Client getJerseyClient() {

if(jerseyClient == null){
jerseyClient = ClientBuilder.newClient();

if(user != null && password != null){
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(getUser(), getPassword());
jerseyClient.register(feature);
}
}

return jerseyClient;
}

Loading

0 comments on commit 37a731b

Please sign in to comment.