コード例 #1
0
 public function listReleaseLog($release = '', $applicationId = '')
 {
     $releases = $this->objReleaseLogStore->listReleaseLog($release, $applicationId);
     if ($release) {
         //Application...
         $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
         $applications = $objApplicationManager->listApplication();
         $applicationsArr = array();
         foreach ($applications as $application) {
             $applicationsArr[$application['applicationId']] = array('applicationName' => $application['applicationName'], 'applicationGroupName' => $application['applicationGroupName']);
         }
         foreach ($releases as $key => $release) {
             $deployStatus = $this->objReleaseLogStore->getReleaseDeployment($release['release'], $release['applicationId']);
             $releases[$key]['applicationName'] = $applicationsArr[$release['applicationId']]['applicationName'];
             $releases[$key]['applicationGroupName'] = $applicationsArr[$release['applicationId']]['applicationGroupName'];
             $releases[$key]['time_stamp'] = $deployStatus[0]['time_stamp'];
             $releases[$key]['status'] = $deployStatus[0]['status'];
         }
     }
     if (!$release && !$applicationId) {
         foreach ($releases as $key => $release) {
             $comment = $this->objReleaseLogStore->getReleaseComment($release['date'], $release['release']);
             if ($comment) {
                 $comment = $comment['comment'];
             } else {
                 $comment = '';
             }
             $releases[$key]['comment'] = $comment;
         }
     }
     return $releases;
 }
コード例 #2
0
 public function listConfiguration()
 {
     //Application...
     $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
     $applications = $objApplicationManager->listApplication();
     $applicationsArr = array();
     foreach ($applications as $application) {
         $applicationsArr[$application['applicationId']] = $application['applicationName'];
     }
     //Service...
     $objServiceManager = NCConfigFactory::getInstance()->getServiceManager();
     $services = $objServiceManager->listService();
     $servicesArr = array();
     foreach ($services as $service) {
         $servicesArr[$service['serviceId']] = $service['serviceTypeName'] . " (" . $service['servicePort'] . ") - " . $service['serviceRefName'];
     }
     //SystemUser...
     $objSystemUserManager = NCConfigFactory::getInstance()->getSystemUserManager();
     $systemUsers = $objSystemUserManager->listSystemUser();
     $systemUsersArr = array();
     foreach ($systemUsers as $systemUser) {
         $systemUsersArr[$systemUser['systemUserId']] = $systemUser['systemUserRefName'] . " (" . $systemUser['username'] . ")";
     }
     $configurations = $this->objConfigurationStore->listConfiguration();
     foreach ($configurations as $key => $configuration) {
         $configurations[$key]['applicationName'] = $applicationsArr[$configuration['applicationId']];
         $configurations[$key]['service'] = $servicesArr[$configuration['serviceId']];
         $configurations[$key]['systemUser'] = $systemUsersArr[$configuration['systemUserId']];
     }
     return $configurations;
 }
コード例 #3
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $class = __CLASS__;
         self::$instance = new $class();
     }
     return self::$instance;
 }
