Search in sources :

Example 1 with PeerToPeerCopy

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);
// }
// }
}
Also used : OpsException(org.platformlayer.ops.OpsException) PeerToPeerCopy(org.platformlayer.ops.images.direct.PeerToPeerCopy) TemplateDataSource(org.platformlayer.ops.templates.TemplateDataSource) TemplatedFile(org.platformlayer.ops.filesystem.TemplatedFile) DefaultAptSourcesConfigurationFile(org.platformlayer.ops.packages.AptSourcesConfigurationFile.DefaultAptSourcesConfigurationFile) File(java.io.File)

Example 2 with PeerToPeerCopy

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);
    }
}
Also used : PeerToPeerCopy(org.platformlayer.ops.images.direct.PeerToPeerCopy) Command(org.platformlayer.ops.Command) File(java.io.File)

Example 3 with PeerToPeerCopy

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);
}
Also used : PeerToPeerCopy(org.platformlayer.ops.images.direct.PeerToPeerCopy) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey)

Aggregations

PeerToPeerCopy (org.platformlayer.ops.images.direct.PeerToPeerCopy)3 File (java.io.File)2 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 Command (org.platformlayer.ops.Command)1 OpsException (org.platformlayer.ops.OpsException)1 TemplatedFile (org.platformlayer.ops.filesystem.TemplatedFile)1 DefaultAptSourcesConfigurationFile (org.platformlayer.ops.packages.AptSourcesConfigurationFile.DefaultAptSourcesConfigurationFile)1 TemplateDataSource (org.platformlayer.ops.templates.TemplateDataSource)1