Commit cf35fa16 authored by Takumaru Sekine's avatar Takumaru Sekine Committed by Yas Naoi
Browse files

Issue #3285526 by sekinet, yas, Ryo Yamashita: Add the function to create...

Issue #3285526 by sekinet, yas, Ryo Yamashita: Add the function to create Openstack Security Group in the SPA
parent 3e532775
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import OPENSTACK_INSTANCE_TEMPLATE from 'constant/form_template/openstack/instan
import OPENSTACK_FLOATING_IP_TEMPLATE from 'constant/form_template/openstack/floating_ip';
import OPENSTACK_KEY_PAIR_TEMPLATE from 'constant/form_template/openstack/key_pair';
import OPENSTACK_NETWORK_INTERFACE_TEMPLATE from 'constant/form_template/openstack/network_interface';
import OPENSTACK_SECURITY_GROUP_TEMPLATE from 'constant/form_template/openstack/security_group';
import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm';

const ENTITY_FORM_LIST = [
@@ -20,6 +21,7 @@ const ENTITY_FORM_LIST = [
  ...OPENSTACK_FLOATING_IP_TEMPLATE,
  ...OPENSTACK_INSTANCE_TEMPLATE,
  ...OPENSTACK_IMAGE_TEMPLATE,
  ...OPENSTACK_SECURITY_GROUP_TEMPLATE,
  ...OPENSTACK_KEY_PAIR_TEMPLATE,
  ...OPENSTACK_NETWORK_INTERFACE_TEMPLATE,
  ...VMWARE_VM_TEMPLATE,
+21 −0
Original line number Diff line number Diff line
import EntityFormTemplate from 'model/EntityFormTemplate';

const OPENSTACK_SECURITY_GROUP_TEMPLATE: EntityFormTemplate[] = [
  {
    cloudServiceProvider: 'openstack',
    entityName: 'security_group',
    actionType: 'create',
    entityRecords: [
      {
        type: 'panel',
        panelName: 'Security group',
        keyValueRecords: [
          { type: 'default', labelName: 'Security group name', name: 'group_name', defaultValue: '', required: true },
          { type: 'default', labelName: 'Description', name: 'description', defaultValue: '', required: true },
        ]
      }
    ]
  },
]

export default OPENSTACK_SECURITY_GROUP_TEMPLATE;
+14 −0
Original line number Diff line number Diff line
@@ -84,6 +84,13 @@ class SecurityGroup extends CloudContentEntityBase implements SecurityGroupInter
    return $this->get('group_name')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setGroupName($group_name = ''): SecurityGroupInterface {
    return $this->set('group_name', $group_name);
  }

  /**
   * {@inheritdoc}
   */
@@ -91,6 +98,13 @@ class SecurityGroup extends CloudContentEntityBase implements SecurityGroupInter
    return $this->get('description')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setDescription($description = ''): SecurityGroupInterface {
    return $this->set('description', $description);
  }

  /**
   * {@inheritdoc}
   */
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ interface SecurityGroupInterface extends ContentEntityInterface, EntityOwnerInte
   */
  public function getDescription(): ?string;

  /**
   * {@inheritdoc}
   */
  public function setDescription($description = ''): SecurityGroupInterface;

  /**
   * {@inheritdoc}
   */
@@ -38,6 +43,11 @@ interface SecurityGroupInterface extends ContentEntityInterface, EntityOwnerInte
   */
  public function getGroupName(): ?string;

  /**
   * {@inheritdoc}
   */
  public function setGroupName($group_name = ''): SecurityGroupInterface;

  /**
   * {@inheritdoc}
   */
+15 −0
Original line number Diff line number Diff line
@@ -694,3 +694,18 @@ entity.openstack_floating_ip.edit:
    _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access'
  options:
      perm: 'edit any openstack floating ip+edit own openstack floating ip'

entity.openstack_security_group.create:
  path: '/cloud_dashboard/openstack/{cloud_context}/openstack_security_group/create'
  defaults:
    _controller: '\Drupal\openstack\Controller\ApiController::operateEntity'
    entity_type_id: openstack_security_group
    entity_id: ''
    command: create
  methods: [POST]
  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: 'add openstack security group'
Loading