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 @@ -10,6 +10,7 @@ import OPENSTACK_INSTANCE_TEMPLATE from 'constant/form_template/openstack/instan 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 OPENSTACK_SNAPSHOT_TEMPLATE from 'constant/form_template/openstack/snapshot'; import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ Loading @@ -26,6 +27,7 @@ const ENTITY_FORM_LIST = [ ...OPENSTACK_SECURITY_GROUP_TEMPLATE, ...OPENSTACK_KEY_PAIR_TEMPLATE, ...OPENSTACK_NETWORK_INTERFACE_TEMPLATE, ...OPENSTACK_SNAPSHOT_TEMPLATE, ...VMWARE_VM_TEMPLATE, ]; Loading modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/snapshot.ts 0 → 100644 +25 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/snapshot.ts: 25 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const OPENSTACK_SNAPSHOT_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'openstack', entityName: 'snapshot', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Snapshot', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select', labelName: 'Volume ID', name: 'volume_id', url: '/cloud_dashboard/openstack/{cloud_context}/snapshot_volume_ids', defaultValue: '', required: true }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, ] } ] }, ] export default OPENSTACK_SNAPSHOT_TEMPLATE; modules/cloud_service_providers/openstack/openstack.routing.yml +26 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 26 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -777,3 +777,29 @@ entity.openstack_security_group.revoke: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any openstack security group+delete own openstack security group' entity.openstack_snapshot.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_snapshot/create' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_snapshot 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 snapshot' entity.openstack_snapshot.snapshot_volume_ids: path: '/cloud_dashboard/openstack/{cloud_context}/snapshot_volume_ids' defaults: _controller: '\Drupal\openstack\Controller\ApiController::getVolumeOptions' 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 snapshot' modules/cloud_service_providers/openstack/src/Controller/ApiController.php +37 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 37 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -665,6 +665,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'revokeOpenStackSecurityGroup'; break; case 'create_openstack_snapshot': /** @var \Drupal\aws_cloud\Entity\Ec2\SnapshotInterface $entity */ $entity->setName($request->get('name', '')); $entity->set('volume_id', $request->get('volume_id', '')); $entity->set('description', $request->get('description', '')); $method_name = 'createOpenStackSnapshot'; break; } // Execute the process. Loading Loading @@ -710,4 +718,33 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($options); } /** * {@inheritdoc} */ public function getVolumeOptions($cloud_context): JsonResponse { $options = []; $params = [ 'cloud_context' => $cloud_context, ]; if (!$this->currentUser->hasPermission("view any openstack volume")) { $params['uid'] = $this->currentUser->id(); } $volumes = $this->entityTypeManager ->getStorage("openstack_volume") ->loadByProperties($params); foreach ($volumes ?: [] as $volume) { $options[] = [ 'value' => $volume->getVolumeId(), 'label' => $volume->getName() !== $volume->getVolumeId() ? "{$volume->getName()} ({$volume->getVolumeId()})" : $volume->getVolumeId(), ]; } return new JsonResponse($options); } } modules/cloud_service_providers/openstack/src/Controller/ApiControllerInterface.php +14 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiControllerInterface.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -150,4 +150,18 @@ interface ApiControllerInterface { */ public function getNetworkInterfaceOptions(string $cloud_context): JsonResponse; /** * Helper function to get volume options. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getVolumeOptions($cloud_context): JsonResponse; } 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 @@ -10,6 +10,7 @@ import OPENSTACK_INSTANCE_TEMPLATE from 'constant/form_template/openstack/instan 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 OPENSTACK_SNAPSHOT_TEMPLATE from 'constant/form_template/openstack/snapshot'; import VMWARE_VM_TEMPLATE from 'constant/form_template/vmware/vm'; const ENTITY_FORM_LIST = [ Loading @@ -26,6 +27,7 @@ const ENTITY_FORM_LIST = [ ...OPENSTACK_SECURITY_GROUP_TEMPLATE, ...OPENSTACK_KEY_PAIR_TEMPLATE, ...OPENSTACK_NETWORK_INTERFACE_TEMPLATE, ...OPENSTACK_SNAPSHOT_TEMPLATE, ...VMWARE_VM_TEMPLATE, ]; Loading
modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/snapshot.ts 0 → 100644 +25 −0 Changes for modules/cloud_dashboard/cloud_dashboard/src/constant/form_template/openstack/snapshot.ts: 25 added lines, 0 removed lines. Original line number Diff line number Diff line import EntityFormTemplate from 'model/EntityFormTemplate'; const OPENSTACK_SNAPSHOT_TEMPLATE: EntityFormTemplate[] = [ { cloudServiceProvider: 'openstack', entityName: 'snapshot', actionType: 'create', entityRecords: [ { type: 'panel', panelName: 'Snapshot', keyValueRecords: [ { type: 'default', labelName: 'Name', name: 'name', defaultValue: '' }, { type: 'select', labelName: 'Volume ID', name: 'volume_id', url: '/cloud_dashboard/openstack/{cloud_context}/snapshot_volume_ids', defaultValue: '', required: true }, { type: 'default', labelName: 'Description', name: 'description', defaultValue: '' }, ] } ] }, ] export default OPENSTACK_SNAPSHOT_TEMPLATE;
modules/cloud_service_providers/openstack/openstack.routing.yml +26 −0 Changes for modules/cloud_service_providers/openstack/openstack.routing.yml: 26 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -777,3 +777,29 @@ entity.openstack_security_group.revoke: _custom_access: '\Drupal\cloud\Controller\CloudConfigController::access' options: perm: 'delete any openstack security group+delete own openstack security group' entity.openstack_snapshot.create: path: '/cloud_dashboard/openstack/{cloud_context}/openstack_snapshot/create' defaults: _controller: '\Drupal\openstack\Controller\ApiController::operateEntity' entity_type_id: openstack_snapshot 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 snapshot' entity.openstack_snapshot.snapshot_volume_ids: path: '/cloud_dashboard/openstack/{cloud_context}/snapshot_volume_ids' defaults: _controller: '\Drupal\openstack\Controller\ApiController::getVolumeOptions' 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 snapshot'
modules/cloud_service_providers/openstack/src/Controller/ApiController.php +37 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiController.php: 37 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -665,6 +665,14 @@ class ApiController extends ControllerBase implements ApiControllerInterface { $method_name = 'revokeOpenStackSecurityGroup'; break; case 'create_openstack_snapshot': /** @var \Drupal\aws_cloud\Entity\Ec2\SnapshotInterface $entity */ $entity->setName($request->get('name', '')); $entity->set('volume_id', $request->get('volume_id', '')); $entity->set('description', $request->get('description', '')); $method_name = 'createOpenStackSnapshot'; break; } // Execute the process. Loading Loading @@ -710,4 +718,33 @@ class ApiController extends ControllerBase implements ApiControllerInterface { return new JsonResponse($options); } /** * {@inheritdoc} */ public function getVolumeOptions($cloud_context): JsonResponse { $options = []; $params = [ 'cloud_context' => $cloud_context, ]; if (!$this->currentUser->hasPermission("view any openstack volume")) { $params['uid'] = $this->currentUser->id(); } $volumes = $this->entityTypeManager ->getStorage("openstack_volume") ->loadByProperties($params); foreach ($volumes ?: [] as $volume) { $options[] = [ 'value' => $volume->getVolumeId(), 'label' => $volume->getName() !== $volume->getVolumeId() ? "{$volume->getName()} ({$volume->getVolumeId()})" : $volume->getVolumeId(), ]; } return new JsonResponse($options); } }
modules/cloud_service_providers/openstack/src/Controller/ApiControllerInterface.php +14 −0 Changes for modules/cloud_service_providers/openstack/src/Controller/ApiControllerInterface.php: 14 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -150,4 +150,18 @@ interface ApiControllerInterface { */ public function getNetworkInterfaceOptions(string $cloud_context): JsonResponse; /** * Helper function to get volume options. * * @param string $cloud_context * Cloud context to use in the query. * * @return \Symfony\Component\HttpFoundation\JsonResponse * The JSON response. * * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ public function getVolumeOptions($cloud_context): JsonResponse; }