コード例 #1
0
ファイル: TestUtil.php プロジェクト: Tom-Byrne/gocdb
 public static function createSampleService($label)
 {
     $se = new Service();
     $se->setHostName('' . $label);
     $se->setBeta(false);
     $se->setProduction(true);
     $se->setMonitored(true);
     return $se;
 }
コード例 #2
0
ファイル: ServiceService.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Array
  * (
  *     [Service_Type] => 21
  *     [EndpointURL] => Testing://host.com
  *     [Scope] => 2
  *     [Hosting_Site] => 377
  *     [SE] => Array
  *     (
  *         [ENDPOINT] => my.new.host.com21
  *         [HOSTNAME] => my.new.host.com
  *         [HOST_IP] => 10.0.0.1
  *         [HOST_DN] => /cn=JCasson
  *         [HOST_IP_V6] => 0000:0000:0000:0000:0000:0000:0000:0000[/int]
  *         [DESCRIPTION] => hithere
  *         [HOST_OS] =>
  *         [HOST_ARCH] =>
  *         [BETA] => Y
  *         [PRODUCTION_LEVEL] => Y
  *         [IS_MONITORED] => Y
  *         [EMAIL] =>
  *     )
  * )
  * @param Array $values Balues for the new SE (defined above)
  * @param org\gocdb\services\User $user The user adding the SE
  */
 public function addService($values, \User $user = null)
 {
     $this->em->getConnection()->beginTransaction();
     // get the parent site
     $dql = "SELECT s from Site s WHERE s.id = :id";
     $site = $this->em->createQuery($dql)->setParameter('id', $values['hostingSite'])->getSingleResult();
     // get the service type
     $st = $this->getServiceType($values['serviceType']);
     $siteService = new \org\gocdb\services\Site();
     $siteService->setEntityManager($this->em);
     if (count($siteService->authorizeAction(\Action::SITE_ADD_SERVICE, $site, $user)) == 0) {
         throw new \Exception("You don't hold a role over {$site}.");
     }
     $this->validate($values['SE'], 'service');
     $this->validateEndpointUrl($values['endpointUrl']);
     $this->uniqueCheck($values['SE']['HOSTNAME'], $st, $site);
     //check there are the required number of scopes specified
     $this->checkNumberOfScopes($values['Scope_ids']);
     // validate production/monitored combination
     if ($st != 'VOMS' && $st != 'emi.ARGUS') {
         if ($values['PRODUCTION_LEVEL'] == "Y" && $values['IS_MONITORED'] != "Y") {
             throw new \Exception("If Production flat is set to True, Monitored flag must also be True (except for VOMS and emi.ARGUS)");
         }
     }
     $se = new \Service();
     try {
         $se->setParentSiteDoJoin($site);
         $se->setServiceType($st);
         // Set production
         if ($values['PRODUCTION_LEVEL'] == "Y") {
             $se->setProduction(true);
         } else {
             $se->setProduction(false);
         }
         // Set Beta
         if ($values['BETA'] == "Y") {
             $se->setBeta(true);
         } else {
             $se->setBeta(false);
         }
         // Set monitored
         if ($values['IS_MONITORED'] == "Y") {
             $se->setMonitored(true);
         } else {
             $se->setMonitored(false);
         }
         // Set the scopes
         foreach ($values['Scope_ids'] as $scopeId) {
             $dql = "SELECT s FROM Scope s WHERE s.id = :id";
             $scope = $this->em->createQuery($dql)->setParameter('id', $scopeId)->getSingleResult();
             $se->addScope($scope);
         }
         $se->setDn($values['SE']['HOST_DN']);
         $se->setIpAddress($values['SE']['HOST_IP']);
         $se->setOperatingSystem($values['SE']['HOST_OS']);
         $se->setArchitecture($values['SE']['HOST_ARCH']);
         $se->setHostName($values['SE']['HOSTNAME']);
         $se->setDescription($values['SE']['DESCRIPTION']);
         $se->setEmail($values['SE']['EMAIL']);
         $se->setUrl($values['endpointUrl']);
         /* With version 5.3 a service does not have to have an endpoint. 
            $el = new \EndpointLocation();
            $el->setUrl($values['endpointUrl']);
            $se->addEndpointLocationDoJoin($el);
            $this->em->persist($el);
            */
         $this->em->persist($se);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
     return $se;
 }
コード例 #3
0
 $doctrineSe->setParentSiteDoJoin($parentSite);
 // get the hosting service type
 $dql = "SELECT s from ServiceType s WHERE s.name = ?1";
 $sts = $entityManager->createQuery($dql)->setParameter(1, (string) $xmlSe->SERVICE_TYPE)->getResult();
 /* Error checking: ensure each SE's "SERVICE_TYPE" refers to exactly
  * one SERVICE_TYPE */
 if (count($sts) !== 1) {
     throw new Exception(count($sts) . " SERVICE_TYPEs found with name: " . $xmlSe->SERVICE_TYPE);
 }
 foreach ($sts as $st) {
     $st = $st;
 }
 $doctrineSe->setServiceType($st);
 // Set production
 if ((string) $xmlSe->IN_PRODUCTION == "Y") {
     $doctrineSe->setProduction(true);
 } else {
     $doctrineSe->setProduction(false);
 }
 // Set Beta
 if ((string) $xmlSe->BETA == "Y") {
     $doctrineSe->setBeta(true);
 } else {
     $doctrineSe->setBeta(false);
 }
 // Set monitored
 if ((string) $xmlSe->NODE_MONITORED == "Y") {
     $doctrineSe->setMonitored(true);
 } else {
     $doctrineSe->setMonitored(false);
 }