/**
  * Get a list of deployments
  *
  * @return  remote.server.deploy.Deployable[]
  */
 public function scanDeployments()
 {
     clearstatcache();
     $this->changed = FALSE;
     while ($entry = $this->folder->getEntry()) {
         if (!preg_match($this->pattern, $entry)) {
             continue;
         }
         $f = new File($this->folder->getURI() . $entry);
         if (isset($this->files[$entry]) && $f->lastModified() <= $this->files[$entry]) {
             // File already deployed
             continue;
         }
         $this->changed = TRUE;
         $ear = new Archive(new File($this->folder->getURI() . $entry));
         try {
             $ear->open(ARCHIVE_READ) && ($meta = $ear->extract('META-INF/bean.properties'));
         } catch (Throwable $e) {
             $this->deployments[$entry] = new IncompleteDeployment($entry, $e);
             continue;
         }
         $prop = Properties::fromString($meta);
         $beanclass = $prop->readString('bean', 'class');
         if (!$beanclass) {
             $this->deployments[$entry] = new IncompleteDeployment($entry, new FormatException('bean.class property missing!'));
             continue;
         }
         $d = new Deployment($entry);
         $d->setClassLoader(new ArchiveClassLoader($ear));
         $d->setImplementation($beanclass);
         $d->setInterface($prop->readString('bean', 'remote'));
         $d->setDirectoryName($prop->readString('bean', 'lookup'));
         $this->deployments[$entry] = $d;
         $this->files[$entry] = time();
         delete($f);
     }
     // Check existing deployments
     foreach (array_keys($this->deployments) as $entry) {
         $f = new File($this->folder->getURI() . $entry);
         if (!$f->exists()) {
             unset($this->deployments[$entry], $this->files[$entry]);
             $this->changed = TRUE;
         }
         delete($f);
     }
     $this->folder->close();
     return $this->changed;
 }
 function run()
 {
     $batch_size = 15;
     if (isset($_GET['batch_size'])) {
         $batch_size = intval(trim(Convert::raw2sql($_GET['batch_size'])));
     }
     $surveys = DeploymentSurvey::getNotDigestSent($batch_size);
     $deployments = Deployment::getNotDigestSent($batch_size);
     if ($surveys) {
         foreach ($surveys as $survey) {
             $survey->SendDigest = 1;
             $survey->write();
         }
     }
     if ($deployments) {
         foreach ($deployments as $dep) {
             $dep->SendDigest = 1;
             $dep->write();
         }
     }
     if ((!is_null($surveys) && count($surveys)) > 0 || !is_null($deployments) && count($deployments)) {
         global $email_new_deployment;
         $email = EmailFactory::getInstance()->buildEmail($email_new_deployment, $email_new_deployment, $subject = 'New Deployments and Surveys');
         $email->setTemplate('NewDeploymentsSurveysEmail');
         $email->populateTemplate(array('SurveysUrl' => Director::absoluteURL('admin/deployments/DeploymentSurvey/EditForm/field/DeploymentSurvey/item'), 'DeploymentsUrl' => Director::absoluteURL('admin/deployments/Deployment/EditForm/field/Deployment/item'), 'SangriaDeploymentsUrl' => Director::absoluteURL('sangria/ViewDeploymentDetails'), 'Surveys' => $surveys, 'Deployments' => $deployments));
         $email->send();
     }
 }
Пример #3
0
 public function getDeployment($key)
 {
     require_once 'lib/deployment.class.php';
     $deployments = $this->config->get('deployments', array());
     if (!isset($deployments[$key])) {
         trigger_error('Couldn\'t find deployment ' . $key . ' in project "' . $this->getTitle() . '"', E_USER_ERROR);
     }
     return Deployment::fromConfig($this, $deployments[$key]);
 }
Пример #4
0
    function run($args, $options) {
        if ($options['dns'])
            return $this->print_dns();

        // Set some forced args and options
        $temp = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $stage_path = $temp . 'osticket'
            . substr(md5('osticket-stage'.getmypid().getcwd()), -8);
        $args['install-path'] = $stage_path . '/upload';

        // Deployment will auto-create the staging area

        // Ensure that the staging path is cleaned up on exit
        register_shutdown_function(function() use ($stage_path) {
            $delTree = function($dir) use (&$delTree) {
                $files = array_diff(scandir($dir), array('.','..'));
                foreach ($files as $file) {
                    (is_dir("$dir/$file")) ? $delTree("$dir/$file") : unlink("$dir/$file");
                }
                return rmdir($dir);
            };
            return $delTree($stage_path);
        });

        $options['setup'] = true;
        $options['git'] = true;
        $options['verbose'] = true;

        $options['clean'] = false;
        $options['dry-run'] = false;
        $options['include'] = false;

        $this->_args = $args;
        $this->_options = $options;

        // TODO: Run the testing applet first
        $root = $this->find_root_folder();
        if (!$this->getOption('skip-test') && $this->run_tests($root) > 0)
            $this->fail("Regression tests failed. Cowardly refusing to package");

        // Run the deployment
        // NOTE: The deployment will change the working directory
        parent::run($args, $options);

        // Deploy the `setup/scripts` folder to `/scripts`
        $root = $this->source;
        Unpacker::unpackage("$root/setup/scripts/{,.}*", "$stage_path/scripts", -1);

        // Package up the staging area
        $version = exec('git describe');
        switch (strtolower($this->getOption('format'))) {
        case 'zip':
        default:
            $this->packageZip("$root/osTicket-$version.zip", $stage_path);
        }
    }
