Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +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 Loading @@ -6,6 +6,7 @@ import K8S_SCHEDULE_TEMPLATE from 'constant/form_template/k8s/schedule'; import OPENSTACK_IMAGE_TEMPLATE from 'constant/form_template/openstack/image'; import OPENSTACK_INSTANCE_TEMPLATE from 'constant/form_template/openstack/instance'; 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 VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ Loading @@ -18,6 +19,7 @@ const ENTITY_FORM_LIST = [ ...OPENSTACK_INSTANCE_TEMPLATE, ...OPENSTACK_IMAGE_TEMPLATE, ...OPENSTACK_KEY_PAIR_TEMPLATE, ...OPENSTACK_NETWORK_INTERFACE_TEMPLATE, ...VMWARE_VM_TEMPLATE, ]; Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/network_interface.ts 0 → 100644 +87 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/network_interface.ts: 87 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const OPENSTACK_NETWORK_INTERFACE_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Network interface name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, ] } ] }, { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'edit', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Network interface name', name: 'name', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Network interface ID', name: 'network_interface_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Instance ID', name: 'instance_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Allocation ID', name: 'allocation_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Mac Address', name: 'mac_address', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Device Index', name: 'device_index', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Status', name: 'status', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Delete on Termination', name: 'delete_on_termination', defaultValue: '', readOnly: true }, { type: 'datetime', labelName: 'Created', name: 'created' }, ] }, { type: 'panel', panelName: 'Network', keyValueRecords: [ { type: 'default', labelName: 'Security group', name: 'security_groups', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'VPC ID', name: 'vpc_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'CIDR Block', name: 'cidr_block', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Subnet ID', name: 'subnet_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Public IPs', name: 'public_ips', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Primary Private IP', name: 'primary_private_ip', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Secondary Private IPs', name: 'secondary_private_ips', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Private DNS', name: 'private_dns', defaultValue: '', readOnly: true }, ] }, { type: 'panel', panelName: 'Attachment', keyValueRecords: [ { type: 'default', labelName: 'Attachment ID', name: 'attachment_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Attachment Owner', name: 'attachment_owner', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Attachment Status', name: 'attachment_status', defaultValue: '', readOnly: true }, ] }, { type: 'panel', panelName: 'Owner', keyValueRecords: [ { type: 'default', labelName: 'AWS account ID', name: 'account_id', defaultValue: '', readOnly: true }, ] } ] }, { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'delete', entityRecords: [ { type: 'label', text: 'Are you sure you want to delete the {{entityName}} {{name}}?' }, ], submitButtonLabel: 'Delete' } ] export default OPENSTACK_NETWORK_INTERFACE_TEMPLATE; modules/cloud_service_providers/openstack/openstack.routing.yml +15 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -597,3 +597,18 @@ entity.openstack_key_pair.delete: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any openstack key pair+delete own openstack key pairr' entity.openstack_network_interface.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_network_interface/create' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_network_interface 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 network interface' modules/cloud_service_providers/openstack/src/Controller/ApiController.php +6 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -556,6 +556,12 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteOpenStackKeyPair'; break; case 'create_openstack_network_interface': $original_entity->setName($request->get('name', '')); $original_entity->setDescription($request->get('description', '')); $method_name = 'createOpenStackNetworkInterface'; break; } // Execute the process. Loading modules/cloud_service_providers/openstack/src/Form/OpenStackNetworkInterfaceCreateForm.php +16 −10 Changes for modules/cloud_service_providers/openstack/src/Form/OpenStackNetworkInterfaceCreateForm.php: 16 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ use Drupal\Core\Render\Renderer; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\cloud\Service\CloudServiceInterface; use Drupal\openstack\Service\OpenStackOperationsServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading @@ -37,6 +38,13 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { */ protected $openStackServiceFactory; /** * The OpenStack operations Service. * * @var \Drupal\openstack\Service\OpenStackOperationsServiceInterface */ protected $openStackOperationsService; /** * OpenStackNetworkInterfaceCreateForm constructor. * Loading Loading @@ -72,6 +80,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { * The general renderer. * @param \Drupal\cloud\Service\CloudServiceInterface $cloud_service * The Cloud service. * @param \Drupal\openstack\Service\OpenStackOperationsServiceInterface $openstack_operations_service * The OpenStack Operations service. */ public function __construct(OpenStackServiceFactoryInterface $openstack_service_factory, Ec2ServiceInterface $ec2_service, Loading @@ -88,7 +98,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { RouteMatchInterface $route_match, DateFormatterInterface $date_formatter, Renderer $renderer, CloudServiceInterface $cloud_service) { CloudServiceInterface $cloud_service, OpenStackOperationsServiceInterface $openstack_operations_service) { parent::__construct( $ec2_service, Loading @@ -109,6 +120,7 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { ); $this->openStackServiceFactory = $openstack_service_factory; $this->openStackOperationsService = $openstack_operations_service; } /** Loading Loading @@ -137,7 +149,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { $container->get('current_route_match'), $container->get('date.formatter'), $container->get('renderer'), $container->get('cloud') $container->get('cloud'), $container->get('openstack.operations') ); } Loading Loading @@ -177,14 +190,7 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { * The current form state. */ public function save(array $form, FormStateInterface $form_state): void { $entity = $this->entity; // Switch OpenStack EC2 or REST service based on $entity->getCloudContext(). $this->ec2Service = $this->openStackServiceFactory->get($entity->getCloudContext()); parent::save($form, $form_state); if ($this->ec2Service instanceof OpenStackRestService) { $this->updateNameAndCreatedByTags($entity, $entity->getNetworkInterfaceId()); } $this->openStackOperationsService->createOpenStackNetworkInterface($this->entity, $form, $form_state); } } Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/entity_form_template.ts +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 Loading @@ -6,6 +6,7 @@ import K8S_SCHEDULE_TEMPLATE from 'constant/form_template/k8s/schedule'; import OPENSTACK_IMAGE_TEMPLATE from 'constant/form_template/openstack/image'; import OPENSTACK_INSTANCE_TEMPLATE from 'constant/form_template/openstack/instance'; 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 VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ Loading @@ -18,6 +19,7 @@ const ENTITY_FORM_LIST = [ ...OPENSTACK_INSTANCE_TEMPLATE, ...OPENSTACK_IMAGE_TEMPLATE, ...OPENSTACK_KEY_PAIR_TEMPLATE, ...OPENSTACK_NETWORK_INTERFACE_TEMPLATE, ...VMWARE_VM_TEMPLATE, ]; Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/network_interface.ts 0 → 100644 +87 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/network_interface.ts: 87 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const OPENSTACK_NETWORK_INTERFACE_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Network interface name', name: 'name', defaultValue: '' }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, ] } ] }, { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'edit', entityRecords: [ { type: 'panel', panelName: 'Network interface', keyValueRecords: [ { type: 'default', labelName: 'Network interface name', name: 'name', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Network interface ID', name: 'network_interface_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Instance ID', name: 'instance_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Allocation ID', name: 'allocation_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Mac Address', name: 'mac_address', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Device Index', name: 'device_index', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Status', name: 'status', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Delete on Termination', name: 'delete_on_termination', defaultValue: '', readOnly: true }, { type: 'datetime', labelName: 'Created', name: 'created' }, ] }, { type: 'panel', panelName: 'Network', keyValueRecords: [ { type: 'default', labelName: 'Security group', name: 'security_groups', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'VPC ID', name: 'vpc_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'CIDR Block', name: 'cidr_block', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Subnet ID', name: 'subnet_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Public IPs', name: 'public_ips', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Primary Private IP', name: 'primary_private_ip', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Secondary Private IPs', name: 'secondary_private_ips', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Private DNS', name: 'private_dns', defaultValue: '', readOnly: true }, ] }, { type: 'panel', panelName: 'Attachment', keyValueRecords: [ { type: 'default', labelName: 'Attachment ID', name: 'attachment_id', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Attachment Owner', name: 'attachment_owner', defaultValue: '', readOnly: true }, { type: 'default', labelName: 'Attachment Status', name: 'attachment_status', defaultValue: '', readOnly: true }, ] }, { type: 'panel', panelName: 'Owner', keyValueRecords: [ { type: 'default', labelName: 'AWS account ID', name: 'account_id', defaultValue: '', readOnly: true }, ] } ] }, { cloudServiceProvider: 'openstack', entityName: 'network_interface', actionType: 'delete', entityRecords: [ { type: 'label', text: 'Are you sure you want to delete the {{entityName}} {{name}}?' }, ], submitButtonLabel: 'Delete' } ] export default OPENSTACK_NETWORK_INTERFACE_TEMPLATE;
modules/cloud_service_providers/openstack/openstack.routing.yml +15 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -597,3 +597,18 @@ entity.openstack_key_pair.delete: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any openstack key pair+delete own openstack key pairr' entity.openstack_network_interface.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_network_interface/create' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_network_interface 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 network interface'
modules/cloud_service_providers/openstack/src/Controller/ApiController.php +6 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -556,6 +556,12 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteOpenStackKeyPair'; break; case 'create_openstack_network_interface': $original_entity->setName($request->get('name', '')); $original_entity->setDescription($request->get('description', '')); $method_name = 'createOpenStackNetworkInterface'; break; } // Execute the process. Loading
modules/cloud_service_providers/openstack/src/Form/OpenStackNetworkInterfaceCreateForm.php +16 −10 Changes for modules/cloud_service_providers/openstack/src/Form/OpenStackNetworkInterfaceCreateForm.php: 16 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ use Drupal\Core\Render\Renderer; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; use Drupal\cloud\Service\CloudServiceInterface; use Drupal\openstack\Service\OpenStackOperationsServiceInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** Loading @@ -37,6 +38,13 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { */ protected $openStackServiceFactory; /** * The OpenStack operations Service. * * @var \Drupal\openstack\Service\OpenStackOperationsServiceInterface */ protected $openStackOperationsService; /** * OpenStackNetworkInterfaceCreateForm constructor. * Loading Loading @@ -72,6 +80,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { * The general renderer. * @param \Drupal\cloud\Service\CloudServiceInterface $cloud_service * The Cloud service. * @param \Drupal\openstack\Service\OpenStackOperationsServiceInterface $openstack_operations_service * The OpenStack Operations service. */ public function __construct(OpenStackServiceFactoryInterface $openstack_service_factory, Ec2ServiceInterface $ec2_service, Loading @@ -88,7 +98,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { RouteMatchInterface $route_match, DateFormatterInterface $date_formatter, Renderer $renderer, CloudServiceInterface $cloud_service) { CloudServiceInterface $cloud_service, OpenStackOperationsServiceInterface $openstack_operations_service) { parent::__construct( $ec2_service, Loading @@ -109,6 +120,7 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { ); $this->openStackServiceFactory = $openstack_service_factory; $this->openStackOperationsService = $openstack_operations_service; } /** Loading Loading @@ -137,7 +149,8 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { $container->get('current_route_match'), $container->get('date.formatter'), $container->get('renderer'), $container->get('cloud') $container->get('cloud'), $container->get('openstack.operations') ); } Loading Loading @@ -177,14 +190,7 @@ class OpenStackNetworkInterfaceCreateForm extends NetworkInterfaceCreateForm { * The current form state. */ public function save(array $form, FormStateInterface $form_state): void { $entity = $this->entity; // Switch OpenStack EC2 or REST service based on $entity->getCloudContext(). $this->ec2Service = $this->openStackServiceFactory->get($entity->getCloudContext()); parent::save($form, $form_state); if ($this->ec2Service instanceof OpenStackRestService) { $this->updateNameAndCreatedByTags($entity, $entity->getNetworkInterfaceId()); } $this->openStackOperationsService->createOpenStackNetworkInterface($this->entity, $form, $form_state); } }