/**
  * Creates a new instance of the Container entity and optional saves to the database.
  *
  * @param $name
  * @param string $friendlyName
  * @param bool|FALSE $persist
  * @return Container
  */
 public function createContainer($name, $friendlyName = '', $persist = false)
 {
     $container = new Container();
     $container->setName($name);
     $container->setFriendlyName($friendlyName);
     if ($persist) {
         $this->saveContainer($container);
     }
     return $container;
 }
Exemplo n.º 2
0
    protected function createDummyProject()
    {
        $container = new Container();
        $container->setName('test')->setFriendlyName('Test')->setHostname('cluster.test.localdev')->setDomain('test.localdev')->setDnsZoneSerial('2015070501')->setLxcUtsName('test')->setLxcHwAddr('00:16:3e:e0:5c:c3')->setLxcRootFs('/var/lib/lxc/test/rootfs')->setNetworkAddress('10.100.1.0')->setIPAddress('10.100.1.1')->setDnsZoneTtl(604800)->setDnsZonePriMasterNs('ns.rainmaker.localdev')->setDnsZoneAdminEmail('hostmaster.rainmaker.localdev')->setDnsZoneRefresh(604800)->setDnsZoneRetry(86400)->setDnsZoneExpire(2419200)->setDnsZoneNegCacheTtl(604800)->setState(Container::STATE_RUNNING)->setProfileName('rainmaker/default-project');
        $json = '
{
  "mounts": [
    {
      "source": "/var/cache/lxc/rainmaker",
      "target": "{{container_rootfs}}/var/cache/lxc/rainmaker",
      "group": "bind"
    },
    {
      "source": "/srv/saltstack",
      "target": "{{container_rootfs}}/srv/saltstack",
      "group": "bind"
    }
  ],
  "exports": []
}
';
        $container->setProfileMetadata($json);
        return $container;
    }
Exemplo n.º 3
0
    protected function createDummyProjectBranches()
    {
        $json = '
{
  "mounts": [
    {
      "source": "{{container_rootfs}}/var/www/html",
      "target": "/export/rainmaker/{{container_name}}",
      "group": "nfs"
    },
    {
      "source": "/srv/saltstack",
      "target": "{{container_rootfs}}/srv/saltstack",
      "group": "bind"
    }
  ],
  "exports": [
    {
      "source": "/export/rainmaker/{{container_name}}"
    }
  ]
}
';
        $containers = array();
        $container = new Container();
        $container->setName('test.prod')->setFriendlyName('Test [Prod]')->setHostname('test.localdev')->setDomain('test.localdev')->setDnsZoneSerial('2015070501')->setLxcUtsName('test.prod')->setLxcHwAddr('00:16:3e:e0:5c:c4')->setLxcRootFs('/var/lib/lxc/test.prod/rootfs')->setNetworkAddress('10.100.1.0')->setIPAddress('10.100.1.2')->setDnsZoneTtl(604800)->setDnsZonePriMasterNs('ns.rainmaker.localdev')->setDnsZoneAdminEmail('hostmaster.rainmaker.localdev')->setDnsZoneRefresh(604800)->setDnsZoneRetry(86400)->setDnsZoneExpire(2419200)->setDnsZoneNegCacheTtl(604800)->setState(Container::STATE_RUNNING)->setProfileName('rainmaker/default-branch')->setProfileMetadata($json)->setParentId(1);
        $containers[] = $container;
        $container = new Container();
        $container->setName('test.dev')->setFriendlyName('Test [Dev]')->setHostname('develop.test.localdev')->setDomain('test.localdev')->setDnsZoneSerial('2015070501')->setLxcUtsName('test.dev')->setLxcHwAddr('00:16:3e:e0:5c:c5')->setLxcRootFs('/var/lib/lxc/test.dev/rootfs')->setNetworkAddress('10.100.1.0')->setIPAddress('10.100.1.3')->setDnsZoneTtl(604800)->setDnsZonePriMasterNs('ns.rainmaker.localdev')->setDnsZoneAdminEmail('hostmaster.rainmaker.localdev')->setDnsZoneRefresh(604800)->setDnsZoneRetry(86400)->setDnsZoneExpire(2419200)->setDnsZoneNegCacheTtl(604800)->setState(Container::STATE_STOPPED)->setProfileName('rainmaker/default-branch')->setProfileMetadata($json)->setParentId(1);
        $containers[] = $container;
        return $containers;
    }
Exemplo n.º 4
0
    protected function createDummyProjectBranchClone()
    {
        $container = new Container();
        $container->setName('test.dev')->setFriendlyName('Test [Dev]')->setHostname('develop.test.localdev')->setDomain('test.localdev')->setDnsZoneSerial('2015070501')->setParentId(1);
        $json = '
{
  "mounts": [
    {
      "source": "{{container_rootfs}}/var/www/html",
      "target": "/export/rainmaker/{{container_name}}",
      "group": "nfs"
    },
    {
      "source": "/srv/saltstack",
      "target": "{{container_rootfs}}/srv/saltstack",
      "group": "bind"
    }
  ],
  "exports": [
    {
      "source": "/export/rainmaker/{{container_name}}"
    }
  ]
}
';
        $container->setProfileMetadata($json);
        return $container;
    }
Exemplo n.º 5
0
    protected function createDummyProjectBranch()
    {
        $container = new Container();
        $container->setName('test.prod')->setFriendlyName('Test [Prod]')->setHostname('test.localdev')->setDomain('test.localdev')->setDnsZoneSerial('2015070501')->setState(Container::STATE_PENDING_PROVISIONING)->setProfileName('rainmaker/default-branch')->setParentId(1);
        $json = '
{
  "mounts": [
    {
      "source": "{{container_rootfs}}/var/www/html",
      "target": "/export/rainmaker/{{container_name}}",
      "group": "nfs"
    },
    {
      "source": "/srv/saltstack",
      "target": "{{container_rootfs}}/srv/saltstack",
      "group": "bind"
    }
  ],
  "exports": [
    {
      "source": "/export/rainmaker/{{container_name}}"
    }
  ]
}
';
        $container->setProfileMetadata($json);
        return $container;
    }