Skip to content

Commit

Permalink
Merge pull request #81 from opensds/development
Browse files Browse the repository at this point in the history
This is the third release candidate (RC) build for the Capri release.
  • Loading branch information
leonwanghui authored Jun 18, 2019
2 parents 6fbf08b + 4b6cce2 commit 43d8022
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 26 deletions.
22 changes: 0 additions & 22 deletions contrib/st2/opensds/actions/workflows/migration_bucket.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions orchestration.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 23 additions & 4 deletions orchestration/api/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions orchestration/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43d8022

Please sign in to comment.