コード例 #4
0
 public function deleteValidation($serviceId)
 {
     $ConfigurationManager = NCConfigFactory::getInstance()->getConfigurationManager();
     if ($ConfigurationManager->getServiceConfiguration($serviceId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     return $this->errorArray;
 }
コード例 #5
0
 private function serverList()
 {
     $objServerManager = NCConfigFactory::getInstance()->getServerManager();
     $servers = $objServerManager->listServer();
     $serversArr = array();
     foreach ($servers as $server) {
         $serversArr[$server['serverId']] = $server;
     }
     return $serversArr;
 }
コード例 #6
0
 public function getApplicationOwned($email)
 {
     $app = array();
     $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
     $applications = $objApplicationManager->getUserApplication($email);
     foreach ($applications as $application) {
         $app[] = $application['applicationId'];
     }
     return $app;
 }
コード例 #7
0
 public function deleteValidation($email)
 {
     $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
     $applications = $objApplicationManager->listApplication();
     foreach ($applications as $application) {
         if ($email == $application['email']) {
             $this->errorArray['error'] = 'ERROR';
             break;
         }
     }
     return $this->errorArray;
 }
コード例 #8
0
 public function deleteValidation($serverId)
 {
     $ApplicationServerMapManager = NCConfigFactory::getInstance()->getApplicationServerMapManager();
     $ServiceManager = NCConfigFactory::getInstance()->getServiceManager();
     if ($ApplicationServerMapManager->getServerApplicationMap($serverId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     if ($ServiceManager->listService($serverId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     return $this->errorArray;
 }
コード例 #9
0
 private function deleteService()
 {
     $serverId = $this->requestParameter['serverId'];
     $serviceId = $this->requestParameter['serviceId'];
     $objServiceValidator = NCConfigFactory::getInstance()->getServiceValidator();
     $errorArray = $objServiceValidator->deleteValidation($serviceId);
     if ($errorArray) {
         $returnUrl = DOMAIN . "server/view?serverId={$serverId}&action=deleteServiceError";
     } else {
         $this->objServiceManager->deleteService($serviceId);
         $returnUrl = DOMAIN . "server/view?serverId={$serverId}&action=deleteService";
     }
     header("Location: {$returnUrl}");
 }
コード例 #10
0
 protected function isActionAllowed($applicationId)
 {
     $role = $this->objAuthenticateManager->getRole();
     if ($role == 'ADMIN') {
         return true;
     }
     $objRoleManager = NCConfigFactory::getInstance()->getRoleManager();
     $applicationsOwned = $objRoleManager->getApplicationOwned($this->objAuthenticateManager->getEmail());
     if (!in_array($applicationId, $applicationsOwned)) {
         $errorM = 'Action Not Allowed. <br/>Your account is not currently set up to allow this function. <br/>Please contact your ADMIN User';
         $this->smarty->assign('error', $errorM);
         $this->smarty->display('error.html');
         die;
     }
 }
コード例 #11
0
 public function listService($serverId)
 {
     $objServiceTypeManager = NCConfigFactory::getInstance()->getServiceTypeManager();
     $serviceTypes = $objServiceTypeManager->listServiceType();
     $serviceTypesArr = array();
     foreach ($serviceTypes as $serviceType) {
         $serviceTypesArr[$serviceType['serviceTypeId']] = $serviceType['serviceTypeName'];
     }
     $services = $this->objServiceStore->listService($serverId);
     foreach ($services as $key => $service) {
         $services[$key]['serviceTypeName'] = $serviceTypesArr[$service['serviceTypeId']];
         $services[$key]['serviceLabel'] = $services[$key]['serviceTypeName'] . ' (' . $service['servicePort'] . ') - ' . $service['serviceRefName'];
     }
     return $services;
 }
コード例 #12
0
 private function addConfigureApplication()
 {
     if ($this->requestParameter['submit']) {
         $applicationId = $this->requestParameter['applicationId'];
         $objConfigurationPath = new ConfigurationPath();
         $objConfigurationPath->setApplicationId($applicationId);
         $objConfigurationPath->setConfigurationPath($this->requestParameter['configPath']);
         /*
           $objConfigurationFile	= new ConfigurationFile();
           $objConfigurationFile->setApplicationId($applicationId);
           $objConfigurationFile->setConfigurationFile($_FILES["configFile"]["name"]);
         */
         $objApplicationServerMap = new ApplicationServerMap();
         $objApplicationServerMap->setApplicationId($applicationId);
         $objApplicationServerMap->setServerId($this->requestParameter['serverId']);
         $this->objConfigurationPathManager->addConfigurationPath($objConfigurationPath);
         //$this->objConfigurationFileManager->addConfigurationFile($objConfigurationFile);
         $this->objApplicationServerMapManager->addApplicationServerMap($objApplicationServerMap);
         //$this->manageFile($this->requestParameter['applicationId']);
         $this->smarty->assign('success', 'Application Configured Successfully.');
         $this->viewConfigureApplication();
     }
     $applications = $this->objApplicationManager->listApplication();
     $servers = $this->objServerManager->listServer();
     $applicationGroupNames = array();
     foreach ($applications as $application) {
         $groupName = $application['applicationGroupName'];
         $applicationGroupNames[$groupName] = $groupName;
     }
     $this->smarty->assign('sugg_applicationGroupNames', json_encode($applicationGroupNames));
     $objUserManager = NCConfigFactory::getInstance()->getUserManager();
     $users = $objUserManager->listUser();
     $sugg_Emails = array();
     foreach ($users as $user) {
         $email = $user['email'];
         $sugg_Emails[$email] = $email;
     }
     $this->smarty->assign('sugg_Emails', json_encode($sugg_Emails));
     $this->smarty->assign('applications', $applications);
     $this->smarty->assign('servers', $servers);
     $this->smarty->assign('DEFAULT_CONFIG_PATH', DEFAULT_CONFIG_PATH);
     $this->smarty->display('configureApplication.html');
 }
コード例 #13
0
 public function deleteValidation($cronId)
 {
     $CronServerMapManager = NCConfigFactory::getInstance()->getCronServerMapManager();
     $ConfigurationManager = NCConfigFactory::getInstance()->getConfigurationManager();
     $ConfigurationFileManager = NCConfigFactory::getInstance()->getConfigurationFileManager();
     $ConfigurationPathManager = NCConfigFactory::getInstance()->getConfigurationPathManager();
     if ($ConfigurationPathManager->getConfigurationPath($cronId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     if ($ConfigurationFileManager->getConfigurationFile($cronId)) {
         return $this->errorArray['error'] = 'ERORR';
     }
     if ($CronServerMapManager->getCronServerMap($cronId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     if ($ConfigurationManager->getCronConfiguration($cronId)) {
         return $this->errorArray['error'] = 'ERROR';
     }
     return $this->errorArray;
 }
コード例 #14
0
 public function addValidation($objConfiguration)
 {
     $applicationId = $objConfiguration->getApplicationId();
     $serviceId = $objConfiguration->getServiceId();
     $systemUserId = $objConfiguration->getSystemUserId();
     $systemUserId2 = $objConfiguration->getSystemUserId2();
     $configurationTag = $objConfiguration->getConfigurationTag();
     if (!$this->blankCheck($configurationTag)) {
         $this->errorArray['configurationTag'] = 'Please provide Tag';
     } elseif (!$this->maxLengthCheck($configurationTag, 50)) {
         $this->errorArray['configurationTag'] = 'Max length 50 characters long';
     }
     $objConfigurationManager = NCConfigFactory::getInstance()->getConfigurationManager();
     $status = $objConfigurationManager->validateConfiguration($applicationId, $serviceId, $systemUserId, $systemUserId2);
     if (!$status) {
         $this->errorArray['configurationTag'] = 'Tag already exists';
     }
     $status = $objConfigurationManager->validateConfigurationTag($configurationTag);
     if (!$status) {
         $this->errorArray['serviceId'] = 'Configuration already exists';
     }
     return $this->errorArray;
 }
コード例 #15
0
 private function deleteApplication()
 {
     $applicationId = $this->requestParameter['applicationId'];
     $objApplicationValidator = NCConfigFactory::getInstance()->getApplicationValidator();
     $errorArray = $objApplicationValidator->deleteValidation($applicationId);
     if ($errorArray) {
         $this->smarty->assign('error', 'Application cannot be deleted');
     } else {
         //Delete Application.
         $this->objApplicationManager->deleteApplication($applicationId);
         $this->smarty->assign('success', 'Application deleted successfully');
     }
     $this->listApplication();
 }
コード例 #16
0
 private function changePassword()
 {
     $email = $this->userEMAIL;
     if ($this->requestParameter['submit']) {
         $password = $this->requestParameter['password'];
         $confirmPassword = $this->requestParameter['confirmPassword'];
         $objUser = new User();
         $objUserValidator = NCConfigFactory::getInstance()->getUserValidator();
         $errorArray = $objUserValidator->changePasswordValidation($password, $confirmPassword);
         if ($errorArray) {
             $this->smarty->assign('password', $password);
             $this->smarty->assign('confirmPassword', $confirmPassword);
             $this->smarty->assign('errors', $errorArray);
         } else {
             $this->objUserManager->changePassword($email, md5($password));
             $this->smarty->assign('success', 'Your password has been changed successfully');
         }
     }
     $this->smarty->display('changePassword.html');
 }
コード例 #17
0
 private function editCron()
 {
     $cronId = $this->requestParameter['cronId'];
     if ($this->requestParameter['submit']) {
         $objCron = new Cron();
         $objCronValidator = NCConfigFactory::getInstance()->getCronValidator();
         $objCron->setCronId($this->requestParameter['cronId']);
         $objCron->setApplicationId($this->requestParameter['applicationId']);
         $objCron->setServerId($this->requestParameter['serverId']);
         $objCron->setMinute($this->requestParameter['minute']);
         $objCron->setHour($this->requestParameter['hour']);
         $objCron->setDay($this->requestParameter['day']);
         $objCron->setMonth($this->requestParameter['month']);
         $objCron->setWeekday($this->requestParameter['weekday']);
         $objCron->setCommand($this->requestParameter['command']);
         $objCron->setComment($this->requestParameter['comment']);
         $objCron->setUser($this->requestParameter['user']);
         $objCron->setCompletionTime($this->requestParameter['completionTime']);
         $objCron->setMaxConcurrency($this->requestParameter['maxConcurrency']);
         $objCron->setTimeAlert($this->requestParameter['timeAlert']);
         $objCron->setFromEmail($this->requestParameter['fromEmail']);
         $objCron->setToEmail($this->requestParameter['toEmail']);
         $objCron->setCronAlias($this->requestParameter['cronAlias']);
         $objCron->setCronOutput($this->requestParameter['cronOutput']);
         $objCron->setUpdatedBy($this->userEMAIL);
         //Application Check | Start
         $this->isActionAllowed($this->requestParameter['applicationId']);
         //Application Check | End
         //$errorArray = $objCronValidator->addValidation($objCron);
         if ($errorArray) {
             $errorArray['error'] = 'ERROR';
             echo json_encode($errorArray);
         } else {
             $this->objCronManager->editCron($objCron);
             $this->smarty->assign('success', 'Cron Job updated successfully');
         }
     }
     $cron = $this->objCronManager->getCron($cronId);
     //Application Check | Start
     $this->isActionAllowed($cron['applicationId']);
     //Application Check | End
     $cron['command'] = htmlentities($cron['command']);
     $this->smarty->assign('cron', $cron);
     $applications = $this->objApplicationManager->listApplication();
     $servers = $this->objServerManager->listServer();
     $cronUsers = $this->objCronManager->listCronUser();
     $this->smarty->assign('cronUsers', $cronUsers);
     $this->smarty->assign('servers', $servers);
     $this->smarty->assign('applications', $applications);
     $this->smarty->display('cron.html');
 }
コード例 #18
0
 private function editConfiguration()
 {
     $configurationId = $this->requestParameter['configurationId'];
     $configuration = $this->objConfigurationManager->getConfiguration($configurationId);
     if ($this->requestParameter['submit']) {
         $objConfiguration = new Configuration();
         $objConfigurationValidator = NCConfigFactory::getInstance()->getConfigurationValidator();
         $objConfiguration->setConfigurationId($this->requestParameter['configurationId']);
         $objConfiguration->setApplicationId($this->requestParameter['applicationId']);
         $objConfiguration->setServiceId($this->requestParameter['serviceId']);
         $objConfiguration->setSystemUserId($this->requestParameter['systemUserId']);
         $objConfiguration->setSystemUserId2($this->requestParameter['systemUserId2']);
         $objConfiguration->setConfigurationTag($this->requestParameter['configurationTag']);
         $errorArray = $objConfigurationValidator->editValidation($objConfiguration);
         if ($errorArray) {
             $this->smarty->assign('errors', $errorArray);
         } else {
             $serverId = $this->objConfigurationManager->editConfiguration($objConfiguration);
             $this->smarty->assign('success', 'Configuration (Id : ' . $configurationId . ') updated Successfully.');
             $this->listConfiguration();
             die;
         }
     }
     $applications = $this->objApplicationManager->listApplication();
     $services = $this->objServiceManager->listService();
     $systemUsers = $this->objSystemUserManager->listSystemUser();
     $this->smarty->assign('configuration', $configuration);
     $this->smarty->assign('applications', $applications);
     $this->smarty->assign('services', $services);
     $this->smarty->assign('systemUsers', $systemUsers);
     $this->smarty->display('configuration.html');
 }
コード例 #19
0
 private function getPassword($email)
 {
     $objUserManager = NCConfigFactory::getInstance()->getUserManager();
     return $objUserManager->getUser($email);
 }
コード例 #20
0
 private function changeConfigFile()
 {
     $date = date("Y-m-d");
     $release = date("YmdHis");
     shell_exec('cp -r ' . CONFIG_UPLOAD_PATH . ' ' . PROD_READY_FILES . $release . '_tmp');
     //Execute | File Change | Start
     $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
     $objConfigurationManager = NCConfigFactory::getInstance()->getConfigurationManager();
     $objConfigurationFileManager = NCConfigFactory::getInstance()->getConfigurationFileManager();
     $objServiceManager = NCConfigFactory::getInstance()->getServiceManager();
     $objSystemUserManager = NCConfigFactory::getInstance()->getSystemUserManager();
     $objServerManager = NCConfigFactory::getInstance()->getServerManager();
     $applications = $objApplicationManager->listApplication();
     $releaseLog = array();
     foreach ($applications as $application) {
         $applicationId = $application['applicationId'];
         $configurations = $objConfigurationManager->getApplicationConfiguration($applicationId);
         $configurationFile = $objConfigurationFileManager->getConfigurationFile($applicationId);
         foreach ($configurations as $configuration) {
             $serviceId = $configuration['serviceId'];
             $systemUserId = $configuration['systemUserId'];
             $service = $objServiceManager->getService($serviceId);
             $systemUser = $objSystemUserManager->getSystemUser($systemUserId);
             $server = $objServerManager->getServer($service['serverId']);
             $serverIP = $server['serverIP'];
             $servicePort = $service['servicePort'];
             $serviceDNS = $service['serviceDNS'];
             $serviceDNS2 = $service['serviceDNS2'];
             $serviceDNS3 = $service['serviceDNS3'];
             $username = $systemUser['username'];
             $password = $systemUser['password'];
             $configurationTag = $configuration['configurationTag'];
             foreach ($configurationFile as $file) {
                 $configFile = $file['configFile'];
                 $configFilePath = PROD_READY_FILES . $release . '_tmp' . '/' . $applicationId . '/' . $configFile;
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_IP' . TAG_DELIMITER, $serverIP, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_USERNAME' . TAG_DELIMITER, $username, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_PASSWORD' . TAG_DELIMITER, $password, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_PORT' . TAG_DELIMITER, $servicePort, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_DNS' . TAG_DELIMITER, $serviceDNS, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_DNS2' . TAG_DELIMITER, $serviceDNS2, file_get_contents($configFilePath)));
                 file_put_contents($configFilePath, str_replace(TAG_DELIMITER . $configurationTag . '_DNS3' . TAG_DELIMITER, $serviceDNS3, file_get_contents($configFilePath)));
                 $releaseLog[$applicationId][$configFile] = $configFile;
             }
         }
     }
     $this->objReleaseLogManager = NCConfigFactory::getInstance()->getReleaseLogManager();
     foreach ($releaseLog as $applicationId => $files) {
         foreach ($files as $file) {
             $this->objReleaseLogManager->addReleaseLog($date, $release, $applicationId, $file, $this->userEMAIL);
         }
     }
     $releaseComment = $this->requestParameter['releaseComment'];
     $this->objReleaseLogManager->addReleaseComment($date, $release, date('Y-m-d H:i:s'), $releaseComment, $this->userEMAIL);
     //Execute | File Change | End
     rename(PROD_READY_FILES . '/' . $release . '_tmp', PROD_READY_FILES . $release);
     $this->smarty->assign('success', 'Config files changed successfully');
     $this->listConfigFile();
 }
コード例 #21
0
 private function deleteServer()
 {
     $serverId = $this->requestParameter['serverId'];
     $objServerValidator = NCConfigFactory::getInstance()->getServerValidator();
     $errorArray = $objServerValidator->deleteValidation($serverId);
     if ($errorArray) {
         $this->smarty->assign('error', 'Server cannot be deleted');
     } else {
         $this->objServerManager->deleteServer($serverId);
         $this->smarty->assign('success', 'Server (Id : ' . $serverId . ') deleted Successfully.');
     }
     $this->listServer();
 }
コード例 #22
0
 private function deleteSystemUser()
 {
     $systemUserId = $this->requestParameter['systemUserId'];
     $objSystemUserValidator = NCConfigFactory::getInstance()->getSystemUserValidator();
     $errorArray = $objSystemUserValidator->deleteValidation($systemUserId);
     if ($errorArray) {
         $this->smarty->assign('error', 'SystemUser cannot be deleted');
     } else {
         //Delete SystemUser.
         $this->objSystemUserManager->deleteSystemUser($systemUserId);
         $this->smarty->assign('success', 'SystemUser deleted successfully');
     }
     $this->listSystemUser();
 }
コード例 #23
0
 private function connectionGraph()
 {
     if ($this->requestParameter['submit']) {
         $applicationId = $this->requestParameter['applicationId'];
         $serviceTypeId = $this->requestParameter['serviceTypeId'];
     }
     $objApplicationManager = NCConfigFactory::getInstance()->getApplicationManager();
     $objServiceTypeManager = NCConfigFactory::getInstance()->getServiceTypeManager();
     $objReportManager = NCConfigFactory::getInstance()->getReportManager();
     $applications = $objApplicationManager->listApplication();
     if ($applicationId) {
         $apps[] = $objApplicationManager->getApplication($applicationId);
     } else {
         $apps = $applications;
     }
     $serviceTypes = $objServiceTypeManager->listServiceType();
     $colors = $this->getColorCodes();
     $colorCodes = array();
     $i = 0;
     foreach ($apps as $application) {
         $colorCodes[$application['applicationId']] = $colors[$i];
         $i++;
     }
     $connectionGraph = $objReportManager->connectionGraph($applicationId, $serviceTypeId);
     foreach ($connectionGraph as $key => $conn) {
         $conn['color'] = $colorCodes[$conn['applicationId']];
         $connectionGraph[$key] = $conn;
     }
     $servers = array();
     foreach ($connectionGraph as $connection) {
         $servers[] = array('serverId' => $connection['serverId'], 'serverName' => $connection['serverName']);
     }
     $this->smarty->assign('servers', $servers);
     $this->smarty->assign('applications', $applications);
     $this->smarty->assign('apps', $apps);
     $this->smarty->assign('serviceTypes', $serviceTypes);
     $this->smarty->assign('applicationId', $applicationId);
     $this->smarty->assign('serviceTypeId', $serviceTypeId);
     $this->smarty->assign('connectionInfo', $connectionGraph);
     $this->smarty->display('connectionGraph.html');
 }