Skip to content
Snippets Groups Projects
Commit bd48b6eb authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3044522 by Xiaohua Guan, baldwinlouie, Masami, yas: Display the...

Issue #3044522 by Xiaohua Guan, baldwinlouie, Masami, yas: Display the instance type pricing list by Google Spreadsheet
parent d6fbe934
Branches 4.0.x
No related tags found
No related merge requests found
Showing
with 305 additions and 327 deletions
......@@ -30,7 +30,7 @@ function cloud_update_8102() {
/**
* Change the field name of user_id to uid.
*/
function cloud_update_8109() {
function cloud_update_8103() {
$db = \Drupal::database();
$tables = [
......@@ -65,3 +65,12 @@ function cloud_update_8109() {
}
}
}
/**
* Update cloud_listing view.
*/
function cloud_update_8104() {
cloud_update_yml_definitions([
'views.view.cloud_listing.yml',
]);
}
......@@ -2,6 +2,7 @@
"name": "drupal/cloud",
"type": "drupal-module",
"require": {
"aws/aws-sdk-php": "3.*.*@dev"
"aws/aws-sdk-php": "3.*.*@dev",
"google/apiclient": "^2.0"
}
}
......@@ -62,8 +62,9 @@ display:
description: ''
columns:
name: name
cloud_context_1: cloud_context_1
list_instances_cloud_config: list_instances_cloud_config
pricing_internal_cloud_config: pricing_internal_cloud_config
pricing_external_cloud_config: pricing_external_cloud_config
info:
name:
sortable: true
......@@ -72,14 +73,21 @@ display:
separator: ''
empty_column: false
responsive: ''
cloud_context_1:
sortable: true
list_instances_cloud_config:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
list_instances_cloud_config:
pricing_internal_cloud_config:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
pricing_external_cloud_config:
sortable: false
default_sort_order: asc
align: ''
......@@ -155,14 +163,14 @@ display:
multi_type: separator
separator: ', '
field_api_classes: false
cloud_context_1:
id: cloud_context_1
table: cloud_config_field_data
field: cloud_context
list_instances_cloud_config:
id: list_instances_cloud_config
table: cloud_config
field: list_instances_cloud_config
relationship: none
group_type: group
admin_label: ''
label: 'Cloud Provider Machine Name'
label: Instances
exclude: false
alter:
alter_text: false
......@@ -203,31 +211,17 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: true
click_sort_column: value
type: string
settings:
link_to_entity: false
group_column: value
group_columns: { }
group_rows: true
delta_limit: 0
delta_offset: 0
delta_reversed: false
delta_first_last: false
multi_type: separator
separator: ', '
field_api_classes: false
text: view
entity_type: cloud_config
entity_field: cloud_context
plugin_id: field
list_instances_cloud_config:
id: list_instances_cloud_config
plugin_id: cloud_list_instances
pricing_internal_cloud_config:
id: pricing_internal_cloud_config
table: cloud_config
field: list_instances_cloud_config
field: pricing_internal_cloud_config
relationship: none
group_type: group
admin_label: ''
label: Instances
label: Instance Pricing
exclude: false
alter:
alter_text: false
......@@ -270,7 +264,58 @@ display:
hide_alter_empty: true
text: view
entity_type: cloud_config
plugin_id: cloud_list_instances
plugin_id: cloud_pricing_internal
pricing_external_cloud_config:
id: pricing_external_cloud_config
table: cloud_config
field: pricing_external_cloud_config
relationship: none
group_type: group
admin_label: ''
label: Spreadsheet
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: view
entity_type: cloud_config
plugin_id: cloud_pricing_external
filters: { }
sorts: { }
title: 'Cloud Service Providers'
......
......@@ -8,6 +8,22 @@ views.field.cloud_list_instances:
type: label
label: 'Text to display'
views.field.cloud_pricing_internal:
type: views_field
label: 'Link to an internal pricing'
mapping:
text:
type: label
label: 'Text to display'
views.field.cloud_pricing_external:
type: views_field
label: 'Link to an external pricing'
mapping:
text:
type: label
label: 'Text to display'
views.field.cloud_list_templates:
type: views_field
label: 'Link to cloud server template list'
......
......@@ -20,8 +20,8 @@ entity.cloud_server_template_type.add_form:
appears_on:
- entity.cloud_server_template_type.collection
aws_cloud.instanceTypePrices:
route_name: aws_cloud.instanceTypePrices
aws_cloud.instance_type_prices:
route_name: aws_cloud.instance_type_prices
title: 'Instance Type Prices'
appears_on:
- entity.cloud_server_template.add_form
......
......@@ -535,6 +535,25 @@ function aws_cloud_update_8131() {
}
}
/**
* Add a configuration item and a field.
*
* Add configuration item google_credential_file_path to aws_cloud.settings,
* and Add field field_google_spreadsheet_pricing_url to cloud_config.
*/
function aws_cloud_update_8132() {
aws_cloud_update_entity_definitions();
// Update value of google_credential_file_path.
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('aws_cloud.settings');
$config->set('google_credential_file_path', 'private://aws_cloud/.gapps/client_secrets.json');
$config->save();
// Add field_google_spreadsheet_pricing_url.
aws_cloud_add_fields('cloud_config', 'aws_ec2', 'field_spreadsheet_pricing_url');
}
/**
* Helper function to add fields to the entity type.
*
......
......@@ -79,6 +79,6 @@ aws_cloud.local_tasks.snapshot:
aws_cloud.local_tasks.instance_type_price:
title: 'Instance Type Prices'
route_name: 'aws_cloud.instanceTypePrices'
route_name: 'aws_cloud.instance_type_prices'
base_route: 'aws_cloud.local_tasks.cloud_context'
weight: 10
......@@ -423,6 +423,20 @@ EOF;
$cloud_config->set('field_secret_key', NULL);
}
}
// Create a google spreadsheet for instance type pricing.
// Delete the old spreadsheet if existing.
$spreadsheet = \Drupal::service('aws_cloud.google_spreadsheet');
$old_url = $cloud_config->get('field_spreadsheet_pricing_url')->value;
if (!empty($old_url)) {
$spreadsheet->delete($old_url);
}
$url = $spreadsheet->create(
$cloud_config->get('field_region')->value,
'AWS Cloud Instance Type Pricing of ' . $cloud_config->getName()
);
$cloud_config->set('field_spreadsheet_pricing_url', $url);
}
/**
......@@ -510,6 +524,13 @@ function aws_cloud_cloud_config_delete(CloudConfig $cloud_config) {
// Clean up credential files.
$credential_file = aws_cloud_ini_file_path($cloud_config->get('cloud_context')->value);
file_unmanaged_delete($credential_file);
// Delete the spreadsheet for instance type pricing.
$spreadsheet = \Drupal::service('aws_cloud.google_spreadsheet');
$url = $cloud_config->get('field_spreadsheet_pricing_url')->value;
if (!empty($url)) {
$spreadsheet->delete($url);
}
}
/**
......@@ -751,6 +772,22 @@ function aws_cloud_query_aws_cloud_volume_views_access_alter(AlterableInterface
* Add termination options to the server template launch form.
*/
function aws_cloud_form_cloud_server_template_aws_cloud_launch_form_alter(&$form, FormStateInterface $form_state, $form_id) {
/* @var \Drupal\cloud_server_template\Entity\CloudServerTemplate $cloud_server_template */
$cloud_server_template = \Drupal::routeMatch()->getParameter('cloud_server_template');
$form['cost'] = [
'#type' => 'details',
'#title' => t('Cost'),
'#open' => TRUE,
];
$cloud_context = \Drupal::routeMatch()->getParameter('cloud_context');
$price_table_renderer = \Drupal::service('aws_cloud.instance_type_price_table_renderer');
$form['cost']['price_table'] = $price_table_renderer->render(
$cloud_context,
$cloud_server_template->get('field_instance_type')->value
);
$form['automation'] = [
'#type' => 'details',
'#title' => t('Automation'),
......@@ -783,9 +820,6 @@ function aws_cloud_form_cloud_server_template_aws_cloud_launch_form_alter(&$form
'#default_value' => DrupalDateTime::createFromTimestamp(time() + 2592000),
];
/* @var \Drupal\cloud_server_template\Entity\CloudServerTemplate $cloud_server_template */
$cloud_server_template = \Drupal::routeMatch()->getParameter('cloud_server_template');
$form['automation']['schedule'] = [
'#title' => t('Schedule'),
'#type' => 'select',
......@@ -1814,7 +1848,7 @@ function aws_cloud_get_schedule() {
}
/**
* Get instance types from the EC2 pricing endpoint.
* Get instance types from the EC2 pricing endpoint with cloud_context.
*
* @param string $cloud_context
* The cloud context used to get instance types.
......@@ -1830,20 +1864,9 @@ function aws_cloud_get_instance_types($cloud_context) {
$cloud_config = $cloud_config_plugin->loadConfigEntity();
if ($cloud_config != FALSE) {
$cache_key = _aws_cloud_get_instance_type_cache_key($cloud_config);
$cache = \Drupal::cache()->get($cache_key);
if ($cache) {
$instance_types = $cache->data;
}
else {
// Set a message saying instance types need to be imported. This
// can occur when the cache clear all is run.
\Drupal::messenger()->addError(t(
'Instance types for @cloud_context not found. Please wait for cron to run or re-save the cloud config entity: @cloud_context.', [
'@cloud_context' => $cloud_context,
]
));
}
$instance_types = aws_cloud_get_instance_types_by_region(
$cloud_config->get('field_region')->value
);
}
else {
// Cannot load cloud config entity. Show an error to the user.
......@@ -1852,6 +1875,35 @@ function aws_cloud_get_instance_types($cloud_context) {
return $instance_types;
}
/**
* Get instance types from the EC2 pricing endpoint with region.
*
* @param string $region
* The region used to get instance types.
*
* @return array
* An array of instances.
*/
function aws_cloud_get_instance_types_by_region($region) {
$instance_types = [];
$cache_key = _aws_cloud_get_instance_type_cache_key_by_region($region);
$cache = \Drupal::cache()->get($cache_key);
if ($cache) {
$instance_types = $cache->data;
}
else {
// Set a message saying instance types need to be imported. This
// can occur when the cache clear all is run.
\Drupal::messenger()->addError(t(
'Instance types for @region not found. Please wait for cron to run or re-save the cloud config entity: @cloud_context.', [
'@region' => $region,
]
));
}
return $instance_types;
}
/**
* Update instance types every 30 days.
*
......@@ -1907,7 +1959,7 @@ function aws_cloud_import_instance_types(CloudConfig $cloud_config) {
}
/**
* Helper function to generate instance type cache key.
* Helper function to generate instance type cache key with cloud_config.
*
* @param Drupal\cloud\Entity\CloudConfig $cloud_config
* Cloud config object.
......@@ -1919,6 +1971,19 @@ function _aws_cloud_get_instance_type_cache_key(CloudConfig $cloud_config) {
return $cloud_config->get('field_region')->value . '-instance_types';
}
/**
* Helper function to generate instance type cache key with region.
*
* @param string $region
* Region.
*
* @return string
* Instance type cache key.
*/
function _aws_cloud_get_instance_type_cache_key_by_region($region) {
return $region . '-instance_types';
}
/**
* Helper function to generate instance type state key.
*
......
......@@ -97,7 +97,7 @@ aws_cloud.settings:
# AWS Cloud Instance Type Prices
aws_cloud.instanceTypePrices:
aws_cloud.instance_type_prices:
path: '/clouds/aws_cloud/{cloud_context}/instance_type_price'
defaults:
_title: AWS Cloud Instance Type Prices
......
......@@ -2,14 +2,29 @@ services:
aws_cloud.ec2:
class: Drupal\aws_cloud\Service\AwsEc2Service
arguments: ['@entity_type.manager', '@logger.factory', '@config.factory', '@messenger', '@string_translation', '@current_user', '@plugin.manager.cloud_config_plugin', '@plugin.manager.field.field_type', '@entity_field.manager']
aws_cloud.iam:
class: Drupal\aws_cloud\Service\AwsIamService
arguments: ['@logger.factory', '@config.factory', '@messenger', '@string_translation', '@plugin.manager.cloud_config_plugin']
aws_cloud.pricing:
class: Drupal\aws_cloud\Service\AwsPricingService
arguments: ['@logger.factory', '@config.factory', '@messenger', '@string_translation', '@plugin.manager.cloud_config_plugin', '@http_client']
aws_cloud.subscriber:
class: Drupal\aws_cloud\EventSubscriber\AwsCloudSubscriber
arguments: ['@entity_type.manager', '@messenger', '@string_translation', '@current_route_match', '@aws_cloud.ec2', '@cache.default']
tags:
- { name: event_subscriber }
aws_cloud.instance_type_price_data_provider:
class: Drupal\aws_cloud\Service\InstanceTypePriceDataProvider
arguments: ['@aws_cloud.pricing', '@string_translation']
aws_cloud.instance_type_price_table_renderer:
class: Drupal\aws_cloud\Service\InstanceTypePriceTableRenderer
arguments: ['@request_stack', '@aws_cloud.instance_type_price_data_provider']
aws_cloud.google_spreadsheet:
class: Drupal\aws_cloud\Service\GoogleSpreadsheetService
arguments: ['@messenger', '@config.factory', '@aws_cloud.instance_type_price_data_provider', '@string_translation']
{
"name": "drupal/aws_cloud",
"require": {
"aws/aws-sdk-php": "3.*.*@dev"
"aws/aws-sdk-php": "3.*.*@dev",
"google/apiclient": "^2.0"
},
"extra": {
"drush": {
......
......@@ -8,3 +8,4 @@ aws_cloud_scheduler_tag: "Schedule"
aws_cloud_scheduler_periods: ""
aws_cloud_instance_terminate: false
aws_cloud_view_refresh_interval: 10
google_credential_file_path: 'private://aws_cloud/.gapps/client_secrets.json'
......@@ -16,6 +16,7 @@ dependencies:
- field.field.cloud_config.aws_ec2.field_account_id
- field.field.cloud_config.aws_ec2.field_use_instance_credentials
- field.field.cloud_config.aws_ec2.field_x_509_certificate
- field.field.cloud_config.aws_ec2.field_spreadsheet_pricing_url
id: cloud_config.aws_ec2.default
targetEntityType: cloud_config
bundle: aws_ec2
......@@ -132,4 +133,5 @@ content:
placeholder: ''
region: content
third_party_settings: { }
hidden: { }
hidden:
field_spreadsheet_pricing_url: true
......@@ -16,6 +16,7 @@ dependencies:
- field.field.cloud_config.aws_ec2.field_account_id
- field.field.cloud_config.aws_ec2.field_use_instance_credentials
- field.field.cloud_config.aws_ec2.field_x_509_certificate
- field.field.cloud_config.aws_ec2.field_spreadsheet_pricing_url
module:
- options
- user
......@@ -126,6 +127,14 @@ content:
third_party_settings: { }
type: basic_string
region: content
field_spreadsheet_pricing_url:
weight: 100
label: above
settings:
link_to_entity: false
third_party_settings: { }
type: string
region: content
name:
label: above
type: string
......
langcode: en
status: true
dependencies:
config:
- cloud.cloud_config_type.aws_ec2
- field.storage.cloud_config.field_spreadsheet_pricing_url
id: cloud_config.aws_ec2.field_spreadsheet_pricing_url
field_name: field_spreadsheet_pricing_url
entity_type: cloud_config
bundle: aws_ec2
label: 'Spreadsheet Pricing Url'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string
langcode: en
status: true
dependencies:
module:
- cloud
id: cloud_config.field_spreadsheet_pricing_url
field_name: field_spreadsheet_pricing_url
entity_type: cloud_config
type: string
settings:
max_length: 255
is_ascii: false
case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
......@@ -23,3 +23,5 @@ aws_cloud.settings:
type: boolean
aws_cloud_view_refresh_interval:
type: integer
google_credential_file_path:
type: string
......@@ -11,3 +11,7 @@
.aws_cloud_instance_type_prices.table td {
vertical-align: middle;
}
.aws_cloud_instance_type_prices.table .highlight {
font-weight: bold;
}
......@@ -3,66 +3,24 @@
namespace Drupal\aws_cloud\Controller\Ec2;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\aws_cloud\Service\AwsPricingServiceInterface;
use Drupal\aws_cloud\Aws\Ec2\InstanceTypePriceControllerInterface;
use Drupal\aws_cloud\Service\InstanceTypePriceTableRenderer;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Controller responsible to show price list.
*/
class InstanceTypePriceController extends ControllerBase implements InstanceTypePriceControllerInterface {
const ONE_YEAR = 365.25;
/**
* The Aws Pricing Service.
*
* @var \Drupal\aws_cloud\Service\AwsPricingServiceInterface
*/
protected $awsPricingService;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* Cloud context string.
*
* @var string
*/
private $cloudContext;
/**
* Request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
private $request;
/**
* InstanceTypePriceController constructor.
*
* @param \Drupal\aws_cloud\Service\AwsPricingServiceInterface $aws_pricing_service
* @param \Drupal\aws_cloud\Service\InstanceTypePriceTableRenderer $price_table_renderer
* AWS Pricing service.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* Messanger Object.
* @param \Symfony\Component\HttpFoundation\Request $request
* Request Object.
*/
public function __construct(
AwsPricingServiceInterface $aws_pricing_service,
MessengerInterface $messenger,
Request $request
) {
$this->awsPricingService = $aws_pricing_service;
$this->messenger = $messenger;
$this->request = $request;
public function __construct(InstanceTypePriceTableRenderer $price_table_renderer) {
$this->priceTableRenderer = $price_table_renderer;
}
/**
......@@ -70,9 +28,7 @@ class InstanceTypePriceController extends ControllerBase implements InstanceType
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('aws_cloud.pricing'),
$container->get('messenger'),
$container->get('request_stack')->getCurrentRequest()
$container->get('aws_cloud.instance_type_price_table_renderer')
);
}
......@@ -80,228 +36,11 @@ class InstanceTypePriceController extends ControllerBase implements InstanceType
* {@inheritdoc}
*/
public function show($cloud_context) {
$this->cloudContext = $cloud_context;
$build = [];
$build['table'] = $this->buildTable();
$build['#attached']['library'][] = 'aws_cloud/aws_cloud_instance_type_prices';
$build['table'] = $this->priceTableRenderer->render($cloud_context);
return $build;
}
/**
* Build table.
*
* @return array
* The render array of table.
*/
private function buildTable() {
$table = [
'#type' => 'table',
'#header' => array_values($this->getTableHeader()),
'#attributes' => [
'class' => ['aws_cloud_instance_type_prices'],
],
];
foreach ($this->getTableRows() as $row) {
$table[] = $row;
}
return $table;
}
/**
* Get the header of table.
*
* @return array
* The header of table.
*/
private function getTableHeader() {
return [
[
'data' => $this->t('Instance Type'),
'field' => 'instance_type',
],
[
'data' => $this->t('On-demand<br>Hourly ($)'),
'field' => 'on_demand_hourly',
],
[
'data' => $this->t('On-demand<br>Daily ($)'),
'field' => 'on_demand_daily',
],
[
'data' => $this->t('On-demand<br>Monthly ($)'),
'field' => 'on_demand_monthly',
],
[
'data' => $this->t('On-demand<br>Yearly ($)'),
'field' => 'on_demand_yearly',
],
[
'data' => $this->t('RI<br>1 Year ($)'),
'field' => 'ri_one_year',
],
[
'data' => $this->t('RI<br>3 Year ($)'),
'field' => 'ri_three_year',
],
];
}
/**
* Get rows of table.
*
* @return array
* The render array of table's rows.
*/
private function getTableRows() {
$rows = [];
$header = $this->getTableHeader();
$rows_data = $this->getTableRowsData();
foreach ($rows_data as $row_data) {
$row = [];
foreach ($row_data as $col_name => $col_val) {
$this->buildCell($row, $col_name, $col_val);
}
$rows[] = $row;
}
return $rows;
}
/**
* Get rows data of table.
*
* @return array
* The rows data of table.
*/
private function getTableRowsData() {
$instance_types = aws_cloud_get_instance_types($this->cloudContext);
$rows_data = [];
foreach ($instance_types as $key => $value) {
$parts = explode(':', $value);
$name = $parts[0];
$hourly_rate = $parts[4];
$rows_data[] = [
'instance_type' => $name,
'on_demand_hourly' => floatval($hourly_rate),
'on_demand_daily' => floatval($hourly_rate) * 24,
'on_demand_monthly' => floatval($hourly_rate) * 24 * self::ONE_YEAR / 12,
'on_demand_yearly' => floatval($hourly_rate) * 24 * self::ONE_YEAR,
'ri_one_year' => floatval($parts[5]),
'ri_three_year' => floatval($parts[6]),
];
}
// Get sort and order parameters.
$sort = $this->request->get('sort');
$order_field = $this->getHeaderFieldByData($this->request->get('order'));
if (empty($sort)) {
$sort = 'asc';
}
if (empty($order_field)) {
$order_field = 'instance_type';
}
// Sort rows data.
usort($rows_data, function ($a, $b) use ($sort, $order_field) {
if ($order_field == 'instance_type') {
$a_type = explode('.', $a[$order_field])[0];
$b_type = explode('.', $b[$order_field])[0];
if ($a_type < $b_type) {
$result = -1;
}
elseif ($a_type > $b_type) {
$result = 1;
}
else {
$result = $a['on_demand_hourly'] < $b['on_demand_hourly'] ? -1 : 1;
}
}
else {
$result = $a[$order_field] < $b[$order_field] ? -1 : 1;
}
if ($sort == 'desc') {
$result *= -1;
}
return $result;
});
return $rows_data;
}
/**
* Get field of header by data.
*
* @param string $data
* The data of header.
*
* @return string
* The field of header.
*/
private function getHeaderFieldByData($data) {
$field = NULL;
$header = $this->getTableHeader();
foreach ($header as $col) {
if (is_array($col) && isset($col['data']) && $col['data'] == $data) {
$field = $col['field'];
break;
}
}
return $field;
}
/**
* Build cell.
*
* @param array &$row
* The render array of row.
* @param string $cell_name
* The name of cell.
* @param string $cell_value
* The value of cell.
*/
private function buildCell(array &$row, $cell_name, $cell_value) {
if ($cell_name == 'on_demand_hourly') {
$precision = 4;
}
elseif ($cell_name == 'on_demand_daily' || $cell_name == 'on_demand_monthly') {
$precision = 2;
}
else {
$precision = 0;
}
if ($cell_name != 'instance_type') {
$cell_value = $this->convertToNumber($cell_value, $precision);
}
$row[$cell_name] = [
'#markup' => $cell_value,
];
}
/**
* Convert to the string formatted with grouped thousands.
*
* @param float $float
* The float variable.
* @param int $precision
* The optional number of decimal digits.
*
* @return string
* The formatted string.
*/
private function convertToNumber($float, $precision = 0) {
$float = round($float, $precision);
return number_format($float, $precision);
}
}
<?php
// Created by yas 2016/06/02.
namespace Drupal\aws_cloud\Form\Config;
use Drupal\Component\Utility\Html;
......@@ -101,7 +100,7 @@ class AwsCloudAdminSettings extends ConfigFormBase {
60 => $this->t('60 days'),
90 => $this->t('90 days'),
],
'#title' =>$this-> t('Notification criteria'),
'#title' => $this->t('Notification criteria'),
'#description' => $this->t('Notify instance owners after an instance has been running for this period of time'),
'#default_value' => $config->get('aws_cloud_notification_criteria'),
];
......@@ -123,7 +122,7 @@ class AwsCloudAdminSettings extends ConfigFormBase {
'#type' => 'textarea',
'#title' => $this->t('Email message'),
'#default_value' => $config->get('aws_cloud_notification_msg'),
'#description' => $this->t('Edit the email message. Available variables are: [aws_cloud_instance:name], [aws_cloud_instance:id], [aws_cloud_instance:launch_time], [aws_cloud_instance:instance_state], [aws_cloud_instance:availability_zone], [aws_cloud_instance:private_ip], [aws_cloud_instance:public_up], [aws_cloud_instance:elastic_ip], [aws_cloud_instance:instance_link], [aws_cloud_instance:instance_link_edit]')
'#description' => $this->t('Edit the email message. Available variables are: [aws_cloud_instance:name], [aws_cloud_instance:id], [aws_cloud_instance:launch_time], [aws_cloud_instance:instance_state], [aws_cloud_instance:availability_zone], [aws_cloud_instance:private_ip], [aws_cloud_instance:public_up], [aws_cloud_instance:elastic_ip], [aws_cloud_instance:instance_link], [aws_cloud_instance:instance_link_edit]'),
];
$form['schedule'] = [
......@@ -169,6 +168,19 @@ class AwsCloudAdminSettings extends ConfigFormBase {
'#default_value' => $config->get('aws_cloud_scheduler_periods'),
];
$form['google'] = [
'#type' => 'details',
'#title' => $this->t('Google'),
'#open' => TRUE,
];
$form['google']['google_credential_file_path'] = [
'#type' => 'textfield',
'#title' => $this->t('Credential file path'),
'#description' => $this->t("The path of a service account's credential file."),
'#default_value' => $config->get('google_credential_file_path'),
];
return parent::buildForm($form, $form_state);
}
......
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