Skip to content

Commit

Permalink
Use Spring Boot based configuration for the agents
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Schrijver committed May 29, 2018
1 parent 365e3de commit 8f2ef87
Show file tree
Hide file tree
Showing 78 changed files with 1,562 additions and 1,211 deletions.
137 changes: 0 additions & 137 deletions cosmic-agent/bindir/cosmic-setup-agent

This file was deleted.

32 changes: 32 additions & 0 deletions cosmic-agent/bindir/cosmic-setup-agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/python

from optparse import OptionParser

import os
import yaml

if __name__ == '__main__':
parser = OptionParser()
parser.add_option("-m", "--host", dest="mgt", help="Management server hostname or IP-Address")
parser.add_option("-z", "--zone", dest="zone", help="zone id")
parser.add_option("-p", "--pod", dest="pod", help="pod id")
parser.add_option("-c", "--cluster", dest="cluster", help="cluster id")
parser.add_option("-g", "--guid", dest="guid", help="guid")

(options, args) = parser.parse_args()

config = ''

with open('/etc/cosmic/agent/application.yml', 'r') as f:
config = yaml.load(f)
config['cosmic']['guid'] = options.guid
config['cosmic']['hosts'] = [options.mgt]
config['cosmic']['cluster'] = options.cluster
config['cosmic']['pod'] = options.pod
config['cosmic']['zone'] = options.zone
config['cosmic']['localstorage']['uuid'] = options.guid

with open('/etc/cosmic/agent/application.yml', 'w') as f:
yaml.dump(config, f, default_flow_style=False)

os.system("sudo systemctl start cosmic-agent")
134 changes: 0 additions & 134 deletions cosmic-agent/conf/agent.properties

This file was deleted.

27 changes: 1 addition & 26 deletions cosmic-agent/src/main/java/com/cloud/agent/AgentApplication.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package com.cloud.agent;

import com.cloud.agent.service.AgentShell;

import javax.naming.ConfigurationException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -18,25 +10,8 @@
excludeFilters = {
@ComponentScan.Filter(type = FilterType.REGEX, pattern = "(?!com.cloud.agent.service).*")
})
public class AgentApplication implements CommandLineRunner {
private static final Logger s_logger = LoggerFactory.getLogger(AgentApplication.class);

@Autowired
AgentShell agentShell;

public class AgentApplication {
public static void main(final String[] args) {
SpringApplication.run(AgentApplication.class, args);
}

@Override
public void run(final String... strings) throws Exception {
s_logger.info("Starting Cosmic Agent...");

try {
agentShell.init(strings);
agentShell.start();
} catch (final ConfigurationException e) {
s_logger.error(e.getMessage());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.cloud.agent.resource;

import com.cloud.common.agent.IAgentControl;
import com.cloud.legacymodel.communication.answer.Answer;
import com.cloud.legacymodel.communication.command.Command;
import com.cloud.legacymodel.communication.command.PingCommand;
import com.cloud.legacymodel.communication.command.StartupCommand;
import com.cloud.model.enumeration.HostType;

import javax.naming.ConfigurationException;
import java.util.Map;

public interface AgentResource {
String getName();

void setName(String name);

boolean configure(Map<String, Object> params) throws ConfigurationException;

boolean start();

boolean stop();

HostType getType();

StartupCommand[] initialize();

PingCommand getCurrentStatus(long id);

Answer executeRequest(Command cmd);

void disconnected();

IAgentControl getAgentControl();

void setAgentControl(IAgentControl agentControl);
}
Loading

0 comments on commit 8f2ef87

Please sign in to comment.