Package org.platformlayer.ops.instances

Examples of org.platformlayer.ops.instances.InstanceBuilder


    @Override
    protected void addChildren() throws OpsException {
        VpnService model = OpsContext.get().getInstance(VpnService.class);

        InstanceBuilder instance = InstanceBuilder.build(model.dnsName, DiskImageRecipeBuilder.buildDiskImageRecipe(this));
        addChild(instance);

        instance.addChild(PackageDependency.build("strongswan"));

        instance.addChild(CollectdCollector.build());

        // instance.addChild(ManagedService.build("ipsec"));
    }
View Full Code Here


  @Override
  protected void addChildren() throws OpsException {
    Desktop model = OpsContext.get().getInstance(Desktop.class);

    InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
    instance.publicPorts.add(22);

    instance.hostPolicy.allowRunInContainer = true;
    instance.minimumMemoryMb = 4096;

    addChild(instance);

    {
      RecipeOperatingSystem os = injected(RecipeOperatingSystem.class);
      os.operatingSystem = new OperatingSystemRecipe();
      os.operatingSystem.setDistribution("debian");
      os.operatingSystem.setVersion("wheezy");
      instance.addChild(os);
    }

    // We use curl for backups
    instance.addChild(PackageDependency.build("curl"));

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = 22;
      endpoint.backendPort = 22;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      instance.addChild(endpoint);
    }

    // {
    // BackupDirectory backup = injected(BackupDirectory.class);
    // backup.itemKey = model.getKey();
View Full Code Here

  protected void addChildren() throws OpsException {
    int port = PORT;

    String dnsName = model.dnsName;

    InstanceBuilder vm;
    {
      vm = InstanceBuilder.build(dnsName, this, model.getTags());
      vm.publicPorts.add(port);
      vm.hostPolicy.configureCluster(template.getPlacementKey());

      // TODO: This needs to be configurable (?)
      vm.minimumMemoryMb = 2048;

      addChild(vm);
    }

    {
      PlatformLayerInstall install = injected(PlatformLayerInstall.class);
      vm.addChild(install);
    }

    {
      PlatformLayerInstance service = injected(PlatformLayerInstance.class);
      vm.addChild(service);
    }

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = port;
      endpoint.backendPort = port;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      if (model.transport != null) {
        endpoint.transport = EnumUtils.valueOfCaseInsensitive(Transport.class, model.transport);
      } else {
        endpoint.transport = Transport.Ipv6;
      }

      vm.addChild(endpoint);
    }

    if (model.dnsName != null) {
      loadBalancing.addHttpSite(this, model, model.dnsName, template.getSslKeyPath(), SslMode.Terminate);
    }
View Full Code Here

    int port = ZookeeperConstants.ZK_PUBLIC_PORT;

    // A per-instance name (for convenience)
    String dnsName = ZookeeperUtils.buildDnsName(model);

    InstanceBuilder vm = InstanceBuilder.build(dnsName, this, model.getTags());
    // vm.publicPorts.add(port);
    // vm.publicPorts.add(ZookeeperConstants.ZK_SYSTEM_PORT_1);
    // vm.publicPorts.add(ZookeeperConstants.ZK_SYSTEM_PORT_2);

    vm.hostPolicy.configureSpread(template.getClusterGroupId());

    vm.addChild(IpsecInstall.class);

    {
      IpsecPresharedKey psk = vm.addChild(IpsecPresharedKey.class);
      psk.id = IpsecPresharedKey.SHAREDKEY_USER_FQDN;
      psk.secret = ipsec.getIpsecSecret();
    }

    // The system ports are used for communication between nodes,
    // so need to be opened early
    for (int systemPort : ZookeeperConstants.SYSTEM_PORTS) {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = systemPort;
      endpoint.backendPort = systemPort;

      endpoint.dnsName = dnsName;

      // We expect this to be used by IPv6 capable client
      endpoint.transport = Transport.Ipv6;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);

      {
        IpsecForPort ipsecForPort = vm.addChild(IpsecForPort.class);
        ipsecForPort.port = systemPort;
      }
    }

    vm.hostPolicy.allowRunInContainer = true;

    // TODO: This needs to be configurable...
    vm.minimumMemoryMb = 2048;

    addChild(vm);

    {
      ZookeeperInstall install = vm.addChild(ZookeeperInstall.class);
    }

    {
      ZookeeperInstance service = vm.addChild(ZookeeperInstance.class);
    }

    {
      PublicEndpoint endpoint = vm.addChild(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = port;
      endpoint.backendPort = port;
      endpoint.dnsName = dnsName;

      // We expect this to be used by IPv6 capable client
      endpoint.transport = Transport.Ipv6;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      {
        IpsecForPort ipsecForPort = vm.addChild(IpsecForPort.class);
        ipsecForPort.port = port;
      }
    }

    vm.addChild(ZookeeperStatusChecker.class);

    // TODO: Establish round-robin style DNS on clusterDnsName
    // TODO: Is some form of geo-direction possible?
  }
