use of org.platformlayer.ops.images.direct.PeerToPeerCopy in project platformlayer by platformlayer.
the class InstanceBootstrap method addChildren.
@Override
protected void addChildren() throws OpsException {
addChild(PersistIptablesScripts.class);
addChild(DefaultAptSourcesConfigurationFile.class);
{
File aptConfDir = new File("/etc/apt/apt.conf.d");
TemplateDataSource template = new TemplateDataSource() {
@Override
public void buildTemplateModel(Map<String, Object> model) throws OpsException {
}
};
addChild(TemplatedFile.build(template, new File(aptConfDir, "90-install-recommends")));
addChild(TemplatedFile.build(template, new File(aptConfDir, "90-install-suggests")));
}
addChild(BootstrapLocales.class);
addChild(ConfigureSshd.class);
// We always install curl, because we use it to check for http proxy responsiveness
// TODO: Switch to netcat, to avoid using curl here - it's quite big
addChild(PackageDependency.build("curl"));
PeerToPeerCopy peerToPeerCopy = Injection.getInstance(PeerToPeerCopy.class);
peerToPeerCopy.addChildren(this);
// if (OpsContext.isDelete()) {
// OpenstackComputeMachine machine = OpsContext.get().getInstance(OpenstackComputeMachine.class);
//
// OpsTarget target = OpsContext.get().getInstance(OpsTarget.class);
//
// OpenstackInstance model = OpsContext.get().getInstance(OpenstackInstance.class);
//
// if (model.recipeId != null) {
// DiskImageRecipe recipe = platformLayerClient.getItem(DiskImageRecipe.class, model.recipeId);
//
// diskImageRecipeHelper.applyRecipe(target, recipe);
// }
// }
}
use of org.platformlayer.ops.images.direct.PeerToPeerCopy in project platformlayer by platformlayer.
the class FilesystemCasStore method copyTo.
void copyTo(FilesystemCasObject src, OpsTarget target, File targetFilePath, boolean cacheOnTarget) throws OpsException {
File fileOnTarget;
if (!host.isSameMachine(target)) {
File downloadTo;
if (cacheOnTarget) {
// Copy to host cache
File cachePath = new File(PATH_CACHE, toRelativePath(src.getHash(), 2));
target.mkdir(cachePath.getParentFile());
downloadTo = cachePath;
} else {
downloadTo = targetFilePath;
}
PeerToPeerCopy peerToPeerCopy = Injection.getInstance(PeerToPeerCopy.class);
peerToPeerCopy.copy(host, src.getPath(), target, downloadTo);
fileOnTarget = downloadTo;
} else {
fileOnTarget = src.getPath();
}
if (!fileOnTarget.equals(targetFilePath)) {
Command copy = Command.build("cp {0} {1}", fileOnTarget, targetFilePath);
target.executeCommand(copy);
} else {
log.info("File is in destination path: " + fileOnTarget);
}
}
use of org.platformlayer.ops.images.direct.PeerToPeerCopy in project platformlayer by platformlayer.
the class DirectHostController method addChildren.
@Override
protected void addChildren() throws OpsException {
// if (Strings.isEmpty(model.dnsName)) {
// throw new IllegalArgumentException("dnsName must be specified");
// }
// DirectCloud cloud = platformLayer.getItem(model.cloud, DirectCloud.class);
// We'd like to auto-gen the disk image, but there's no way to auto-specify the OS at the moment
// String dnsName = "direct-host-" + model.getId();
// InstanceBuilder instance = InstanceBuilder.build(dnsName, DiskImageRecipeBuilder.buildDiskImageRecipe(this));
// instance.cloud = cloud.machineSource;
// instance.addTagToManaged = true;
// addChild(instance);
DirectTarget host;
{
host = addChild(DirectTarget.class);
host.address = NetworkPoint.forPublicHostname(model.host);
host.sshKey = service.getSshKey();
}
// TODO: It isn't quite right to call this InstanceBootstrap any more!
host.addChild(InstanceBootstrap.class);
host.addChild(DnsResolver.class);
// Time synchronization is pretty important
host.addChild(PackageDependency.build("ntp"));
// TODO: Do we want to differentiate between an LXC host and a KVM host?
host.addChild(PackageDependency.build("lxc"));
host.addChild(ManagedDirectory.build(LXC_INSTANCE_DIR, "0755"));
host.addChild(ManagedDirectory.build(KVM_INSTANCE_DIR, "0755"));
// Useful for moving images around
host.addChild(PackageDependency.build("bzip2"));
PeerToPeerCopy peerToPeerCopy = Injection.getInstance(PeerToPeerCopy.class);
peerToPeerCopy.addChildren(this);
{
PlatformLayerKey owner = model.getKey();
serviceManager.addServiceInstall(owner, host);
}
host.addChild(KvmHost.class);
host.addChild(MountCgroups.class);
host.addChild(PackageDependency.build("bridge-utils"));
host.addChild(NetworkBridge.class);
OpsItemBase.setAllChildrenLazyDelete(host, true);
}
Aggregations