Commit 6fb3236e authored by Yas Naoi's avatar Yas Naoi
Browse files

Issue #2736821: aws_cloud - Supported Availability Zone selection in a launch instance form

parent 0d1176ee
Loading
Loading
Loading
Loading
+13 −9
Changes for modules/cloud_service_providers/aws_cloud/src/Form/Ec2/InstanceLaunchForm.php: 13 added lines, 9 removed lines.
Original line number Diff line number Diff line
<?php

// Updated by yas 2016/09/06
// Updated by yas 2016/09/04
// Updated by yas 2016/06/20
// Updated by yas 2016/06/03
@@ -28,6 +29,8 @@ use Aws\Result;
 */
class InstanceLaunchForm extends CloudContentForm {

  private $apiController = NULL;

  /**
   * Overrides Drupal\Core\Entity\EntityFormController::buildForm().
   *
@@ -41,7 +44,7 @@ class InstanceLaunchForm extends CloudContentForm {
    if(isset($cloudContext)) {

      $cloud_type = $cloudContext->cloud_type();

      $this->apiController = new ApiController($this->query_factory);
    }
    else {

@@ -135,20 +138,23 @@ class InstanceLaunchForm extends CloudContentForm {
    );

    $form['is_monitoring'] = array(
      '#type'          => 'textfield',
      '#type'          => 'select',
      '#title'         => $this->t('Monitoring Enabled'),
      '#default_value' => FALSE,
      '#options'       => array(0 => t('No'), 1 => t('Yes')),
      '#default_value' => 0,
      '#weight'        => -5,
      '#required'      => TRUE,
    // '#attributes'    => array('readonly' => 'readonly'),
    //    '#disabled'      => TRUE,.
    );

    $availability_zones = $this->apiController->getAvailabilityZones($cloudContext);
    $form['availability_zone'] = array(
      '#type'          => 'textfield',
      '#type'          => 'select',
      '#title'         => $this->t('Availability Zone'),
      '#size'          => 60,
      '#default_value' => $entity->availability_zone(),
      '#options'       => $availability_zones,
      // Pick up the first availability zone in the array
      '#default_value' => array_shift($availability_zones),
      '#weight'        => -5,
      '#required'      => TRUE,
    // '#attributes'    => array('readonly' => 'readonly'),
@@ -237,10 +243,8 @@ class InstanceLaunchForm extends CloudContentForm {
  public function save(array $form, FormStateInterface $form_state) {

    $entity = $this->entity;
    $apiController = new ApiController($this->query_factory);
 
    $entity->setParams($form);
    $result = $apiController->launchInstance($entity);
    $result = $this->apiController->launchInstance($entity);

    $status  = 'error';
    $message = $this->t('The @type "@label" failed to launch.', array(