View Full Code Here

  @Bound
  DnsServer model;

  @Override
  protected void addChildren() throws OpsException {
    InstanceBuilder vm = InstanceBuilder.build(model.dnsName, this, model.getTags());

    // TODO: Do we need a DnsCluster concept?
    // For now, we fake it
    PlatformLayerKey key = model.getKey();
    String groupId = key.withId(new ManagedItemId("primary")).getUrl();
    groupId = groupId.replace("/dnsServer/", "/dnsCluster/");
    vm.hostPolicy.configureSpread(groupId);

    vm.addTagToManaged = true;
    vm.publicPorts.add(53);

    // vm.minimumMemoryMb = 512;

    addChild(vm);

    vm.addChild(DnsServerInstall.class);
    vm.addChild(DnsServerInstance.class);

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = 53;
      endpoint.backendPort = 53;
      endpoint.dnsName = model.dnsName;
      endpoint.protocol = Protocol.Udp;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      vm.addChild(endpoint);
    }

    // TODO: Refresh other DNS servers so they also point to this server
  }
View Full Code Here

  @Override
  protected void addChildren() throws OpsException {
    JenkinsService model = OpsContext.get().getInstance(JenkinsService.class);

    InstanceBuilder vm;

    {
      vm = InstanceBuilder.build(model.dnsName, this, model.getTags());
      vm.publicPorts.add(PORT);

      vm.hostPolicy.allowRunInContainer = true;
      vm.minimumMemoryMb = 2048;

      addChild(vm);
    }

    // If we're building Java projects, we'll want a JDK
    vm.addChild(JavaVirtualMachine.buildJdk7());

    {
      PackageDependency jenkinsPackage = PackageDependency.build("jenkins");
      jenkinsPackage.repositoryKey = new RepositoryKey();
      jenkinsPackage.repositoryKey.setUrl("http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key");
      jenkinsPackage.repository = new Repository();
      jenkinsPackage.repository.setKey("jenkins");
      jenkinsPackage.repository.getSource().add("deb http://pkg.jenkins-ci.org/debian binary/");
      vm.addChild(jenkinsPackage);
    }

    // We use curl for backups
    vm.addChild(PackageDependency.build("curl"));

    // Jenkins git usually relies on git being installed
    // git-core is valid on both Debian & Ubuntu
    vm.addChild(PackageDependency.build("git-core"));

    vm.addChild(SimpleFile.build(getClass(), new File("/etc/default/jenkins")));

    vm.addChild(EnsureJenkinsSshKey.class);

    {
      // Adding a known-host entry for github.com doesn't reduce security (?)
      EnsureKnownHost knownHost = vm.addChild(EnsureKnownHost.class);
      knownHost.user = "jenkins";
      knownHost.homeDir = new File("/var/lib/jenkins");
      knownHost.host = "github.com";
      knownHost.algorithm = "ssh-rsa";
      knownHost.key = "AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==";
    }

    // Collectd not in wheezy??
    // instance.addChild(CollectdCollector.build());

    // TODO: If we're going to support SSH git....
    // TODO: We need to ssh-keygen for jenkins
    // TODO: Someone has to add the jenkins ssh key to the git repo
    // TODO: We need to set the git user variables (name & email)
    // TODO: We need to add the ssh key(s) of any git repos we're going to be using over ssh

    // su -c "ssh-keygen -q -f /var/lib/jenkins/.ssh/id_rsa -N ''" jenkins

    // scp root@[2001:470:8157:2::f]:/var/lib/jenkins/.ssh/id_rsa.pub .
    // cat id_rsa.pub | ssh -p29418 <gerritip> gerrit create-account --ssh-key - --full-name Jenkins jenkins

    {
      PublicEndpoint endpoint = injected(PublicEndpoint.class);
      // endpoint.network = null;
      endpoint.publicPort = PORT;
      endpoint.backendPort = PORT;
      endpoint.dnsName = model.dnsName;

      endpoint.tagItem = model.getKey();
      endpoint.parentItem = model.getKey();

      endpoint.transport = Transport.Ipv6;

      vm.addChild(endpoint);
    }

    {
      BackupDirectory backup = injected(BackupDirectory.class);
      backup.itemKey = model.getKey();

      File jenkinsRoot = new File("/var/lib/jenkins");
      backup.backupRoot = jenkinsRoot;

      String[] excludes = { "jobs/*/workspace", "jobs/*/modules", "jobs/*/builds/*/workspace.tar.gz",
          ".m2/repository" };

      for (String exclude : excludes) {
        backup.excludes.add(new File(jenkinsRoot, exclude));
      }

      vm.addChild(backup);
    }

  }
View Full Code Here

TOP

Related Classes of org.platformlayer.ops.instances.InstanceBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.