Пример #5
0
 function getCMSFields()
 {
     // Get arrays to related dropdowns
     $deployments = Deployment::get()->filter('IsPublic', 1);
     if ($deployments) {
         $deployments = $deployments->map('ID', 'OrgAndLabel', '(Select one)', true);
     }
     $industries = UserStoriesIndustry::get()->filter('Active', 1);
     if ($industries) {
         $industries = $industries->map('ID', 'IndustryName', '(Select one)', true);
     }
     $fields = parent::getCMSFields();
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $fields->addFieldsToTab('Root.Main', array(new CustomUploadField('SummaryImg', 'Summary Image'), new DropdownField('DeploymentID', 'Deployment', $deployments), new DropdownField('UserStoriesIndustryID', 'Industry', $industries), new DropdownField('DeploymentType', 'Deployment Type', DeploymentOptions::$deployment_type_options), $ddl_country = new DropdownField('PrimaryCountry', 'Country', $CountryCodes)));
     $ddl_country->setEmptyString('-- Select One --');
     $fields->addFieldsToTab('Root.CaseStudy', array(new CheckboxField('ShowCaseStudy', 'Show Case Study?'), new TextField('CaseStudyTitle', 'Case Study Title'), new TextField('CompanyName', 'Company Name'), new TextField('CompanyURL', 'Company URL'), new TextField('ThirdPartyURL', '3rd Party Site URL'), new HtmlEditorField('CaseStudyBody', 'Case Study Body'), new CustomUploadField('CaseStudyImg', 'Case Study Image'), new TextField('ObjectivesTitle', 'Objectives Title'), new HtmlEditorField('ObjectivesBody', 'Objectives Body'), new TextField('CompanyHeadquarters', 'Company Headquarters'), new TextField('CompanySize', 'Company Size'), new TextField('CompanyIndustry', 'Company Industry'), new CheckboxSetField('ProjectsUsed', 'ProjectsUsed', array('Openstack Compute (Nova)' => 'Openstack Compute (Nova)', 'Openstack Block Storage (Cinder)' => 'Openstack Block Storage (Cinder)', 'Openstack Object Storage (Swift)' => 'Openstack Object Storage (Swift)', 'Openstack Network' => 'Openstack Network (Neutron)', 'Openstack Dashboard (Horizon)' => 'Openstack Dashboard (Horizon)', 'Openstack Identity Service (Keystone)' => 'Openstack Identity Service (Keystone)', 'Openstack Image Service (Glance)' => 'Openstack Image Service (Glance)', 'Heat' => 'OpenStack Orchestration (Heat)', 'Ceilometer' => 'OpenStack Metering (Ceilometer)', 'OpenStack Bare Metal (Ironic)' => 'OpenStack Bare Metal (Ironic)', 'OpenStack Database as a Service (Trove)' => 'OpenStack Database as a Service (Trove)'))));
     $fields->addFieldsToTab('Root.Video', array(new CheckboxField('ShowVideo', 'Show Video?'), new TextField('Video', 'YouTube URL')));
     // Reuse fields from Page Model, and change their label to match Specs
     $fields->renameField('Title', 'Deployment Display Name');
     $fields->renameField('Content', 'Summary');
     return $fields;
 }
Пример #6
0
 /**
  * Show a list of all the blog posts formatted for Datatables.
  *
  * @return Datatables JSON
  */
 public function getData()
 {
     $deployments = Deployment::select(array('deployments.id', 'deployments.name', 'cloudAccounts.name as AcctName', 'cloudAccounts.cloudProvider', 'users.username', 'users.email', 'cloudAccounts.created_at'))->join('users', 'users.id', '=', 'deployments.user_id')->join('cloudAccounts', 'cloudAccounts.id', '=', 'deployments.cloudAccountId');
     return Datatables::of($deployments)->remove_column('id')->make();
 }
