Loading modules/cloud_service_providers/aws_cloud/src/Plugin/Field/FieldWidget/IpPermissionItem.php +34 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ class IpPermissionItem extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { if (empty($items[$delta])) { return $element; } /** @var \Drupal\Core\Entity\Plugin\DataType\EntityAdapter $parent */ $parent = $items->getParent(); $security_group = $parent->getValue(); Loading Loading @@ -78,8 +82,9 @@ class IpPermissionItem extends WidgetBase { '#size' => 5, '#default_value' => $items[$delta]->from_port ?? NULL, '#maxlength' => 5, '#placeholder' => 0, '#placeholder' => $this->getSetting('from_port_placeholder'), ]; $element['to_port'] = [ '#type' => 'textfield', '#title' => $this->t('To Port'), Loading @@ -88,6 +93,7 @@ class IpPermissionItem extends WidgetBase { '#maxlength' => 5, '#placeholder' => 65535, ]; $element['source'] = [ '#type' => 'select', '#title' => $this->t('Source'), Loading @@ -100,6 +106,7 @@ class IpPermissionItem extends WidgetBase { ], '#default_value' => $items[$delta]->source ?? NULL, ]; $element['cidr_ip'] = [ '#type' => 'textfield', '#title' => $this->t('CIDR IP'), Loading @@ -113,6 +120,7 @@ class IpPermissionItem extends WidgetBase { ], ], ]; $element['cidr_ip_v6'] = [ '#type' => 'textfield', '#title' => $this->t('CIDR IPv6'), Loading @@ -139,6 +147,7 @@ class IpPermissionItem extends WidgetBase { ], ]; } $element['group_id'] = [ '#type' => 'textfield', '#title' => $this->t('Group ID'), Loading @@ -151,6 +160,7 @@ class IpPermissionItem extends WidgetBase { ], ], ]; if (isset($items[$delta]->group_name)) { $element['group_name'] = [ '#type' => 'textfield', Loading @@ -166,6 +176,7 @@ class IpPermissionItem extends WidgetBase { ], ]; } $element['peering_status'] = [ '#type' => 'textfield', '#title' => $this->t('Peering Status'), Loading Loading @@ -227,4 +238,26 @@ class IpPermissionItem extends WidgetBase { return $element; } /** * {@inheritdoc} */ public static function defaultSettings(): array { return [ 'from_port_placeholder' => '0', ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state): array { $element['from_port_placeholder'] = [ '#title' => $this->t('From Port placeholder'), '#type' => 'textfield', '#default_value' => $this->getSetting('from_port_placeholder'), ]; return $element; } } modules/cloud_service_providers/openstack/src/Entity/OpenStackSecurityGroup.php +24 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\openstack\Entity; use Drupal\aws_cloud\Entity\Ec2\SecurityGroup; use Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface; use Drupal\Core\Entity\EntityTypeInterface; /** * Defines the OpenStack security group entity. Loading Loading @@ -56,4 +57,27 @@ use Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface; */ class OpenStackSecurityGroup extends SecurityGroup implements SecurityGroupInterface { /** * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type): array { $fields = parent::baseFieldDefinitions($entity_type); $fields['ip_permission'] ->setDisplayOptions('form', [ 'settings' => [ 'from_port_placeholder' => '1', ], ]); $fields['outbound_permission'] ->setDisplayOptions('form', [ 'settings' => [ 'from_port_placeholder' => '1', ], ]); return $fields; } } modules/cloud_service_providers/openstack/src/Service/Rest/OpenStackService.php +16 −11 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,12 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions = $ip_permissions_egress = []; foreach ($value['security_group_rules'] ?: [] as $value_rules) { $security_group_rules = []; if (!empty($value['security_group_rules'])) { $security_group_rules = $value['security_group_rules']; } foreach ($security_group_rules ?: [] as $value_rules) { if (!empty($value_rules['direction']) && $value_rules['direction'] === 'egress') { $ip_permissions_egress[$ip_permission_egress_cnt] = [ Loading @@ -1812,8 +1817,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions_egress[$ip_permission_egress_cnt] += [ 'Ipv6Ranges' => [ [ 'CidrIpv6' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIpv6' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '::/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading @@ -1825,8 +1830,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions_egress[$ip_permission_egress_cnt] += [ 'IpRanges' => [ [ 'CidrIp' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIp' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '0.0.0.0/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading Loading @@ -1860,8 +1865,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions[$ip_permission_cnt] += [ 'Ipv6Ranges' => [ [ 'CidrIpv6' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIpv6' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '::/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading @@ -1872,8 +1877,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions[$ip_permission_cnt] += [ 'IpRanges' => [ [ 'CidrIp' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIp' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '0.0.0.0/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading Loading @@ -3785,9 +3790,9 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_protocol = $ec2_permission['IpProtocol']; // To keep things consistent, if ip_protocol is -1, // set from_port and to_port as 0-65535. // set from_port and to_port as 1-65535. if ($ip_protocol === '-1') { $from_port = '0'; $from_port = '1'; $to_port = '65535'; } Loading Loading
modules/cloud_service_providers/aws_cloud/src/Plugin/Field/FieldWidget/IpPermissionItem.php +34 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,10 @@ class IpPermissionItem extends WidgetBase { * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state): array { if (empty($items[$delta])) { return $element; } /** @var \Drupal\Core\Entity\Plugin\DataType\EntityAdapter $parent */ $parent = $items->getParent(); $security_group = $parent->getValue(); Loading Loading @@ -78,8 +82,9 @@ class IpPermissionItem extends WidgetBase { '#size' => 5, '#default_value' => $items[$delta]->from_port ?? NULL, '#maxlength' => 5, '#placeholder' => 0, '#placeholder' => $this->getSetting('from_port_placeholder'), ]; $element['to_port'] = [ '#type' => 'textfield', '#title' => $this->t('To Port'), Loading @@ -88,6 +93,7 @@ class IpPermissionItem extends WidgetBase { '#maxlength' => 5, '#placeholder' => 65535, ]; $element['source'] = [ '#type' => 'select', '#title' => $this->t('Source'), Loading @@ -100,6 +106,7 @@ class IpPermissionItem extends WidgetBase { ], '#default_value' => $items[$delta]->source ?? NULL, ]; $element['cidr_ip'] = [ '#type' => 'textfield', '#title' => $this->t('CIDR IP'), Loading @@ -113,6 +120,7 @@ class IpPermissionItem extends WidgetBase { ], ], ]; $element['cidr_ip_v6'] = [ '#type' => 'textfield', '#title' => $this->t('CIDR IPv6'), Loading @@ -139,6 +147,7 @@ class IpPermissionItem extends WidgetBase { ], ]; } $element['group_id'] = [ '#type' => 'textfield', '#title' => $this->t('Group ID'), Loading @@ -151,6 +160,7 @@ class IpPermissionItem extends WidgetBase { ], ], ]; if (isset($items[$delta]->group_name)) { $element['group_name'] = [ '#type' => 'textfield', Loading @@ -166,6 +176,7 @@ class IpPermissionItem extends WidgetBase { ], ]; } $element['peering_status'] = [ '#type' => 'textfield', '#title' => $this->t('Peering Status'), Loading Loading @@ -227,4 +238,26 @@ class IpPermissionItem extends WidgetBase { return $element; } /** * {@inheritdoc} */ public static function defaultSettings(): array { return [ 'from_port_placeholder' => '0', ] + parent::defaultSettings(); } /** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state): array { $element['from_port_placeholder'] = [ '#title' => $this->t('From Port placeholder'), '#type' => 'textfield', '#default_value' => $this->getSetting('from_port_placeholder'), ]; return $element; } }
modules/cloud_service_providers/openstack/src/Entity/OpenStackSecurityGroup.php +24 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\openstack\Entity; use Drupal\aws_cloud\Entity\Ec2\SecurityGroup; use Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface; use Drupal\Core\Entity\EntityTypeInterface; /** * Defines the OpenStack security group entity. Loading Loading @@ -56,4 +57,27 @@ use Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface; */ class OpenStackSecurityGroup extends SecurityGroup implements SecurityGroupInterface { /** * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type): array { $fields = parent::baseFieldDefinitions($entity_type); $fields['ip_permission'] ->setDisplayOptions('form', [ 'settings' => [ 'from_port_placeholder' => '1', ], ]); $fields['outbound_permission'] ->setDisplayOptions('form', [ 'settings' => [ 'from_port_placeholder' => '1', ], ]); return $fields; } }
modules/cloud_service_providers/openstack/src/Service/Rest/OpenStackService.php +16 −11 Original line number Diff line number Diff line Loading @@ -1785,7 +1785,12 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions = $ip_permissions_egress = []; foreach ($value['security_group_rules'] ?: [] as $value_rules) { $security_group_rules = []; if (!empty($value['security_group_rules'])) { $security_group_rules = $value['security_group_rules']; } foreach ($security_group_rules ?: [] as $value_rules) { if (!empty($value_rules['direction']) && $value_rules['direction'] === 'egress') { $ip_permissions_egress[$ip_permission_egress_cnt] = [ Loading @@ -1812,8 +1817,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions_egress[$ip_permission_egress_cnt] += [ 'Ipv6Ranges' => [ [ 'CidrIpv6' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIpv6' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '::/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading @@ -1825,8 +1830,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions_egress[$ip_permission_egress_cnt] += [ 'IpRanges' => [ [ 'CidrIp' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIp' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '0.0.0.0/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading Loading @@ -1860,8 +1865,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions[$ip_permission_cnt] += [ 'Ipv6Ranges' => [ [ 'CidrIpv6' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIpv6' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '::/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading @@ -1872,8 +1877,8 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_permissions[$ip_permission_cnt] += [ 'IpRanges' => [ [ 'CidrIp' => $value_rules['remote_ip_prefix'] ?? NULL, 'Description' => $value_rules['description'] ?? NULL, 'CidrIp' => !empty($value_rules['remote_ip_prefix']) ? $value_rules['remote_ip_prefix'] : '0.0.0.0/0', 'Description' => !empty($value_rules['description']) ? $value_rules['description'] : '', ], ], ]; Loading Loading @@ -3785,9 +3790,9 @@ class OpenStackService extends CloudServiceBase implements OpenStackServiceInter $ip_protocol = $ec2_permission['IpProtocol']; // To keep things consistent, if ip_protocol is -1, // set from_port and to_port as 0-65535. // set from_port and to_port as 1-65535. if ($ip_protocol === '-1') { $from_port = '0'; $from_port = '1'; $to_port = '65535'; } Loading