Skip to content

Commit

Permalink
Merge pull request #614 from grycap/eu_node
Browse files Browse the repository at this point in the history
Eu node
  • Loading branch information
micafer authored Jan 17, 2025
2 parents 76b41d6 + 8073933 commit e7bdebd
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 6 deletions.
9 changes: 7 additions & 2 deletions app/cred.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ def validate_cred(self, userid, new_cred):
if isequal:
return 1, "Credentials already available."

if new_cred["type"] in no_host_types:
return 2, ("There is already a set of" + new_cred["type"] + " credentials. " +
if new_cred["type"] == "EUNode":
if new_cred["node"] == cred["node"]:
return 2, ("This site has already a Credential with the same EU Node site." +
" This may cause problems authenticating with the site." +
" Please disable/remove one of the credentials.")
elif new_cred["type"] in no_host_types:
return 2, ("There is already a set of " + new_cred["type"] + " credentials. " +
" This may cause problems authenticating with the Cloud provider." +
" Please disable/remove one of the credentials.")
elif new_cred["type"] not in ['EGI', 'OpenStack', 'fedcloud']: # these types has no problem
Expand Down
Binary file added app/static/images/EUNodeRow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/templates/advanced_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h5>Cloud Provider:</h5>
loadImages();
loadSiteImages();
loadSiteInfo();
} else if (cred_type == 'OpenStack' || cred_type == 'CH') {
} else if (cred_type == 'OpenStack' || cred_type == 'CH'|| cred_type == 'EUNode') {
$('#cloudImages').hide();
$('#fedcloudImages').hide();
$('#siteImages').show();
Expand Down
21 changes: 21 additions & 0 deletions app/templates/modal_creds.html
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,27 @@
<div class="col">
</div>
</div>
{% elif cred_type == "EUNode" %}
<div class="row form-group">
<div class="col">
<input placeholder="ID" name="username" class="col-sm-12 form-control my-1" type="text" id="username" value="{{ creds['username'] if creds else '' }}" required/>
</div>
<div class="col">
<input placeholder="Secret" name="password" class="col-sm-12 form-control my-1" type="password" id="password"/>
</div>
</div>
<div class="row form-group">
<div class="col">
<input placeholder="Project ID" name="tenant" class="col-sm-12 form-control my-1" type="text" id="tenant" value="{{ creds['tenant'] if creds else '' }}" required/>
</div>
<div class="col">
<select class="js-example-basic-single js-states form-control" id="node" name="node" required>
<option name="node" value="">-- Set EU Node Provider --</option>
<option name="node" value="eu-1" {{ "selected" if creds and creds['node'] == "eu-1" else '' }}>eu-1</option>
<option name="node" value="eu-2" {{ "selected" if creds and creds['node'] == "eu-2" else '' }}>eu-2</option>
</select>
</div>
</div>
{% else %}


Expand Down
4 changes: 4 additions & 0 deletions app/templates/service_creds.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ <h4 class="font-weight-bold text-primary">Cloud Credentials</h4>
<a class="dropdown-item" data-id="" data-type="InfrastructureManager" data-bs-toggle="modal" data-bs-target="#newModal" href="#"><img src="{{ url_for('static', filename='images/InfrastructureManagerRow.png') }}"/></a>
<a class="dropdown-item" data-id="" data-type="OSCAR" data-bs-toggle="modal" data-bs-target="#newModal" href="#"><img src="{{ url_for('static', filename='images/OSCARRow.png') }}"/></a>
<a class="dropdown-item" data-id="" data-type="CH" data-bs-toggle="modal" data-bs-target="#newModal" href="#"><img src="{{ url_for('static', filename='images/CHRow.png') }}"/></a>
<a class="dropdown-item" data-id="" data-type="EUNode" data-bs-toggle="modal" data-bs-target="#newModal" href="#"><img src="{{ url_for('static', filename='images/EUNodeRow.png') }}"/></a>
</div>
</div>
</div> <!-- / .row -->
Expand All @@ -56,6 +57,9 @@ <h4 class="font-weight-bold text-primary">Cloud Credentials</h4>
<td>{{cred['id']}}</td>
<td><img src="{{ url_for('static', filename='images/' + cred['type'] + 'Row.png') }}"/></td>
<td>
{% if 'node' in cred %}
<strong>Node: </strong> {{cred["node"]}}
{% endif %}
{% if 'host' in cred %}
<strong>Host: </strong> {{cred["host"]}}
{% endif %}
Expand Down
26 changes: 23 additions & 3 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ def getIMUserAuthData(access_token, cred, userid):
if g.settings.im_auth == "Bearer":
return "Bearer %s" % access_token
res = "type = InfrastructureManager; token = '%s'" % access_token
for cred in cred.get_creds(userid):

try:
creds = cred.get_creds(userid)
except Exception as ex:
creds = []
print("Error getting credentials: %s." % ex, file=sys.stderr)

for cred in creds:
if cred['enabled']:
if cred['type'] == "InfrastructureManager":
res += "\\nid = %s" % cred['id']
Expand All @@ -175,7 +182,11 @@ def getUserAuthData(access_token, cred, userid, cred_id=None, full=False, add_ex
res = "type = InfrastructureManager; token = %s" % access_token

fedcloud_sites = None
creds = cred.get_creds(userid)
try:
creds = cred.get_creds(userid)
except Exception as ex:
creds = []
print("Error getting credentials: %s." % ex, file=sys.stderr)

# Add the extra auth configured in the Dashboard
extra_auth_ids = []
Expand All @@ -199,7 +210,16 @@ def getUserAuthData(access_token, cred, userid, cred_id=None, full=False, add_ex
for cred in creds:
if cred['enabled'] and (cred_id is None or cred_id == cred['id'] or cred['id'] in extra_auth_ids):
res += "\\nid = %s" % cred['id']
if cred['type'] == "CH":
if cred['type'] == "EUNode":
# Add the EUNode provider as OpenStack
res += "; type = OpenStack; auth_version = 3.x_appcred;"
res += " host = https://api.%s.iaas.open-science-cloud.ec.europa.eu:5000" % cred['node']
res += "/identity;" if cred['node'] == "eu-2" else ";"
res += " username = %s; tenant = %s; password = '%s'" % (cred['username'],
cred['tenant'],
cred['password'])
res += "; tenant_id = %s;" % cred["tenant"]
elif cred['type'] == "CH":
# Add the Cloud&Heat provider as OpenStack
res += "; type = OpenStack; auth_version = 3.x_password;"
res += " host = https://identity-%s.cloudandheat.com:5000;" % cred['region']
Expand Down

0 comments on commit e7bdebd

Please sign in to comment.