Пример #7
0
 /**
  * Remove the specified Account .
  *
  * @param $account
  *
  */
 public function postDelete($account)
 {
     if (empty($account->id)) {
         $account = CloudAccount::where('user_id', Auth::id())->find($account);
     }
     $deployment = Deployment::where('user_id', Auth::id())->where('cloudAccountId', $account->id)->get();
     if (!$deployment->isEmpty()) {
         return Redirect::to('account')->with('error', 'Deployment is linked with this account and hence cannot be deleted');
     }
     CloudAccount::where('id', $account->id)->where('user_id', Auth::id())->delete();
     $id = $account->id;
     $account->delete();
     // Was the comment post deleted?
     $account = CloudAccount::where('user_id', Auth::id())->find($id);
     if (empty($account)) {
         // TODO needs to delete all of that user's content
         return Redirect::to('account')->with('success', 'Removed Account Successfully');
     } else {
         // There was a problem deleting the user
         return Redirect::to('account/' . $account->id . '/edit')->with('error', 'Error while deleting');
     }
 }
Пример #8
0
 function DeploymentsAsJSON()
 {
     $Deployments = Deployment::get();
     $f = new JSONDataFormatter();
     echo $f->convertDataObjectSet($Deployments);
 }
Пример #9
0
 /**
  * Constructor
  *
  * @param string $name
  */
 public function __construct($name = null)
 {
     parent::__construct($name);
     $this->releaseIdentifier = null;
 }
Пример #10
0
 public function LoadDeployment($id)
 {
     if ($id && is_numeric($id) && ($CurrentDeployment = Deployment::get()->byID($id))) {
         $DeploymentSurvey = $CurrentDeployment->DeploymentSurvey();
         if ($DeploymentSurvey && $DeploymentSurvey->MemberID == Member::currentUserID()) {
             return $CurrentDeployment;
         }
     }
     return NULL;
 }
 function AddNewDeployment()
 {
     $survey = DataObject::get_one('DeploymentSurvey', 'ID = ' . $_POST['survey']);
     $deployment = new Deployment();
     $deployment->Label = $_POST['label'];
     $deployment->DeploymentType = $_POST['type'];
     $deployment->CountriesPhysicalLocation = $_POST['country'];
     $deployment->CountriesUsersLocation = $_POST['country'];
     if ($survey) {
         $deployment->OrgID = $survey->OrgID;
     } else {
         $deployment->OrgID = 0;
     }
     $deployment->IsPublic = 1;
     $deployment->write();
     if ($survey) {
         $survey->Deployments()->add($deployment);
     }
     $this->owner->setMessage('Success', '<b>' . $_POST['label'] . '</b> added as a new Deployment.');
     Controller::curr()->redirectBack();
 }
Пример #12
0
 public function getDownloadKey($id)
 {
     $this->check(true);
     $instanceID = Input::get('instanceID');
     $deployment = Deployment::where('user_id', Auth::id())->find($id);
     $account = CloudAccount::where('user_id', Auth::id())->findOrFail($deployment->cloudAccountId);
     $arr = $this->executeAction('downloadKey', $account, $deployment, $instanceID);
     if ($arr['status'] == 'OK') {
         $key = StringHelper::decrypt($arr['key'], md5(Auth::user()->username));
         header('Content-Description: File Transfer');
         header('Content-Type: ' . 'application/x-pem-file');
         header('Content-Disposition: attachment; filename=' . $arr['keyName'] . '.pem');
         header('Content-Transfer-Encoding: binary');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . strlen($key));
         print $key;
     }
 }
 public function copyFrom(DeploymentSurvey $oldSurvey)
 {
     // copy properties
     foreach (DeploymentSurvey::$db as $field => $type) {
         if (in_array($field, DeploymentSurveyMigrationOptions::$blank_fields)) {
             continue;
         }
         $new_value = '';
         if (array_key_exists($field, DeploymentSurveyMigrationOptions::$migration_fields)) {
             $new_value = $oldSurvey->getField($field);
             if (empty($new_value)) {
                 continue;
             }
             $table = DeploymentSurveyMigrationOptions::$migration_fields[$field];
             foreach ($table as $old => $new) {
                 $new_value = str_replace($old, $new, $new_value);
             }
         } else {
             $new_value = $oldSurvey->getField($field);
         }
         $this->setField($field, $new_value);
     }
     $this->setField('OrgID', $oldSurvey->getField('OrgID'));
     $this->setField('MemberID', $oldSurvey->getField('MemberID'));
     foreach ($oldSurvey->Deployments() as $oldDeployment) {
         $newDeployment = new Deployment();
         $newDeployment->copyFrom($oldDeployment);
         $newDeployment->write();
         $this->Deployments()->add($newDeployment);
     }
     foreach ($oldSurvey->AppDevSurveys() as $oldAppDev) {
         $newAppDev = new AppDevSurvey();
         $newAppDev->copyFrom($oldAppDev);
         $newAppDev->write();
         $this->AppDevSurveys()->add($newAppDev);
     }
 }
