Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/floating_ip.ts +30 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/floating_ip.ts: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,7 +69,37 @@ const OPENSTACK_FLOATING_IP_TEMPLATE: EntityFormTemplate[] = [ }, ], submitButtonLabel: 'Delete' }, { cloudServiceProvider: 'openstack', entityName: 'floating_ip', actionType: 'disassociate', entityRecords: [ { type: 'label', text: 'Are you sure you want to disassociate this {{entityName}}({{name}})?' }, { type: 'panel', panelName: 'Floating IP Information', keyValueRecords: [ { type: 'join', labelName: 'Instance ID', name: 'instance_id', info: { entityTypeId: 'openstack_instance', keyColumn: 'name', }, defaultValue: '', readOnly: true }, { type: 'join', labelName: 'Network ID', name: 'network_interface_id', info: { entityTypeId: 'openstack_network_interface', keyColumn: 'name', }, defaultValue: '', readOnly: true } ] } ], submitButtonLabel: 'Disassociate Address' }, ] export default OPENSTACK_FLOATING_IP_TEMPLATE; modules/cloud_dashboard/cloud_dashboard/src/molecules/DataTableRowWithOperationLinks.tsx +5 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/DataTableRowWithOperationLinks.tsx: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -104,6 +104,11 @@ const getOperations = (dataRecord: DataRecord): string[] => { return ['Copy']; case 'k8s_pod_resource_store': return ['Copy']; case 'openstack_floating_ip': return dataRecord.value['instance_id'] === '' || dataRecord.value['instance_id'] === null ? ['Associate'] : ['Disassociate']; case 'vmware_vm': const list: string[] = []; if (dataRecord.value['power_state'] === 'POWERED_OFF') { Loading modules/cloud_service_providers/openstack/openstack.routing.yml +10 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -725,6 +725,16 @@ entity.openstack_floating_ip.delete: options: perm: 'delete any openstack floating ip+delete own openstack floating ip' entity.openstack_floating_ip.disassociate: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_floating_ip/{entity_id}/disassociate' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_floating_ip command: disassociate methods: [POST] requirements: _custom_access: '\Drupal\openstack\Controller\ApiController::access' entity.openstack_security_group.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_security_group/create' defaults: Loading modules/cloud_service_providers/openstack/openstack.services.yml +1 −1 Changes for modules/cloud_service_providers/openstack/openstack.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,4 +24,4 @@ services: openstack.operations: class: Drupal\openstack\Service\OpenStackOperationsService arguments: ['@aws_cloud.openstack.operations', '@plugin.manager.cloud_config_plugin', '@cloud', '@openstack.ec2', '@entity_type.manager', '@messenger', '@openstack.factory', '@request_stack'] arguments: ['@aws_cloud.openstack.operations', '@plugin.manager.cloud_config_plugin', '@cloud', '@openstack.ec2', '@entity_type.manager', '@messenger', '@openstack.factory', '@request_stack', '@entity.link_renderer'] modules/cloud_service_providers/openstack/src/Controller/ApiController.php +41 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,9 +5,13 @@ namespace Drupal\openstack\Controller; use Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface; use Drupal\cloud\Service\CloudService; use Drupal\cloud\Service\CloudServiceInterface; use Drupal\cloud\Traits\AccessCheckTrait; use Drupal\cloud\Traits\CloudContentEntityTrait; use Drupal\cloud\Traits\CloudResourceTrait; use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\Messenger; use Drupal\Core\Render\RendererInterface; Loading @@ -22,6 +26,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Route; /** * Api controller for interacting with OpenStack. Loading @@ -30,6 +35,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { use CloudContentEntityTrait; use CloudResourceTrait; use AccessCheckTrait; /** * The OpenStack Service. Loading Loading @@ -162,6 +168,37 @@ class ApiController extends ControllerBase implements ApiControllerInterface { ); } /** * Checks user access for a specific request based on the cloud context. * * @param string $cloud_context * Cloud context to check. * @param \Drupal\Core\Session\AccountInterface $account * Run access checks for this account. * @param \Symfony\Component\Routing\Route $route * The route object. * @param string $entity_type_id * The entity type. * @param string $entity_id * The entity id. * @param string $command * The command name. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */ public function access(string $cloud_context, AccountInterface $account, Route $route, string $entity_type_id, string $entity_id, string $command): AccessResultInterface { $entity = $this->entityTypeManager ->getStorage($entity_type_id) ->load($entity_id); if (!empty($entity) && $entity instanceof EntityInterface) { return $entity->access($command, $account, TRUE); } // Unknown operation, no opinion. return AccessResult::neutral(); } /** * Update message after refresh resources. * Loading Loading @@ -601,6 +638,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteOpenStackFloatingIp'; break; case 'disassociate_openstack_floating_ip': $method_name = 'disassociateOpenStackFloatingIp'; break; case 'create_openstack_security_group': /** @var \Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface $entity */ $entity->setGroupName($request->get('group_name', '')); Loading Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/floating_ip.ts +30 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/floating_ip.ts: 30 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,7 +69,37 @@ const OPENSTACK_FLOATING_IP_TEMPLATE: EntityFormTemplate[] = [ }, ], submitButtonLabel: 'Delete' }, { cloudServiceProvider: 'openstack', entityName: 'floating_ip', actionType: 'disassociate', entityRecords: [ { type: 'label', text: 'Are you sure you want to disassociate this {{entityName}}({{name}})?' }, { type: 'panel', panelName: 'Floating IP Information', keyValueRecords: [ { type: 'join', labelName: 'Instance ID', name: 'instance_id', info: { entityTypeId: 'openstack_instance', keyColumn: 'name', }, defaultValue: '', readOnly: true }, { type: 'join', labelName: 'Network ID', name: 'network_interface_id', info: { entityTypeId: 'openstack_network_interface', keyColumn: 'name', }, defaultValue: '', readOnly: true } ] } ], submitButtonLabel: 'Disassociate Address' }, ] export default OPENSTACK_FLOATING_IP_TEMPLATE;
modules/cloud_dashboard/cloud_dashboard/src/molecules/DataTableRowWithOperationLinks.tsx +5 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/molecules/DataTableRowWithOperationLinks.tsx: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -104,6 +104,11 @@ const getOperations = (dataRecord: DataRecord): string[] => { return ['Copy']; case 'k8s_pod_resource_store': return ['Copy']; case 'openstack_floating_ip': return dataRecord.value['instance_id'] === '' || dataRecord.value['instance_id'] === null ? ['Associate'] : ['Disassociate']; case 'vmware_vm': const list: string[] = []; if (dataRecord.value['power_state'] === 'POWERED_OFF') { Loading
modules/cloud_service_providers/openstack/openstack.routing.yml +10 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 10 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -725,6 +725,16 @@ entity.openstack_floating_ip.delete: options: perm: 'delete any openstack floating ip+delete own openstack floating ip' entity.openstack_floating_ip.disassociate: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_floating_ip/{entity_id}/disassociate' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_floating_ip command: disassociate methods: [POST] requirements: _custom_access: '\Drupal\openstack\Controller\ApiController::access' entity.openstack_security_group.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_security_group/create' defaults: Loading
modules/cloud_service_providers/openstack/openstack.services.yml +1 −1 Changes for modules/cloud_service_providers/openstack/openstack.services.yml: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -24,4 +24,4 @@ services: openstack.operations: class: Drupal\openstack\Service\OpenStackOperationsService arguments: ['@aws_cloud.openstack.operations', '@plugin.manager.cloud_config_plugin', '@cloud', '@openstack.ec2', '@entity_type.manager', '@messenger', '@openstack.factory', '@request_stack'] arguments: ['@aws_cloud.openstack.operations', '@plugin.manager.cloud_config_plugin', '@cloud', '@openstack.ec2', '@entity_type.manager', '@messenger', '@openstack.factory', '@request_stack', '@entity.link_renderer']
modules/cloud_service_providers/openstack/src/Controller/ApiController.php +41 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,9 +5,13 @@ namespace Drupal\openstack\Controller; use Drupal\cloud\Plugin\cloud\config\CloudConfigPluginManagerInterface; use Drupal\cloud\Service\CloudService; use Drupal\cloud\Service\CloudServiceInterface; use Drupal\cloud\Traits\AccessCheckTrait; use Drupal\cloud\Traits\CloudContentEntityTrait; use Drupal\cloud\Traits\CloudResourceTrait; use Drupal\Core\Access\AccessResult; use Drupal\Core\Access\AccessResultInterface; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Messenger\Messenger; use Drupal\Core\Render\RendererInterface; Loading @@ -22,6 +26,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Route; /** * Api controller for interacting with OpenStack. Loading @@ -30,6 +35,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface { use CloudContentEntityTrait; use CloudResourceTrait; use AccessCheckTrait; /** * The OpenStack Service. Loading Loading @@ -162,6 +168,37 @@ class ApiController extends ControllerBase implements ApiControllerInterface { ); } /** * Checks user access for a specific request based on the cloud context. * * @param string $cloud_context * Cloud context to check. * @param \Drupal\Core\Session\AccountInterface $account * Run access checks for this account. * @param \Symfony\Component\Routing\Route $route * The route object. * @param string $entity_type_id * The entity type. * @param string $entity_id * The entity id. * @param string $command * The command name. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */ public function access(string $cloud_context, AccountInterface $account, Route $route, string $entity_type_id, string $entity_id, string $command): AccessResultInterface { $entity = $this->entityTypeManager ->getStorage($entity_type_id) ->load($entity_id); if (!empty($entity) && $entity instanceof EntityInterface) { return $entity->access($command, $account, TRUE); } // Unknown operation, no opinion. return AccessResult::neutral(); } /** * Update message after refresh resources. * Loading Loading @@ -601,6 +638,10 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'deleteOpenStackFloatingIp'; break; case 'disassociate_openstack_floating_ip': $method_name = 'disassociateOpenStackFloatingIp'; break; case 'create_openstack_security_group': /** @var \Drupal\aws_cloud\Entity\Ec2\SecurityGroupInterface $entity */ $entity->setGroupName($request->get('group_name', '')); Loading