コード例 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repository = $this->getEntityManager()->getRepository('Rainmaker:Container');
     $uniqueName = $input->getArgument('name');
     if (empty($uniqueName)) {
         if ($input->isInteractive()) {
             $uniqueName = $this->askForProjectUniqueName($input, $output);
         } else {
             $output->writeln("<error>You must specify a unique name for the project.</error>");
             return 1;
         }
     }
     if (!$repository->projectContainerExists($uniqueName)) {
         $output->writeln("<error>No container with the unique name specified exists.</error>");
         return 1;
     }
     $this->setContainerEntity($repository->findOneByName($uniqueName));
     $this->getConfiguredTask()->setContainer($this->getContainerEntity());
     parent::execute($input, $output);
 }
コード例 #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $repository = $this->getEntityManager()->getRepository('Rainmaker:Container');
     $uniqueName = $input->getArgument('name');
     if (empty($uniqueName)) {
         if ($input->isInteractive()) {
             $uniqueName = $this->askForProjectBranchUniqueName($input, $output);
         } else {
             $output->writeln("<error>You must specify the unique name for the project branch you wish to clone.</error>");
             return 1;
         }
     }
     if (!$repository->projectBranchContainerExists($uniqueName)) {
         $output->writeln("<error>No project branch container with the unique name specified exists.</error>");
         return 1;
     }
     $newUniqueName = $input->getArgument('newname');
     $newFriendlyName = $input->getOption('fname');
     if (empty($newUniqueName)) {
         if ($input->isInteractive()) {
             if (empty($newFriendlyName)) {
                 $newFriendlyName = $this->askForNewProjectBranchFriendlyName($input, $output);
             }
             $newUniqueName = $this->askForNewProjectBranchUniqueName($input, $output, $repository->friendlyNameToContainerName($newFriendlyName));
         } else {
             $output->writeln("<error>You must specify a unique name for the new project branch.</error>");
             return 1;
         }
     }
     if ($repository->containerExists($newUniqueName)) {
         $output->writeln("<error>A project branch already exists with the unique name you have specified.</error>");
         return 1;
     }
     if (empty($newFriendlyName)) {
         if ($input->isInteractive()) {
             $newFriendlyName = $this->askForNewProjectBranchFriendlyName($input, $output);
         } else {
             $output->writeln("<error>You must specify a friendly name for the new project branch.</error>");
             return 1;
         }
     }
     $currentBranch = $repository->findOneByName($uniqueName);
     $newHostname = $input->getOption('hostname');
     if (empty($newHostname)) {
         if ($input->isInteractive()) {
             $defaultHostname = $newUniqueName . '.' . $currentBranch->getDomain();
             $newHostname = $this->askForNewProjectBranchHostName($input, $output, $defaultHostname);
         } else {
             $output->writeln("<error>You must specify a host name for the new project branch.</error>");
             return 1;
         }
     }
     $project = $repository->getParentContainer($currentBranch);
     $newBranch = $repository->createContainer($newUniqueName, $newFriendlyName, false)->setDomain($project->getDomain())->setHostname($newHostname)->setParentId($project->getId());
     $repository->saveContainer($newBranch);
     $newBranch->setCloneSource($currentBranch);
     $newBranch->setDownloadHost($this->getContainer()->getParameter('rainmaker_download_host'));
     $this->setContainerEntity($newBranch);
     $this->getConfiguredTask()->setContainer($newBranch);
     parent::execute($input, $output);
 }
