Skip to content
Snippets Groups Projects
Commit b74f1284 authored by Ryo Yamashita's avatar Ryo Yamashita Committed by Yas Naoi
Browse files

Issue #3301955 by Ryo Yamashita, yas: Add the function to import AWS Cloud key pair in the SPA

parent 147eac2c
No related branches found
No related tags found
3 merge requests!1316Issue #3310263: Release 4.5.0,!1260Issue #3307397: Release 4.4.0,!1202Issue #3301955: Add the function to import AWS Cloud key pair in the SPA
......@@ -44,6 +44,21 @@ const AWS_CLOUD_KEY_PAIR_TEMPLATE: EntityFormTemplate[] = [
}
],
},
{
cloudServiceProvider: 'aws_cloud',
entityName: 'key_pair',
actionType: 'import',
entityRecords: [
{
type: 'panel',
panelName: 'Key pair',
keyValueRecords: [
{ type: 'file', labelName: 'Public Key', name: 'key_pair_public_key' },
{ type: 'default', labelName: 'Key pair name', name: 'key_pair_name', defaultValue: '', required: true },
]
}
]
},
]
export default AWS_CLOUD_KEY_PAIR_TEMPLATE;
......@@ -1100,6 +1100,21 @@ entity.aws_cloud_key_pair.edit:
options:
perm: 'edit any aws cloud key pair+edit own aws cloud key pair'
entity.aws_cloud_key_pair.import:
path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_key_pair/import'
defaults:
_controller: '\Drupal\aws_cloud\Controller\Ec2\ApiController::operateEntity'
entity_type_id: aws_cloud_key_pair
entity_id: ''
command: import
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 key pair'
entity.aws_cloud_security_group.create:
path: '/cloud_dashboard/aws_cloud/{cloud_context}/aws_cloud_security_group/{entity_id}/create'
defaults:
......
......@@ -904,6 +904,21 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
$method_name = 'editKeyPair';
break;
case 'import_aws_cloud_key_pair':
/** @var \Drupal\aws_cloud\Entity\Ec2\KeyPairInterface $entity */
$entity->set('key_pair_name', $request->get('key_pair_name', ''));
/** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
$file = $request->files->get('key_pair_public_key');
if (empty($file)) {
return new JsonResponse([
'result' => 'NG',
'reason' => 'Internal Server Error',
], 500);
}
$form_state->setValue('key_pair_public_key', $file->getRealPath());
$method_name = 'importKeyPair';
break;
case 'reboot_aws_cloud_instance':
$method_name = 'rebootInstance';
break;
......
......@@ -621,7 +621,7 @@ class ApiController extends ControllerBase implements ApiControllerInterface {
$entity->set('key_pair_name', $request->get('key_pair_name', ''));
/** @var \Symfony\Component\HttpFoundation\File\UploadedFile $file */
$file = $request->files->get('key_pair_public_key');
if (!$file) {
if (empty($file)) {
return new JsonResponse([
'result' => 'NG',
'reason' => 'Internal Server Error',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment