Commit af0edcde authored by Ryo Yamashita's avatar Ryo Yamashita Committed by Yas Naoi
Browse files

Issue #3306992 by Ryo Yamashita, yas: Add the function to associate AWS Cloud Elastic IP in the SPA

parent ebc13542
Loading
Loading
Loading
Loading
+36 −2
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/elastic_ip.ts: 36 added lines, 2 removed lines.
Original line number Diff line number Diff line
import EntityFormTemplate from 'model/EntityFormTemplate';

const AWS_CLOUD_ELASTIC_IP_TEMPLATE: EntityFormTemplate[] = [
  {
    cloudServiceProvider: 'aws_cloud',
    entityName: 'elastic_ip',
    actionType: 'associate',
    entityRecords: [
      {
        type: 'panel',
        panelName: 'Select the instance OR network interface',
        keyValueRecords: [
          { type: 'select-local', name: 'resource_type', labelName: 'Resource type', defaultValue: 'instance', value: [
            { name: 'instance', labelName: 'Instance' },
            { name: 'network_interface', labelName: 'Network interface' },
          ] },
          { type: 'select', labelName: 'Instance', name: 'instance_id',
            url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/unassociated_instance_ids',
            defaultValue: ''
          },
          { type: 'select', labelName: 'Private IP', name: 'instance_private_ip',
            url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/instance_private_ips/{instance_id}',
            defaultValue: ''
          },
          { type: 'select', labelName: 'Network interface', name: 'network_interface_id',
            url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/unassociated_network_interface_ids',
            defaultValue: ''
          },
          { type: 'select', labelName: 'Private IP', name: 'network_interface_private_ip',
            url: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/network_interface_private_ips/{network_interface_id}',
            defaultValue: ''
          },
        ]
      }
    ],
    submitButtonLabel: 'Associate Address'
  },
  {
    cloudServiceProvider: 'aws_cloud',
    entityName: 'elastic_ip',
@@ -45,13 +79,13 @@ const AWS_CLOUD_ELASTIC_IP_TEMPLATE: EntityFormTemplate[] = [
        keyValueRecords: [
          {
            type: 'join', labelName: 'Instance ID', name: 'instance_id', info: {
              entityTypeId: 'openstack_instance',
              entityTypeId: 'aws_cloud_instance',
              keyColumn: 'name',
            }, defaultValue: '', readOnly: true
          },
          {
            type: 'join', labelName: 'Network interface ID', name: 'network_interface_id', info: {
              entityTypeId: 'openstack_network_interface',
              entityTypeId: 'aws_cloud_network_interface',
              keyColumn: 'name',
            }, defaultValue: '', readOnly: true
          },
+1 −1
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/floating_ip.ts: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ const OPENSTACK_FLOATING_IP_TEMPLATE: EntityFormTemplate[] = [
        ]
      }
    ],
    submitButtonLabel: 'Disassociate Address'
    submitButtonLabel: 'Associate Address'
  },
  {
    cloudServiceProvider: 'openstack',
+7 −4
Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/DataTableRowWithOperationLinks.tsx: 7 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -62,8 +62,9 @@ const getOperations = (dataRecord: DataRecord): string[] => {
      return list;
    }
    case 'aws_cloud_elastic_ip':
      return dataRecord.value['allocation_id'] === ''
        || dataRecord.value['allocation_id'] === null
      return dataRecord.value['association_id'] === ''
        || dataRecord.value['association_id'] === null
        || dataRecord.value['association_id'] === undefined
        ? ['Associate']
        : ['Disassociate'];
    case 'aws_cloud_snapshot':
@@ -115,13 +116,15 @@ const getOperations = (dataRecord: DataRecord): string[] => {
      return list;
    }
    case 'openstack_floating_ip':
      return dataRecord.value['instance_id'] === ''
        || dataRecord.value['instance_id'] === null
      return dataRecord.value['association_id'] === ''
        || dataRecord.value['association_id'] === null
        || dataRecord.value['association_id'] === undefined
        ? ['Associate']
        : ['Disassociate'];
    case 'openstack_volume':
      return dataRecord.value['attachment_information'] === ''
        || dataRecord.value['attachment_information'] === null
        || dataRecord.value['attachment_information'] === undefined
        ? ['Attach']
        : ['Detach'];
    case 'vmware_vm':
+19 −0
Changes for modules/cloud_dashboard/cloud_dashboard/src/organisms/EntityFormPanel.tsx: 19 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -24,6 +24,24 @@ const showEntityFormBlockFlg = (
  entityFormColumn: EntityFormColumn,
  formData: Record<string, any>
) => {
  // Associate AWS Cloud Elastic IP
  if (actionType === 'associate'
    && cloudServiceProvider === 'aws_cloud'
    && entityName === 'elastic_ip') {
    if (entityFormColumn.type === 'select') {
      switch (entityFormColumn.name) {
        case 'instance_id':
          return formData['resource_type'] === 'instance';
        case 'instance_private_ip':
          return formData['resource_type'] === 'instance';
        case 'network_interface_id':
          return formData['resource_type'] === 'network_interface';
        case 'network_interface_private_ip':
          return formData['resource_type'] === 'network_interface';
      }
    }
  }

  // Create K8s deployment
  if (actionType === 'create'
    && cloudServiceProvider === 'k8s'
@@ -72,6 +90,7 @@ const showEntityFormBlockFlg = (
    }
  }

  // Create AWS Cloud VPC Peering Connection
  if (actionType === 'create'
    && cloudServiceProvider === 'aws_cloud'
    && entityName === 'vpc_peering_connection') {
+78 −0
Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 78 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -893,6 +893,84 @@ entity.aws_cloud_entity.refresh:
  options:
    perm: 'edit any {entity_type_id}+edit own {entity_type_id}+list {entity_type_id}'

entity.aws_cloud_elastic_ip.unassociated_instance_ids:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/unassociated_instance_ids'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getUnassociatedInstanceOptions'
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.unassociated_network_interface_ids:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/unassociated_network_interface_ids'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getUnassociatedNetworkInterfaceOptions'
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.instance_private_ips_default:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/instance_private_ips'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getInstancePrivateIps'
    instance_id: ''
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.instance_private_ips:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/instance_private_ips/{instance_id}'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getInstancePrivateIps'
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.network_interface_private_ips_default:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/network_interface_private_ips'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getNetworkInterfacePrivateIps'
    network_interface_id: ''
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.network_interface_private_ips:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/network_interface_private_ips/{network_interface_id}'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getNetworkInterfacePrivateIps'
  requirements:
    # Use custom access that will check for cloud_context and the desired permission.
    # Desired permission is passed as an option in the "perm" variable
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
    perm: 'edit any aws cloud elastic ip+edit own aws cloud elastic ip'

entity.aws_cloud_elastic_ip.associate:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/{entity_id}/associate'
  defaults:
    _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity'
    entity_type_id: aws_cloud_elastic_ip
    command: associate
  methods: [POST]
  requirements:
    _entity_access: 'aws_cloud_elastic_ip.associate'

entity.aws_cloud_elastic_ip.create:
  path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/create'
  defaults:
Loading