Пример #14
0
 public function copyFrom(Deployment $oldDeployment)
 {
     foreach (Deployment::$db as $field => $type) {
         if (in_array($field, DeploymentMigrationOptions::$blank_fields)) {
             continue;
         }
         $new_value = '';
         if (array_key_exists($field, DeploymentMigrationOptions::$migration_fields)) {
             $new_value = $oldDeployment->getField($field);
             if (empty($new_value)) {
                 continue;
             }
             $table = DeploymentMigrationOptions::$migration_fields[$field];
             foreach ($table as $old => $new) {
                 $new_value = str_replace($old, $new, $new_value);
             }
         } else {
             $new_value = $oldDeployment->getField($field);
         }
         $this->setField($field, $new_value);
     }
     $this->setField('OrgID', $oldDeployment->getField('OrgID'));
     $this->setField('DeploymentSurveyID', $oldDeployment->getField('DeploymentSurveyID'));
 }
Пример #15
0
 public function exportByDeployment()
 {
     $id = Input::get('id');
     $deploymentId = Input::get('deploymentId');
     $deployment = Deployment::where('user_id', Auth::id())->find($deploymentId);
     Log::info('Logs for ' . $deployment->name);
     $result = json_decode($deployment->wsResults);
     $ret = RemoteAPI::export($id, $result->public_dns);
     Log::info('Logs for Container ');
     echo '<pre>';
     print_r($ret);
 }
Пример #16
0
    $logger->log("Error: {$e->getMessage()} in {$e->getFile()} on {$e->getLine()}");
});
function toArray($val)
{
    return is_array($val) ? array_diff($val, array(NULL)) : preg_split('#\\s+#', $val, -1, PREG_SPLIT_NO_EMPTY);
}
// start deploy
$logger->log("Started at " . date('[Y/m/d H:i]'));
$logger->log("Config file is {$configFile}");
foreach ($config as $section => $cfg) {
    $logger->log("\nDeploying {$section}");
    $cfg = array_change_key_case($cfg, CASE_LOWER) + array('local' => dirname($configFile), 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => '');
    if (empty($cfg['remote'])) {
        throw new Exception("Missing 'remote' in config.");
    }
    $deployment = new Deployment($cfg['remote'], $cfg['local'], $logger);
    $deployment->ignoreMasks = array_merge(array('*.bak', '.svn', '.git*'), toArray($cfg['ignore']));
    $deployment->deploymentFile = empty($cfg['deploymentfile']) ? $deployment->deploymentFile : $cfg['deploymentfile'];
    $deployment->testMode = !empty($cfg['test']) || isset($options['t']) || isset($options['test']);
    $deployment->allowDelete = $cfg['allowdelete'];
    $deployment->toPurge = toArray($cfg['purge']);
    $deployment->runBefore = toArray($cfg['before']);
    $deployment->runAfter = toArray($cfg['after']);
    if ($deployment->testMode) {
        $logger->log('Test mode');
    }
    if (!$deployment->allowDelete) {
        $logger->log('Deleting disabled');
    }
    $deployment->deploy();
}
Пример #17
0
 /**
  * Creates a new GetDeploymentResult from parsed response body.
  * 
  * @param array $parsed The parsed response body in array representation.
  * 
  * @return GetDeploymentResult
  * 
  * @static
  */
 public static function create($parsed)
 {
     $result = new GetDeploymentResult();
     $result->setDeployment(Deployment::create($parsed));
     return $result;
 }
Пример #18
0
 public function getReply($id = false)
 {
     $ticket = $id !== false ? Ticket::where('user_id', Auth::id())->findOrFail($id) : null;
     $userList = $id !== false ? DB::table('users')->select('username', 'email')->where('id', Auth::id())->get() : null;
     $ticketComments = $id !== false ? Ticket::leftJoin('ticket_comments', 'tickets.id', '=', 'ticket_comments.ticket_id')->where('tickets.user_id', Auth::id())->orderBy('ticket_comments.created_at', 'DESC')->get() : null;
     $priorities = array('urgent', 'high', 'medium', 'low');
     $deployments = Deployment::where('user_id', Auth::id())->get();
     return View::make('site/ticket/reply', compact('mode', 'ticket', 'priorities', 'ticketComments', 'userList', 'deployments'));
 }