diff --git a/contrib/st2/opensds/actions/workflows/migration_bucket.yaml b/contrib/st2/opensds/actions/workflows/migration_bucket.yaml index 7e1e7ba..67a1bf4 100644 --- a/contrib/st2/opensds/actions/workflows/migration_bucket.yaml +++ b/contrib/st2/opensds/actions/workflows/migration_bucket.yaml @@ -24,28 +24,6 @@ workflows: on-error: - fail tasks: - get_bucket: - action: opensds.get-bucket - input: - url: "http://<% $.ip_addr %>:<% $.port %>/v1/s3/" - bucket_name: "<% $.destBucketName %>" - auth_token: '<% $.auth_token %>' - publish: - print_status: <% task(get_bucket).result.stdout %> - on-success: - - create_bucket_migration - on-error: - - create_bucket - create_bucket: - action: opensds.create-bucket - input: - url: "http://<% $.ip_addr %>:<% $.port %>/v1/s3/<% $.destBucketName %>" - backend_name: "<% $.destBackend %>" - auth_token: '<% $.auth_token %>' - publish: - print_status: <% task(create_bucket).result.stdout %> - on-success: - - create_bucket_migration create_bucket_migration: action: opensds.create-bucket-migration input: diff --git a/orchestration.conf b/orchestration.conf index 1f17cdb..887c7d6 100644 --- a/orchestration.conf +++ b/orchestration.conf @@ -9,3 +9,11 @@ username = st2admin encrypted_password = false password = st2password phrase = '' + +[hotpot] +host = 127.0.0.1 +port = 50040 + +[gelato] +host = 127.0.0.1 +port = 8089 diff --git a/orchestration/api/instances.py b/orchestration/api/instances.py index 0d352f6..66437ba 100644 --- a/orchestration/api/instances.py +++ b/orchestration/api/instances.py @@ -20,10 +20,11 @@ from orchestration.db.api \ import create_workflow, create_service, \ get_sd_wfd_association, delete_service, get_wf_sd, \ - list_services, get_service, get_service_definition,\ + list_services, get_service, get_service_definition, \ get_execid_instance, update_service, update_workflow from orchestration.api.apiconstants import Apiconstants -from orchestration.utils.config import logger +from orchestration.utils.config import logger, config_file, \ + get_config instance = Blueprint("instance", __name__) @@ -44,13 +45,11 @@ def instance_ops(tenant_id=''): c = Connector().morph() content = request.get_json() AUTH_TOKEN = request.headers.get('X-Auth-Token') - # TODO: Need to check, When orchestration APIs authentication # is implemented if AUTH_TOKEN == '' or AUTH_TOKEN is None: err_msg = 'Bad Request. Authentication Token is missing' return jsonify(err_msg), Apiconstants.HTTP_ERR_BAD_REQUEST - if tenant_id == '': err_msg = 'bad URL. tenant id is empty' return jsonify(err_msg), Apiconstants.HTTP_ERR_NOTFOUND @@ -99,6 +98,26 @@ def instance_ops(tenant_id=''): # If description is not provided, the instance creation should proceed logger.info("no user_id provided. Exception [%s]", str(e)) + # action of the instance creator + try: + action = content['action'] + if action == '': + raise ValueError('Empty action provided') + if action == 'opensds.provision-volume': + content['parameters']['ip_addr'] = get_config(config_file, + 'hotpot', 'host') + content['parameters']['port'] = get_config(config_file, + 'hotpot', 'port') + else: + content['parameters']['ip_addr'] = get_config(config_file, + 'gelato', 'host') + content['parameters']['port'] = get_config(config_file, + 'gelato', 'port') + except Exception as e: + err_msg = 'required input action is missing' + logger.error("%s. Exception [%s]" % (err_msg, str(e))) + return jsonify(err_msg), Apiconstants.HTTP_ERR_BAD_REQUEST + content['parameters']['tenant_id'] = tenant_id content['parameters']['auth_token'] = AUTH_TOKEN try: diff --git a/orchestration/utils/config.py b/orchestration/utils/config.py index 535df7d..f841075 100644 --- a/orchestration/utils/config.py +++ b/orchestration/utils/config.py @@ -108,6 +108,26 @@ def get_workflow_config(file): return tech, server, user, passwd +def get_config(file, section, key): + global conf + value = '' + + try: + conf = configparser.ConfigParser() + dataset = conf.read(file) + if len(dataset) == 0: + logger.error( + "Failed to open orchestration config file: [%s]" % file) + raise IOError( + errno.ENOENT, os.strerror(errno.ENOENT), file) + value = conf.get(section, key) + except Exception as ex: + print(ex) + raise ex + + return value + + init_logging() # database configuration