This is an automated email from the ASF dual-hosted git repository.
mykolabodnar pushed a commit to branch DLAB-1565
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1565 by this push:
new fee0e82 [DLAB-1565]: Convey billing for remote endpoints - sed
parameters in billing.yml fixed
fee0e82 is described below
commit fee0e82cb3059e540971e216b2a954825f19e726
Author: Mykola_Bodnar1 <[email protected]>
AuthorDate: Thu Mar 5 11:08:20 2020 +0200
[DLAB-1565]: Convey billing for remote endpoints - sed parameters in
billing.yml fixed
---
.../terraform/bin/deploy/billiing_gcp.yml | 20 ++++++
.../terraform/bin/deploy/billing.yml | 77 ----------------------
.../terraform/bin/deploy/endpoint_fab.py | 66 +++++++------------
3 files changed, 45 insertions(+), 118 deletions(-)
diff --git a/infrastructure-provisioning/terraform/bin/deploy/billiing_gcp.yml
b/infrastructure-provisioning/terraform/bin/deploy/billiing_gcp.yml
new file mode 100644
index 0000000..522c7ad
--- /dev/null
+++ b/infrastructure-provisioning/terraform/bin/deploy/billiing_gcp.yml
@@ -0,0 +1,20 @@
+server:
+ port: 8088
+spring:
+ data:
+ mongodb:
+ username: admin
+ password: <MONGO_PASSWORD>
+ database: dlabdb
+ port: 27017
+ host: localhost
+dlab:
+ sbn: <CONF_SERVICE_BASE_NAME>
+ bigQueryDataset: <BILLING_DATASET_NAME>
+ cron: 0 0 */1 * * *
+
+logging:
+ file: /var/opt/dlab/log/ssn/billing.log
+ level:
+ com:
+ epam: trace
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/bin/deploy/billing.yml
b/infrastructure-provisioning/terraform/bin/deploy/billing.yml
deleted file mode 100644
index da47bd1..0000000
--- a/infrastructure-provisioning/terraform/bin/deploy/billing.yml
+++ /dev/null
@@ -1,77 +0,0 @@
-# *****************************************************************************
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-#
******************************************************************************
-
-# Authentication info
-
-# Explicit azure authentication parameters
-clientId: <CLIENT_ID>
-clientSecret: <CLIENT_SECRET>
-tenantId: <TENANT_ID>
-subscriptionId: <SUBSCRIPTION_ID>
-
-# Contains authentication info (clientId, clientSecret, tenantId,
subscriptionId) received after Azure CLI authentication
-# Overrides explicit azure authentication parameters above
-authenticationFile: <AUTHENTICATION_FILE>
-
-# Billing configuration for RateCard API. For more details please see
https://msdn.microsoft.com/en-us/library/mt219004.aspx
-offerNumber: <OFFER_NUMBER>
-currency: <CURRENCY>
-locale: <LOCALE>
-regionInfo: <REGION_INFO>
-
-# Azure provides with aggregated data by date. Scheduler tries to retrieve
data every <period> with <initialDelay> from
-# application startup in minutes.
-# Scheduler retrieves data only for the past period of time from midnight of
start day to midnight of end date.
-# Scheduler does not retrieve data for the current date
-initialDelay: 10
-period: 60
-
-billingEnabled: false
-
-aggregationOutputMongoDataSource:
- host: localhost
- port: 27017
- username: admin
- password: <MONGODB_PASSWORD>
- database: dlabdb
-
-ssnStorageAccountTagName: <AZURE_SSN_STORAGE_ACCOUNT_TAG>
-sharedStorageAccountTagName: <AZURE_SHARED_STORAGE_ACCOUNT_TAG>
-datalakeTagName: <AZURE_DATALAKE_TAG>
-
-# Logging configuration.
-logging:
- # Default logging level
- level: INFO
- # Logging levels for appenders.
- loggers:
- com.epam: DEBUG
- org.apache.http: WARN
- org.mongodb.driver: WARN
- org.hibernate: WARN
- #Logging appenders
- appenders:
- #- type: console
- - type: file
- currentLogFilename: /var/opt/dlab/log/ssn/billing.log
- archive: true
- archivedLogFilenamePattern:
/var/opt/dlab/log/ssn/billing-%d{yyyy-MM-dd}.log.gz
- archivedFileCount: 10
\ No newline at end of file
diff --git a/infrastructure-provisioning/terraform/bin/deploy/endpoint_fab.py
b/infrastructure-provisioning/terraform/bin/deploy/endpoint_fab.py
index d4cce74..85fe9d7 100644
--- a/infrastructure-provisioning/terraform/bin/deploy/endpoint_fab.py
+++ b/infrastructure-provisioning/terraform/bin/deploy/endpoint_fab.py
@@ -650,52 +650,36 @@ def configure_guacamole():
def configure_billing_endpoint():
try:
if args.billing_enable:
- conn.put('./billing.yml', '{}/conf/billing.yml'
- .format(args.dlab_path))
+ conn.put('./billing_{0}.yml', '{1}/conf/billing.yml'
+ .format(args.cloud_provider, args.dlab_path))
billing_yml_path = "{}/conf/billing.yml".format(args.dlab_path)
- with open(billing_yml_path, 'r') as config_yml_r:
- config_orig = config_yml_r.read()
-
- config_orig = config_orig.replace('billingEnabled: false',
'billingEnabled: true')
if args.cloud_provider == 'aws':
if args.aws_job_enabled == 'true':
args.tag_resource_id = 'resourceTags' + ':' +
args.tag_resource_id
- config_orig = config_orig.replace('<BILLING_BUCKET_NAME>',
args.billing_bucket)
- config_orig = config_orig.replace('<AWS_JOB_ENABLED>',
args.aws_job_enabled)
- config_orig = config_orig.replace('<REPORT_PATH>',
args.report_path)
- config_orig = config_orig.replace('<ACCOUNT_ID>',
args.billing_aws_account_id)
- config_orig = config_orig.replace('<ACCESS_KEY_ID>',
args.access_key_id)
- config_orig = config_orig.replace('<SECRET_ACCESS_KEY>',
args.secret_access_key)
- config_orig = config_orig.replace('<CONF_BILLING_TAG>',
args.billing_tag)
- config_orig = config_orig.replace('<CONF_SERVICE_BASE_NAME>',
args.service_base_name)
- config_orig = config_orig.replace('<MONGODB_PASSWORD>',
args.mongo_password)
- config_orig = config_orig.replace('<DLAB_ID>',
args.billing_dlab_id)
- config_orig = config_orig.replace('<USAGE_DATE>',
args.billing_usage_date)
- config_orig = config_orig.replace('<PRODUCT>',
args.billing_product)
- config_orig = config_orig.replace('<USAGE_TYPE>',
args.billing_usage_type)
- config_orig = config_orig.replace('<USAGE>',
args.billing_usage)
- config_orig = config_orig.replace('<COST>', args.billing_cost)
- config_orig = config_orig.replace('<RESOURCE_ID>',
args.billing_resource_id)
- config_orig = config_orig.replace('<TAGS>', args.billing_tags)
- elif args.cloud_provider == 'azure':
- config_orig = config_orig.replace('<CLIENT_ID>',
args.azure_client_id)
- config_orig = config_orig.replace('<CLIENT_SECRET>',
args.azure_client_secret)
- config_orig = config_orig.replace('<TENANT_ID>',
args.tenant_id)
- config_orig = config_orig.replace('<SUBSCRIPTION_ID>',
args.subscription_id)
- config_orig = config_orig.replace('<AUTHENTICATION_FILE>',
args.authentication_file)
- config_orig = config_orig.replace('<OFFER_NUMBER>',
args.offer_number)
- config_orig = config_orig.replace('<CURRENCY>', args.currency)
- config_orig = config_orig.replace('<LOCALE>', args.locale)
- config_orig = config_orig.replace('<REGION_INFO>',
args.region_info)
- config_orig = config_orig.replace('<MONGODB_PASSWORD>',
args.mongo_password)
+ billing_properties = [
+ {
+ 'key': "<BILLING_BUCKET_NAME>",
+ 'value': args.billing_bucket
+ }
+ ]
elif args.cloud_provider == 'gcp':
- config_orig = config_orig.replace('<CONF_SERVICE_BASE_NAME>',
args.service_base_name)
- config_orig = config_orig.replace('<MONGO_PASSWORD>',
args.mongo_password)
- config_orig = config_orig.replace('<BILLING_DATASET_NAME>',
args.billing_dataset_name)
- f = open(path, 'w')
- f.write(config_orig)
- f.close()
-
+ billing_properties = [
+ {
+ 'key': "<CONF_SERVICE_BASE_NAME>",
+ 'value': args.billing_bucket
+ },
+ {
+ 'key': "<MONGO_PASSWORD>",
+ 'value': args.billing_bucket
+ },
+ {
+ 'key': "<BILLING_DATASET_NAME>",
+ 'value': args.billing_bucket
+ }
+ ]
+ for param in billing_properties:
+ conn.sudo('sed -i "s|{0}|{1}|g" {2}'
+ .format(param['key'], param['value'],
billing_yml_path))
except Exception as err:
traceback.print_exc()
print('Failed to configure billing: ', str(err))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]