Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/elastic_ip.ts 0 → 100644 +28 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/elastic_ip.ts: 28 added lines, 0 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: 'create', entityRecords: [ { type: 'panel', panelName: 'Elastic IP', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select-local', labelName: 'Domain (Standard | VPC)', name: 'domain', defaultValue: 'standard', value: [ { labelName: 'Standard', name: 'standard' }, { labelName: 'VPC', name: 'vpc' }, ], required: true }, { type: 'select', labelName: 'Network border group', name: 'network_border_group', url: '/cloud_dashboard/aws_cloud/{cloud_context}/network_border_groups', defaultValue: '', required: true }, ] } ] }, ] export default AWS_CLOUD_ELASTIC_IP_TEMPLATE; modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +4 −2 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 4 added lines, 2 removed lines. Original line number Diff line number Diff line import AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/carrier_gateway'; import AWS_CLOUD_ELASTIC_IP_TEMPLATE from 'constant/form_template/aws_cloud/elastic_ip'; import AWS_CLOUD_IMAGE_TEMPLATE from 'constant/form_template/aws_cloud/image'; import AWS_CLOUD_INSTANCE_TEMPLATE from 'constant/form_template/aws_cloud/instance'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_KEY_PAIR_TEMPLATE from 'constant/form_template/aws_cloud/key_pair'; import AWS_CLOUD_SECURITY_GROUP_TEMPLATE from 'constant/form_template/aws_cloud/security_group'; import AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/carrier_gateway'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; Loading @@ -22,6 +23,7 @@ import OPENSTACK_VOLUME_TEMPLATE from 'constant/form_template/openstack/volume'; import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ ...AWS_CLOUD_ELASTIC_IP_TEMPLATE, ...AWS_CLOUD_IMAGE_TEMPLATE, ...AWS_CLOUD_INSTANCE_TEMPLATE, ...AWS_CLOUD_KEY_PAIR_TEMPLATE, Loading modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +27 −0 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 27 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -893,6 +893,33 @@ 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.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/create' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_elastic_ip 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 aws cloud elastic ip' entity.aws_cloud_elastic_ip.network_border_groups: path: '/cloud_dashboard/aws_cloud/{cloud_context}/network_border_groups' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getNetworkBorderGroupOptions' methods: [GET] 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: 'access dashboard' entity.aws_cloud_image.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_image/create' defaults: Loading modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +59 −1 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 59 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\aws_cloud\Controller\Ec2; use Drupal\aws_cloud\Entity\Ec2\ElasticIp; use Drupal\aws_cloud\Entity\Ec2\InstanceInterface; use Drupal\aws_cloud\Entity\Ec2\IntermediateFormState; use Drupal\aws_cloud\Entity\Ec2\NetworkInterface; use Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsServiceInterface; use Drupal\aws_cloud\Service\CloudWatch\CloudWatchServiceInterface; Loading @@ -23,7 +24,6 @@ use Drupal\Core\Link; use Drupal\Core\Messenger\Messenger; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; use Drupal\openstack\Entity\IntermediateFormState; use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; Loading Loading @@ -798,6 +798,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'associateElasticIpForInstance'; break; case 'create_aws_cloud_elastic_ip': /** @var \Drupal\aws_cloud\Entity\Ec2\ElasticIpInterface $entity */ $entity->setName($request->get('name', '')); $entity->setDomain($request->get('domain', '')); $entity->setNetworkBorderGroup($request->get('network_border_group', '')); $method_name = 'createElasticIp'; break; case 'create_aws_cloud_image': /** @var \Drupal\aws_cloud\Entity\Ec2\ImageInterface $entity */ $entity->setName($request->get('name', '')); Loading Loading @@ -1180,4 +1188,54 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($output, 200); } /** * {@inheritdoc} */ public function getNetworkBorderGroupOptions(string $cloud_context): JsonResponse { $availability_zones = $this->entityTypeManager ->getStorage("aws_cloud_availability_zone") ->loadByProperties([ 'cloud_context' => $cloud_context, ]); // loadByProperties() must return some entities for Availability Zone; // however if the entities are empty, we try to get Availability Zones since // the entities are filled by aws_cloud_update_resources_queue. // The cost of describeAvailabilityZones() is 400-450 milliseconds. if (empty($availability_zones)) { // This is a trait however we assume $this->ec2Service is available. $this->ec2Service->updateAvailabilityZonesWithoutBatch(); $availability_zones = $this->entityTypeManager ->getStorage("aws_cloud_availability_zone") ->loadByProperties([ 'cloud_context' => $cloud_context, ]); } $group_zones = []; foreach ($availability_zones ?: [] as $zone) { /** @var \Drupal\aws_cloud\Entity\Ec2\AvailabilityZoneInterface $zone */ if (empty($zone->getNetworkBorderGroup())) { continue; } $group = $zone->getNetworkBorderGroup(); if (empty($group_zones[$group])) { $group_zones[$group] = []; } $group_zones[$group][] = $zone->getZoneName(); } $output = []; foreach ($group_zones as $group => $zones) { /** @var array $zones */ $output[] = [ 'value' => $group, 'label' => sprintf('%s (%s)', $group, implode(', ', $zones)), ]; } return new JsonResponse($output, 200); } } modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php +11 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -225,4 +225,15 @@ interface ApiControllerInterface { */ public function getScheduleOptions(): JsonResponse; /** * Get options for the select element network border group. * * @param string $cloud_context * The cloud context. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function getNetworkBorderGroupOptions(string $cloud_context): JsonResponse; } Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/elastic_ip.ts 0 → 100644 +28 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/aws_cloud/elastic_ip.ts: 28 added lines, 0 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: 'create', entityRecords: [ { type: 'panel', panelName: 'Elastic IP', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select-local', labelName: 'Domain (Standard | VPC)', name: 'domain', defaultValue: 'standard', value: [ { labelName: 'Standard', name: 'standard' }, { labelName: 'VPC', name: 'vpc' }, ], required: true }, { type: 'select', labelName: 'Network border group', name: 'network_border_group', url: '/cloud_dashboard/aws_cloud/{cloud_context}/network_border_groups', defaultValue: '', required: true }, ] } ] }, ] export default AWS_CLOUD_ELASTIC_IP_TEMPLATE;
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +4 −2 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts: 4 added lines, 2 removed lines. Original line number Diff line number Diff line import AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/carrier_gateway'; import AWS_CLOUD_ELASTIC_IP_TEMPLATE from 'constant/form_template/aws_cloud/elastic_ip'; import AWS_CLOUD_IMAGE_TEMPLATE from 'constant/form_template/aws_cloud/image'; import AWS_CLOUD_INSTANCE_TEMPLATE from 'constant/form_template/aws_cloud/instance'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_KEY_PAIR_TEMPLATE from 'constant/form_template/aws_cloud/key_pair'; import AWS_CLOUD_SECURITY_GROUP_TEMPLATE from 'constant/form_template/aws_cloud/security_group'; import AWS_CLOUD_CARRIER_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/carrier_gateway'; import AWS_CLOUD_INTERNET_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/internet_gateway'; import AWS_CLOUD_TRANSIT_GATEWAY_TEMPLATE from 'constant/form_template/aws_cloud/transit_gateway'; import AWS_CLOUD_VPC_TEMPLATE from 'constant/form_template/aws_cloud/vpc'; import K8S_DEPLOYMENT_TEMPLATE from 'constant/form_template/k8s/deployment'; Loading @@ -22,6 +23,7 @@ import OPENSTACK_VOLUME_TEMPLATE from 'constant/form_template/openstack/volume'; import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ ...AWS_CLOUD_ELASTIC_IP_TEMPLATE, ...AWS_CLOUD_IMAGE_TEMPLATE, ...AWS_CLOUD_INSTANCE_TEMPLATE, ...AWS_CLOUD_KEY_PAIR_TEMPLATE, Loading
modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml +27 −0 Changes for modules/cloud_service_providers/aws_cloud/aws_cloud.routing.yml: 27 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -893,6 +893,33 @@ 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.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_elastic_ip/create' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity' entity_type_id: aws_cloud_elastic_ip 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 aws cloud elastic ip' entity.aws_cloud_elastic_ip.network_border_groups: path: '/cloud_dashboard/aws_cloud/{cloud_context}/network_border_groups' defaults: _controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::getNetworkBorderGroupOptions' methods: [GET] 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: 'access dashboard' entity.aws_cloud_image.create: path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_image/create' defaults: Loading
modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php +59 −1 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiController.php: 59 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\aws_cloud\Controller\Ec2; use Drupal\aws_cloud\Entity\Ec2\ElasticIp; use Drupal\aws_cloud\Entity\Ec2\InstanceInterface; use Drupal\aws_cloud\Entity\Ec2\IntermediateFormState; use Drupal\aws_cloud\Entity\Ec2\NetworkInterface; use Drupal\aws_cloud\Service\AwsCloud\AwsCloudOperationsServiceInterface; use Drupal\aws_cloud\Service\CloudWatch\CloudWatchServiceInterface; Loading @@ -23,7 +24,6 @@ use Drupal\Core\Link; use Drupal\Core\Messenger\Messenger; use Drupal\Core\Render\RendererInterface; use Drupal\Core\Session\AccountInterface; use Drupal\openstack\Entity\IntermediateFormState; use Drupal\views\Views; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; Loading Loading @@ -798,6 +798,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'associateElasticIpForInstance'; break; case 'create_aws_cloud_elastic_ip': /** @var \Drupal\aws_cloud\Entity\Ec2\ElasticIpInterface $entity */ $entity->setName($request->get('name', '')); $entity->setDomain($request->get('domain', '')); $entity->setNetworkBorderGroup($request->get('network_border_group', '')); $method_name = 'createElasticIp'; break; case 'create_aws_cloud_image': /** @var \Drupal\aws_cloud\Entity\Ec2\ImageInterface $entity */ $entity->setName($request->get('name', '')); Loading Loading @@ -1180,4 +1188,54 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($output, 200); } /** * {@inheritdoc} */ public function getNetworkBorderGroupOptions(string $cloud_context): JsonResponse { $availability_zones = $this->entityTypeManager ->getStorage("aws_cloud_availability_zone") ->loadByProperties([ 'cloud_context' => $cloud_context, ]); // loadByProperties() must return some entities for Availability Zone; // however if the entities are empty, we try to get Availability Zones since // the entities are filled by aws_cloud_update_resources_queue. // The cost of describeAvailabilityZones() is 400-450 milliseconds. if (empty($availability_zones)) { // This is a trait however we assume $this->ec2Service is available. $this->ec2Service->updateAvailabilityZonesWithoutBatch(); $availability_zones = $this->entityTypeManager ->getStorage("aws_cloud_availability_zone") ->loadByProperties([ 'cloud_context' => $cloud_context, ]); } $group_zones = []; foreach ($availability_zones ?: [] as $zone) { /** @var \Drupal\aws_cloud\Entity\Ec2\AvailabilityZoneInterface $zone */ if (empty($zone->getNetworkBorderGroup())) { continue; } $group = $zone->getNetworkBorderGroup(); if (empty($group_zones[$group])) { $group_zones[$group] = []; } $group_zones[$group][] = $zone->getZoneName(); } $output = []; foreach ($group_zones as $group => $zones) { /** @var array $zones */ $output[] = [ 'value' => $group, 'label' => sprintf('%s (%s)', $group, implode(', ', $zones)), ]; } return new JsonResponse($output, 200); } }
modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php +11 −0 Changes for modules/cloud_service_providers/aws_cloud/src/Controller/Ec2/ApiControllerInterface.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -225,4 +225,15 @@ interface ApiControllerInterface { */ public function getScheduleOptions(): JsonResponse; /** * Get options for the select element network border group. * * @param string $cloud_context * The cloud context. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. */ public function getNetworkBorderGroupOptions(string $cloud_context): JsonResponse; }