Source for file soapController.class.php
Documentation is available at soapController.class.php
require_once 'SOAP/Client.php';
* Since we're bypassing Symfony's action dispatcher, we have to initialize manually.
$this->context = sfContext::getInstance();
$this->request = $this->context->getRequest();
$this->__dispatch_map['initializeVirtAgent'] = array(
'in' => array('agent_name'=> 'string',
'agent_memfree'=> 'integer',
'agent_state'=> 'integer'),
'out' => array('return'=> "{urn:soapController}Tuple")
$this->__typedef['Tuple'] = array('success'=> 'boolean','insert_id'=> integer);
$this->__dispatch_map['updateVirtAgent'] = array(
'in' => array('uid'=> 'string',
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentVlan'] = array(
'in' => array('uid'=> 'string',
'vlans'=> array('string')),
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentDevices'] = array(
'in' => array('uid'=> 'string',
'devs'=> array('string')),
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentPvs'] = array(
'in' => array('uid'=> 'string',
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentLvs'] = array(
'in' => array('uid'=> 'string',
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentVgs'] = array(
'in' => array('uid'=> 'string',
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__dispatch_map['updateVirtAgentServers'] = array(
'in' => array('uid'=> 'string',
'out' => array('return'=> "{urn:soapController}ArraySuccess")
$this->__typedef['ArraySuccess'] = array('success'=> 'boolean');
protected function soapAuth($domain,$password){
$c->add(UserPeer::USERNAME ,$domain);
$c->add(UserPeer::PASSWORD ,$password);
$check = UserPeer::doSelectOne($c);
$user = $this->context->getUser();
$user->addCredential($check->getCredential());
$user->setAuthenticated(true);
throw new Exception('Soap Authentication failed');
throw new SoapFault("1",$e->getMessage());
* receives initialization data from node virt agent and store it in db
function initializeVirtAgent($node_name, $node_mem, $node_memfree, $node_cpu, $node_ip, $node_port, $node_uid, $node_state){
// $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)
'memfree'=> $node_memfree,
$this->request->setParameter('etva_node', $array);
$action = $this->getAction('node','soapCreate');
$result = $action->executeSoapCreate($this->request);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('field',$node_field);
$this->request->setParameter('value',$node_value);
$action = $this->getAction('node','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('vms',$vms);
$action = $this->getAction('server','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('vlans',$vlans);
$action = $this->getAction('vlan','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('devs',$devs);
$action = $this->getAction('physicalvol','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
// $this->request->setParameter('uid', $node_uid);
// $this->request->setParameter('lvs',$lvs);
// $action = $this->getAction('logicalvol','soapUpdate');
// $result = $action->executeSoapUpdate($this->request);
$result = array('success'=> true);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('lvs',$lvs);
$action = $this->getAction('logicalvol','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
$this->request->setParameter('uid', $node_uid);
$this->request->setParameter('vgs',$vgs);
$action = $this->getAction('volgroup','soapUpdate');
$result = $action->executeSoapUpdate($this->request);
$host = "" . $proto . "://" . $addr . ":" . $port;
$soapclient = new SOAP_Client($host,false,$port);
$a = array("nil"=> "true");
//$method = "listDomains";
$ret = $soapclient->call($meth,array($a));
//if (is_a($ret, 'PEAR_Error')) {
// echo $soapclient->getLastRequest() . "\n";
// echo 'Error: ' . $ret->getMessage() . "\n";
// $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)
// $this->request->setParameter('number',$number);
// $action = $this->getAction('soapapi','getFactorial');
// $result = $action->executeGetFactorial();
|