示例#1
0
 /**
  * @Route("/check/serverip/{ip}", name="_check_serverip", requirements={
  *   "ip": "[0-9.]+"
  * })
  * @Method({"GET","HEAD"})
  */
 public function checkserveripAction(Request $request, $ip)
 {
     $platformPeer = new PlatformPeer();
     $base_dn = $platformPeer->getConfig()->getDomainConfiguration($platformPeer->getConfig()->getDefaultDomain())->getBaseDn();
     $serverPeer = new ServerPeer($base_dn);
     $servers = $serverPeer->getLdapManager()->getRepository('server')->getServerByIpAddress($ip);
     $response = new JsonResponse();
     $response->setData(array('data' => count($servers)));
     return $response;
 }
示例#2
0
 /**
  * @Route("/server/{platformid}/{serverid}/edit", name="_server_edit", requirements={
  *     "platformid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})",
  *     "serverid": "([a-z0-9]{8})(\-[a-z0-9]{4}){3}(\-[a-z0-9]{12})"
  * })
  */
 public function editAction(Request $request, $platformid, $serverid)
 {
     $platform_repository = (new PlatformPeer())->getLdapManager()->getRepository('platform');
     $platform = $platform_repository->getPlatformByUUID($platformid);
     $serverPeer = new ServerPeer($platform->getDn());
     $server_repository = $serverPeer->getLdapManager()->getRepository('server');
     $serverLdap = $server_repository->getServerByUUID($serverid);
     $tranformer = new ZacaciaTransformer();
     $server = $tranformer->transServer($serverLdap);
     $form = $this->createForm(ServerType::class, $server);
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $serverLdap->setZacaciastatus($server->getZacaciastatus());
             $serverPeer->updateServer($serverLdap);
             return $this->redirectToRoute('_server', array('platformid' => $platform->getEntryUUID()));
         } catch (LdapConnectionException $e) {
             echo "Failed to update server!" . PHP_EOL;
             echo $e->getMessage() . PHP_EOL;
         }
     }
     return $this->render('ZacaciaBundle:Server:edit.html.twig', array('platform' => $platform, 'server' => $server, 'form' => $form->createView()));
 }