コード例 #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //$output->writeln('project:create');
     //print_r($this->getContainer());
     //lxc-create --template download --name "$GOLDPROJ_LXC_NAME" -- --dist ubuntu --release trusty --arch amd64
     //lxc-clone _golden-proj_ myproject
     /** @var ContainerRepository $repository */
     $repository = $this->getEntityManager()->getRepository('Rainmaker:Container');
     $uniqueName = $input->getArgument('name');
     $friendlyName = $input->getOption('fname');
     if (empty($uniqueName)) {
         if ($input->isInteractive()) {
             if (empty($friendlyName)) {
                 $friendlyName = $this->askForProjectFriendlyName($input, $output);
             }
             $uniqueName = $this->askForProjectUniqueName($input, $output, $repository->friendlyNameToContainerName($friendlyName));
         } else {
             $output->writeln("<error>You must specify a unique name for the project.</error>");
             return 1;
         }
     }
     if (empty($friendlyName)) {
         if ($input->isInteractive()) {
             $friendlyName = $this->askForProjectFriendlyName($input, $output);
         } else {
             $output->writeln("<error>You must specify a friendly name for the project.</error>");
             return 1;
         }
     }
     if ($repository->containerExists($uniqueName)) {
         $output->writeln("<error>A project already exists with the unique name you have specified.</error>");
         return 1;
     }
     //
     $domain = $input->getOption('domain');
     if (empty($domain)) {
         if ($input->isInteractive()) {
             $defaultDomain = $uniqueName . '.localdev';
             $domain = $this->askForProjectDomainName($input, $output, $defaultDomain);
         } else {
             $output->writeln("<error>You must specify a domain name for the project.</error>");
             return 1;
         }
     }
     $hostname = $input->getOption('hostname');
     if (empty($hostname)) {
         if ($input->isInteractive()) {
             $defaultHostname = 'cluster.' . $domain;
             $hostname = $this->askForProjectHostName($input, $output, $defaultHostname);
         } else {
             $output->writeln("<error>You must specify a host name for the project.</error>");
             return 1;
         }
     }
     $createBranch = $input->getOption('newbranch');
     if (empty($createBranch)) {
         if ($input->isInteractive()) {
             $createBranch = $this->askWhetherToCreateBranch($input, $output);
         }
     }
     $branchName = $input->getOption('branch-name');
     $branchFriendlyName = $input->getOption('branch-fname');
     $branchHostname = $input->getOption('branch-hostname');
     if ($createBranch && empty($branchName)) {
         if ($input->isInteractive()) {
             $branchName = $this->askForProjectBranchUniqueName($input, $output, $uniqueName . '.prod');
         } else {
             $output->writeln("<error>You must specify a unique name for the project branch.</error>");
             return 1;
         }
     }
     if ($createBranch && empty($branchFriendlyName)) {
         if ($input->isInteractive()) {
             $branchFriendlyName = $this->askForProjectBranchFriendlyName($input, $output);
         } else {
             $output->writeln("<error>You must specify a friendly name for the project branch.</error>");
             return 1;
         }
     }
     if ($createBranch && empty($branchHostname)) {
         if ($input->isInteractive()) {
             $defaultHostname = $domain;
             $branchHostname = $this->askForProjectHostName($input, $output, $defaultHostname);
         } else {
             $output->writeln("<error>You must specify a host name for the project branch.</error>");
             return 1;
         }
     }
     $project = $repository->createContainer($uniqueName, $friendlyName, false)->setDomain($domain)->setHostname($hostname);
     $repository->saveContainer($project);
     $project->setProfileName($this->getContainer()->getParameter('rainmaker_default_project_profile'));
     $project->setDownloadHost($this->getContainer()->getParameter('rainmaker_download_host'));
     $this->setContainerEntity($project);
     $this->getConfiguredTask()->setContainer($project);
     if ($createBranch) {
         $branch = $repository->createContainer($branchName, $branchFriendlyName, false)->setDomain($domain)->setHostname($branchHostname)->setParentId($project->getId());
         $repository->saveContainer($branch);
         $branch->setProfileName($this->getContainer()->getParameter('rainmaker_default_project_branch_profile'));
         $branch->setDownloadHost($this->getContainer()->getParameter('rainmaker_download_host'));
         $this->getConfiguredTask()->setBranchContainer($branch);
     }
     parent::execute($input, $output);
 }
コード例 #4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $task = $this->getConfiguredTask();
     parent::execute($input, $output);
     $output->write("\n" . $task->getList() . "\n", true);
 }