propel
[ class tree: propel ] [ index: propel ] [ all elements ]

Source for file soapController.class.php

Documentation is available at soapController.class.php

  1. <?php
  2. require_once 'SOAP/Client.php';
  3.  
  4. class soapController extends sfController {
  5.  
  6.  
  7.   // public $request;
  8.  
  9.    public function __construct(){
  10.       /**
  11.        * Since we're bypassing Symfony's action dispatcher, we have to initialize manually.
  12.        */
  13.       $this->context sfContext::getInstance();
  14.       $this->request $this->context->getRequest();
  15.  
  16.       
  17.       $this->__dispatch_map['initializeVirtAgent'array(
  18.                                                      'in'    => array('agent_name'=>'string',
  19.                                                                         'agent_mem'=>'integer',
  20.                                                                         'agent_memfree'=>'integer',
  21.                                                                         'agent_cpu'=>'integer',
  22.                                                                         'agent_ip'=>'string',
  23.                                                                         'agent_port'=>'integer',
  24.                                                                         'agent_uid'=>'string',
  25.                                                                         'agent_state'=>'integer'),
  26.                                                      'out'   => array('return'=>"{urn:soapController}Tuple")
  27.                                                     );
  28.  
  29.       $this->__typedef['Tuple'array('success'=>'boolean','insert_id'=>integer);
  30.  
  31.       $this->__dispatch_map['updateVirtAgent'array(
  32.                                                         'in'    => array('uid'=>'string',
  33.                                                                         'field'=>'string',
  34.                                                                         'value'=>'string'),
  35.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  36.                                                      );
  37.      
  38.      $this->__dispatch_map['updateVirtAgentVlan'array(
  39.                                                         'in'    => array('uid'=>'string',
  40.                                                                         'vlans'=>array('string')),
  41.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  42.                                                      );
  43.                                                      
  44.      $this->__dispatch_map['updateVirtAgentDevices'array(
  45.                                                         'in'    => array('uid'=>'string',
  46.                                                                         'devs'=>array('string')),
  47.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  48.                                                      );
  49.  
  50. $this->__dispatch_map['updateVirtAgentPvs'array(
  51.                                                         'in'    => array('uid'=>'string',
  52.                                                                         'pvs'=>array('string')),
  53.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  54.                                                      );
  55.  
  56. $this->__dispatch_map['updateVirtAgentLvs'array(
  57.                                                         'in'    => array('uid'=>'string',
  58.                                                                         'lvs'=>array('string')),
  59.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  60.                                                      );
  61.  
  62.  
  63.      $this->__dispatch_map['updateVirtAgentVgs'array(
  64.                                                         'in'    => array('uid'=>'string',
  65.                                                                         'vgs'=>array('string')),
  66.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  67.                                                      );
  68.  
  69.  
  70.      $this->__dispatch_map['updateVirtAgentServers'array(
  71.                                                         'in'    => array('uid'=>'string',
  72.                                                                         'vms'=>array('string')),
  73.                                                         'out'   => array('return'=>"{urn:soapController}ArraySuccess")
  74.                                                      );
  75.  
  76.       $this->__typedef['ArraySuccess'array('success'=>'boolean');
  77.  
  78.  
  79.  
  80.    }
  81.  
  82.  
  83.    
  84.  
  85.    protected function soapAuth($domain,$password){
  86.      try {
  87.  
  88.        $c new Criteria();
  89.        $c->add(UserPeer::USERNAME ,$domain);
  90.        $c->add(UserPeer::PASSWORD ,$password);
  91.  
  92.        $check UserPeer::doSelectOne($c);
  93.  
  94.        if($check){
  95.          $user $this->context->getUser();
  96.          $user->addCredential($check->getCredential());
  97.          $user->setAuthenticated(true);
  98.        }else{
  99.          throw new Exception('Soap Authentication failed');
  100.        }
  101.      }catch (Exception $e){
  102.        throw new SoapFault("1",$e->getMessage());
  103.      }
  104.    }
  105.  
  106.   
  107.  
  108.  
  109.    /*
  110.     * receives initialization data from node virt agent and store it in db
  111.     */
  112.    function initializeVirtAgent($node_name$node_mem$node_memfree$node_cpu$node_ip$node_port$node_uid$node_state){
  113.  
  114. //     $this->soapAuth($user, $password); //I call this at the start of each function call in the soap controller (You can choose not to do it)
  115.  
  116.     $array array(
  117.                 'name'=>$node_name,
  118.                 'memtotal'=>$node_mem,
  119.                 'memfree'=>$node_memfree,
  120.                 'cputotal'=>$node_cpu,
  121.                 'ip'=>$node_ip,
  122.                 'port'=>$node_port,
  123.                 'uid'=>$node_uid,
  124.                 'state'=>$node_state);
  125.  
  126.  
  127.     $this->request->setParameter('etva_node'$array);
  128.  
  129.     $action $this->getAction('node','soapCreate');
  130.     $result $action->executeSoapCreate($this->request);
  131.  
  132.     return $result;
  133.    }
  134.  
  135.    function updateVirtAgent($node_uid$node_field$node_value)
  136.    {
  137.  
  138.     $array array(
  139.                 'field'=>$node_field,
  140.                 'value'=>$node_value,
  141.              );
  142.     $this->request->setParameter('uid'$node_uid);
  143.     $this->request->setParameter('field',$node_field);
  144.     $this->request->setParameter('value',$node_value);
  145.  
  146.     $action $this->getAction('node','soapUpdate');
  147.     $result $action->executeSoapUpdate($this->request);
  148.  
  149.     return $result;
  150.    }
  151.  
  152.    function updateVirtAgentServers($node_uid$vms)
  153.    {
  154.        
  155.  
  156.    
  157.     $this->request->setParameter('uid'$node_uid);
  158.     $this->request->setParameter('vms',$vms);
  159.  
  160.     $action $this->getAction('server','soapUpdate');
  161.     $result $action->executeSoapUpdate($this->request);
  162.  
  163.     return $result;
  164.    }
  165.  
  166.  
  167.    function updateVirtAgentVlan($node_uid$vlans)
  168.    {
  169.  
  170.     $array array(
  171.                 'field'=>$node_field,
  172.                 'value'=>$node_value,
  173.              );
  174.     $this->request->setParameter('uid'$node_uid);
  175.     $this->request->setParameter('vlans',$vlans);
  176.  
  177.     $action $this->getAction('vlan','soapUpdate');
  178.     $result $action->executeSoapUpdate($this->request);
  179.  
  180.     return $result;
  181.    }
  182.  
  183.  
  184.    function updateVirtAgentDevices($node_uid$devs)
  185.    {
  186.  
  187.     
  188.     $this->request->setParameter('uid'$node_uid);
  189.     $this->request->setParameter('devs',$devs);
  190.  
  191.     $action $this->getAction('physicalvol','soapUpdate');
  192.     $result $action->executeSoapUpdate($this->request);
  193.  
  194.     return $result;
  195.    }
  196.  
  197.    function updateVirtAgentPvs($node_uid$lvs)
  198.    {
  199.  
  200.  
  201. //    $this->request->setParameter('uid', $node_uid);
  202. //    $this->request->setParameter('lvs',$lvs);
  203. //
  204. //    $action = $this->getAction('logicalvol','soapUpdate');
  205. //    $result = $action->executeSoapUpdate($this->request);
  206.     $result array('success'=>true);
  207.     return $result;
  208.    }
  209.  
  210.  
  211.    function updateVirtAgentLvs($node_uid$lvs)
  212.    {
  213.  
  214.  
  215.     $this->request->setParameter('uid'$node_uid);
  216.     $this->request->setParameter('lvs',$lvs);
  217.  
  218.     $action $this->getAction('logicalvol','soapUpdate');
  219.     $result $action->executeSoapUpdate($this->request);
  220.  
  221.     return $result;
  222.    }
  223.  
  224.  
  225.    function updateVirtAgentVgs($node_uid$vgs)
  226.    {
  227.  
  228.  
  229.     $this->request->setParameter('uid'$node_uid);
  230.     $this->request->setParameter('vgs',$vgs);
  231.  
  232.     $action $this->getAction('volgroup','soapUpdate');
  233.     $result $action->executeSoapUpdate($this->request);
  234.  
  235.     return $result;
  236.    }
  237.  
  238.  
  239.  
  240.  
  241.  
  242.    function GetNodeServersSoap($method){
  243.  
  244.     
  245.  
  246. $addr "10.10.20.67";
  247. $port 7001;
  248. $proto "tcp";
  249. $host "" $proto "://" $addr ":" $port;
  250. $soapclient new SOAP_Client($host,false,$port);
  251.  
  252. $a array("nil"=>"true");
  253.  
  254. //$method = "listDomains";
  255. $meth $method;
  256.  
  257. $ret $soapclient->call($meth,array($a));
  258.  
  259. //if (is_a($ret, 'PEAR_Error')) {
  260. //    echo $soapclient->getLastRequest() . "\n";
  261. //    echo 'Error: ' . $ret->getMessage() . "\n";
  262. //} else {
  263. //    print_r($ret);
  264. //}
  265.  
  266.  
  267.  //    $this->soapAuth($user, $password); //I call this at the start of each function call in the soap controller (You can choose not to do it)
  268. //     $this->request->setParameter('number',$number);
  269.  
  270.   //   $action = $this->getAction('soapapi','getFactorial');
  271.   //   $result = $action->executeGetFactorial();
  272.  
  273.      return $ret;
  274.    }
  275.  
  276.  
  277.  
  278.  
  279. }
  280. ?>

Documentation generated on Fri, 19 Jun 2009 10:49:30 +0100 by phpDocumentor 1.4.2