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

Issue #3295695 by Ryo Yamashita, yas: Add the function to revoke AWS Cloud...

Issue #3295695 by Ryo Yamashita, yas: Add the function to revoke AWS Cloud security group in the SPA
parent 6f01316d
Loading
Loading
Loading
Loading
+18 −3
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/entity_info_template/aws_cloud/security_group.ts: 18 added lines, 3 removed lines.
Original line number Diff line number Diff line
import EntityInfoTemplate from 'model/EntityInfoTemplate';
import { ROUTE_URL } from 'constant/other';
import EntityColumn from 'model/EntityColumn';
import EntityInfoTemplate from 'model/EntityInfoTemplate';

// Template for displaying the Launch template in K8s.
const COLUMN_RULES: EntityColumn[] = [
@@ -18,6 +19,20 @@ const COLUMN_RULES: EntityColumn[] = [
  { labelName: 'Description', 'name': 'description', type: 'default' },
];

const INBOUND_COLUMN_RULES: EntityColumn[] = COLUMN_RULES.concat([
  { labelName: 'Operation', name: 'operation', type: 'link',
    label: 'Revoke',
    url: `${ROUTE_URL}/{cloudServiceProvider}/{cloudContext}/{entityName}/{entityId}/revoke?type=ip_permission&position={index}`,
  }
]);

const OUTBOUND_COLUMN_RULES: EntityColumn[] = COLUMN_RULES.concat([
  { labelName: 'Operation', name: 'operation', type: 'link',
    label: 'Revoke',
    url: `${ROUTE_URL}/{cloudServiceProvider}/{cloudContext}/{entityName}/{entityId}/revoke?type=outbound_permission&position={index}`,
  }
]);

const AWS_CLOUD_SECURITY_GROUP_TEMPLATE: EntityInfoTemplate = {
  cloudServiceProvider: 'aws_cloud',
  entityName: 'security_group',
@@ -37,8 +52,8 @@ const AWS_CLOUD_SECURITY_GROUP_TEMPLATE: EntityInfoTemplate = {
      panelName: 'Rules',
      tableRecordList: ['outbound_permission'],
      keyValueRecords: [
        { labelName: 'Inbound Rules', name: 'ip_permission', type: 'custom-table', column: COLUMN_RULES },
        { labelName: 'Outbound Rules', name: 'outbound_permission', type: 'custom-table', column: COLUMN_RULES },
        { labelName: 'Inbound Rules', name: 'ip_permission', type: 'custom-table', column: INBOUND_COLUMN_RULES },
        { labelName: 'Outbound Rules', name: 'outbound_permission', type: 'custom-table', column: OUTBOUND_COLUMN_RULES },
      ]
    },
  ]
+18 −0
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/security_group.ts: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
import EntityFormTemplate from 'model/EntityFormTemplate';

const AWS_CLOUD_SECURITY_GROUP_TEMPLATE: EntityFormTemplate[] = [
  {
    cloudServiceProvider: 'aws_cloud',
    entityName: 'security_group',
    actionType: 'revoke',
    entityRecords: [
      {
        type: 'label',
        text: 'Are you sure you want to revoke the following permission?'
      },
    ],
    submitButtonLabel: 'Revoke'
  }
]

export default AWS_CLOUD_SECURITY_GROUP_TEMPLATE;
+2 −0
Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
import AWS_CLOUD_INSTANCE_TEMPLATE from 'constant/form_template/aws_cloud/instance';
import AWS_CLOUD_SECURITY_GROUP_TEMPLATE from 'constant/form_template/aws_cloud/security_group';
import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment';
import K8S_NAMESPACE_TEMPLATE from 'constant/form_template/k8s/namespace';
import K8S_OTHER_TEMPLATE from 'constant/form_template/k8s/other';
@@ -15,6 +16,7 @@ import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm';

const ENTITY_FORM_LIST = [
  ...AWS_CLOUD_INSTANCE_TEMPLATE,
  ...AWS_CLOUD_SECURITY_GROUP_TEMPLATE,
  ...K8S_DEPLOYMENT_TEMPLATE,
  ...K8S_NAMESPACE_TEMPLATE,
  ...K8S_POD_TEMPLATE,
+24 −0
Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -786,6 +786,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
    // branching is performed with a switch statement.
    $form_state = new IntermediateFormState();
    $method_name = '';
    $parameters = [];
    try {
      switch ($command . '_' . $entity_type_id) {
        case 'associate_elastic_ip_aws_cloud_instance':
@@ -828,6 +829,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
          $method_name = 'rebootInstance';
          break;

        case 'revoke_aws_cloud_security_group':
          $parameters = [
            'type' => $request->get('type', ''),
            'position' => $request->get('position', ''),
          ];
          $method_name = 'revokeSecurityGroup';
          break;

        case 'start_aws_cloud_instance':
          $method_name = 'startInstance';
          break;
@@ -849,12 +858,27 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
    $result = NULL;
    if (method_exists($this->awsCloudOperationsService, $method_name)) {
      $form = [];
      if (!empty($parameters)) {
        switch ($command . '_' . $entity_type_id) {
          case 'revoke_aws_cloud_security_group':
            $result = $this->awsCloudOperationsService->revokeSecurityGroup(
              $entity,
              $form,
              $form_state,
              $parameters['type'],
              $parameters['position']
            );
            break;
        }
      }
      else {
        $result = $this->awsCloudOperationsService->$method_name(
          $entity,
          $form,
          $form_state
        );
      }
    }

    return !empty($result)
      ? new JsonResponse([
+5 −0
Changes for modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/NetworkInterfaceInterface.php: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -17,6 +17,11 @@ interface NetworkInterfaceInterface extends ContentEntityInterface, EntityOwnerI
   */
  public function getCloudContext(): ?string;

  /**
   * {@inheritdoc}
   */
  public function getName(): ?string;

  /**
   * {@inheritdoc}
   */
Loading