use of org.platformlayer.ops.supervisor.StandardService in project platformlayer by platformlayer.
the class StandardServiceInstance method addChildren.
@Override
protected void addChildren() throws OpsException {
final StandardTemplateData template = getTemplate();
File instanceDir = template.getInstanceDir();
addChild(MetricsInstance.class);
String user = template.getUser();
String group = template.getGroup();
addChild(ManagedDirectory.build(instanceDir, "0700").setOwner(user).setGroup(group));
addChild(ManagedDirectory.build(template.getConfigDir(), "0700").setOwner(user).setGroup(group));
addConfigurationFile(template);
addLogFile(template);
addExtraFiles();
{
StandardService service = addChild(StandardService.class);
Command command = template.getCommand();
service.command = OpsProvider.of(command);
Map<String, String> env = template.getEnvironment();
service.environment = Providers.of(env);
service.instanceDir = instanceDir;
service.key = template.getServiceKey();
service.owner = template.getModel().getKey();
service.matchExecutableName = template.getMatchExecutableName();
}
if (template.shouldCreateKeystore()) {
createKeystore(template);
}
}
use of org.platformlayer.ops.supervisor.StandardService in project platformlayer by platformlayer.
the class LxcInstanceController method addChildren.
@Override
protected void addChildren() throws OpsException {
final DirectInstance model = OpsContext.get().getInstance(DirectInstance.class);
CloudInstanceMapper instance;
{
instance = injected(CloudInstanceMapper.class);
instance.instance = OpsContext.get().getInstance(DirectInstance.class);
addChild(instance);
}
instance.addChild(ManagedDirectory.build(getInstanceDir(), "700"));
// TODO: If we're not going to assign an IPV4 redirect, we might not need this
final Provider<AddressModel> address4;
{
NetworkAddressPoolAssignment provider = instance.addChild(NetworkAddressPoolAssignment.class);
provider.holder = model.getKey();
provider.poolProvider = DirectCloudUtils.getPrivateAddressPool4();
address4 = provider;
}
final Provider<AddressModel> address6;
{
NetworkAddressPoolAssignment provider = instance.addChild(NetworkAddressPoolAssignment.class);
provider.holder = model.getKey();
provider.poolProvider = directCloudHelpers.getAddressPool6();
address6 = provider;
}
// {
// NetworkTunDevice tun = injected(NetworkTunDevice.class);
// tun.interfaceName = getEthernetDeviceName();
// tun.bridgeName = Providers.getProperty(assignNetworkAddress, "bridge");
// instance.addChild(tun);
// }
{
DownloadImage download = injected(DownloadImage.class);
download.imageFile = new File(getInstanceDir(), "rootfs");
download.recipeKey = model.recipeId;
download.imageFormats = Collections.singletonList(ImageFormat.Tar);
instance.addChild(download);
}
{
LxcBootstrap bootstrap = injected(LxcBootstrap.class);
bootstrap.address4 = address4;
bootstrap.address6 = address6;
bootstrap.lxcId = id;
bootstrap.instanceDir = instanceDir;
try {
bootstrap.sshPublicKey = OpenSshUtils.readSshPublicKey(model.sshPublicKey);
} catch (IOException e) {
throw new OpsException("Error deserializing SSH key", e);
}
bootstrap.hostname = model.hostname;
instance.addChild(bootstrap);
}
InstanceScript script;
{
script = instance.addChild(InstanceScript.class);
script.filePath = new File(DirectHostController.LXC_INSTANCE_DIR, id);
String key = "lxc-" + id;
script.key = key;
script.addresses.add(address4);
script.addresses.add(address6);
// script.hostPrimaryInterface = hostModel.publicInterface;
Command command = Command.build("lxc-start");
command.addLiteral("--name").addQuoted(id);
script.launchInstanceCommand = command;
}
{
// ManagedSupervisordInstance service = instance.addChild(ManagedSupervisordInstance.class);
StandardService service = instance.addChild(StandardService.class);
script.configure(model, service);
}
{
OpsProvider<TagChanges> tagChanges = new OpsProvider<TagChanges>() {
@Override
public TagChanges get() {
TagChanges tagChanges = new TagChanges();
tagChanges.addTags.add(Tag.INSTANCE_KEY.build(model.getKey()));
AddressModel ipv4 = address4.get();
AddressModel ipv6 = address6.get();
if (ipv4 != null) {
tagChanges.addTags.add(Tag.NETWORK_ADDRESS.build(ipv4));
}
if (ipv6 != null) {
tagChanges.addTags.add(Tag.NETWORK_ADDRESS.build(ipv6));
}
return tagChanges;
}
};
instance.addChild(Tagger.build(model, tagChanges));
}
}
use of org.platformlayer.ops.supervisor.StandardService in project platformlayer by platformlayer.
the class ManagedKvmInstance method addChildren.
@Override
protected void addChildren() throws OpsException {
addChild(TemplatedFile.build(buildDeviceConfigModel(), getDeviceConfigPath()));
InstanceScript script;
{
script = addChild(InstanceScript.class);
script.filePath = new File(DirectHostController.KVM_INSTANCE_DIR, id);
String key = "kvm-" + id;
script.key = key;
script.addresses.addAll(addresses);
// script.hostPrimaryInterface = hostModel.publicInterface;
script.launchInstanceCommand = buildKvmCommand();
}
{
// ManagedSupervisordInstance service = addChild(ManagedSupervisordInstance.class);
StandardService service = addChild(StandardService.class);
script.configure(model, service);
}
}
Aggregations