예제 #1
0
파일: ElbApi.php 프로젝트: rickb838/scalr
 /**
  * CreateLoadBalancerListeners action
  *
  * Creates one or more listeners on a LoadBalancer for the specified port. If a listener with the given port
  * does not already exist, it will be created; otherwise, the properties of the new listener must match the
  * properties of the existing listener.
  *
  * @param    string           $loadBalancerName  A load balancer name.
  * @param    ListenerList     $listenersList     An ListenerList object that holds list of LoadBalancerPort,
  *                                               InstancePort, Protocol, Yes and SSLCertificateId items.
  * @return   boolean          Returns TRUE if listeners are successfully created.
  * @throws   ClientException
  */
 public function createLoadBalancerListeners($loadBalancerName, ListenerList $listenersList)
 {
     $result = false;
     $options = array('LoadBalancerName' => (string) $loadBalancerName);
     $options = array_merge($options, $listenersList->getQueryArray());
     $response = $this->client->call('CreateLoadBalancerListeners', $options);
     if ($response->getError() === false) {
         //Success
         /* @var $loadBalancer LoadBalancerDescriptionData */
         $loadBalancer = $this->elb->loadBalancer->get($options['LoadBalancerName']);
         if ($loadBalancer !== null) {
             //Updates listenerDescriptions for the LoadBalancer object.
             if ($loadBalancer->listenerDescriptions instanceof ListenerDescriptionList || $loadBalancer->listenerDescriptions !== $listenersList) {
                 $old = array();
                 /* @var $listener ListenerData */
                 foreach ($loadBalancer->listenerDescriptions->getComputed() as $listener) {
                     //Listeners are removed by loadBalancerPort, so we use it as primary key
                     //to compare.
                     $old[$listener->loadBalancerPort] = $listener;
                 }
                 //Append to existing load balancer new listeners which have just been created.
                 foreach ($listenersList as $listener) {
                     if (!array_key_exists($listener->loadBalancerPort, $old)) {
                         $listenerDescription = new ListenerDescriptionData();
                         $listenerDescription->setElb($this->elb);
                         $listenerDescription->listener = $listener;
                         $loadBalancer->listenerDescriptions->append($listenerDescription);
                         unset($listenerDescription);
                     }
                     //It's not allowed to change an existing lisntener properties
                     //in this api method. It will cause DuplicateListener error, therefore
                     //it's no sence to update listener's properties which are received from response.
                 }
                 unset($old);
             }
         }
         $result = true;
     }
     return $result;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  * @see Scalr\Service\Aws\DataType.ListDataType::getQueryArray()
  */
 public function getQueryArray($uriParameterName = 'Listeners', $member = true)
 {
     //Returns listeners parameters
     $listenerList = new ListenerList($this->getComputed());
     return $listenerList->getQueryArray($uriParameterName);
 }