Skip to content

Commit

Permalink
Merge pull request EarthSystemCoG#6 from EarthSystemCoG/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
sashakames committed Sep 9, 2019
2 parents a84b3c8 + 6ad9405 commit 001ff76
Show file tree
Hide file tree
Showing 169 changed files with 2,077 additions and 95 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
*.pyc
*.eggs

# CKEditor
cog/static/cog/ckeditor

# static files
static/


# site media
site_media/

Expand Down
49 changes: 23 additions & 26 deletions cog/plugins/globus/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,42 +27,39 @@ def generateGlobusDownloadScript(download_map):
return script


def activateEndpoint(transfer_client, endpoint, openid=None, password=None):

if not openid or not password:
def activateEndpoint(api_client, endpoint, myproxy_server=None, username=None, password=None, cert=None, key=None):
if (not myproxy_server or not password) and (not myproxy_server or not cert):

# Try to autoactivate the endpoint
code, reason, result = transfer_client.endpoint_autoactivate(endpoint, if_expires_in=2880)
print "Endpoint Activation: %s. %s: %s" % (endpoint, result["code"], result["message"])
if result["code"] == "AutoActivationFailed":
return (False, "")
return (True, "")

openid_parsed = urlparse.urlparse(openid)
hostname = openid_parsed.hostname
username = os.path.basename(openid_parsed.path)
code, reason, reqs = transfer_client.endpoint_get_activation_requirements(endpoint)

code, reason, reqs = api_client.endpoint_activation_requirements(endpoint)

# Activate the endpoint using an X.509 user credential stored by esgf-idp in /tmp/x509up_<idp_hostname>_<username>
#cred_file = "/tmp/x509up_%s_%s" % (hostname, username)
#public_key = reqs.get_requirement_value("delegate_proxy", "public_key")
#try:
# proxy = x509_proxy.create_proxy_from_file(cred_file, public_key, lifetime_hours=72)
#except Exception as e:
# print "Could not activate the endpoint: %s. Error: %s" % (endpoint, str(e))
# return False
#reqs.set_requirement_value("delegate_proxy", "proxy_chain", proxy)

# Activate the endpoint using MyProxy server method
for i, d in enumerate(req["DATA"]):
if d["type"] == "myproxy":
if d["name"] == "hostname":
req["DATA"][i]["value"] = hostname
elif d["name"] == "username":
req["DATA"][i]["value"] = username
elif d["name"] == "passphrase":
req["DATA"][i]["value"] = password
elif d["name"] == "lifetime_in_hours":
req["DATA"][i]["value"] = "168"
if cert and key:
cred_file = "/tmp/x509up_%s_%s" % (myproxy_server, username)
with open(cred_file, 'w') as cred:
cred.write(cert)
cred.write(key)
public_key = reqs.get_requirement_value("delegate_proxy", "public_key")
try:
proxy = x509_proxy.create_proxy_from_file(cred_file, public_key, lifetime_hours=72)
except Exception as e:
print "Could not activate the endpoint: %s. Error: %s" % (endpoint, str(e))
return False
reqs.set_requirement_value("delegate_proxy", "proxy_chain", proxy)
else:
# Activate the endpoint using MyProxy server method
reqs.set_requirement_value("myproxy", "hostname", myproxy_server)
reqs.set_requirement_value("myproxy", "username", username)
reqs.set_requirement_value("myproxy", "passphrase", password)
reqs.set_requirement_value("myproxy", "lifetime_in_hours", "168")

try:
code, reason, result = transfer_client.endpoint_activate(endpoint, reqs)
Expand Down
2 changes: 1 addition & 1 deletion cog/templates/cog/common/cog_footer_bar_only.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<td style="width:30%;">
<table >
<tr>
<td style="text-align:center;">CoG version 3.13.0</td>
<td style="text-align:center;">CoG version {{ 'COG_VERSION'|settings_value }}</td>
</tr>
{% if 'ESGF_VERSION'|settings_value %}
<tr>
Expand Down
5 changes: 4 additions & 1 deletion cog/templates/cog/common/cog_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@
{% endfor %}
{% endfor %}
{% else %}
<li><a href="http://{{site.domain }}">{{ site.name }} Home</a></li>
<li><a href="https://{{site.domain }}">{{ site.name }} Home</a></li>
{% endif %}
{% if 'HAS_DATANODE_STATUS'|settings_value %}
<li><a href="https://{{site.domain}}/status/">Data Nodes Status</a>a</li>
</ul>
{% endif %}
</div> <!--// end div id=top_nav_left //-->
</div> <!--//end div.span-26 //-->

Expand Down
28 changes: 0 additions & 28 deletions cog/templates/cog/datacart/datacart.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
<style scoped type="text/css">
#datacart-table td,th { padding-bottom: 0; padding-top:2px; margin:0; }
</style>

<!-- function triggered on other datacart selection -->
<script type="text/javascript">
function handleOtherDataCartSelect(elm) {
window.location = elm.value;
}
</script>

{% endblock %}

Expand All @@ -40,34 +33,13 @@ <h1>My Data Cart</h1>
<p>
<strong>About Data Carts:</strong> You have a Data Cart on every ESGF node you have logged into. This is your
Data Cart on the <a href="http://{{ site.domain }}">{{ site.domain }} </a> node.
{% if datacars.items|length > 0 %}
Use the pull down menu below to navigate between Data Carts.
{% endif %}
The items in this cart will persist until removed.
</p>
<div style="text-align:center; font-weight:bold">

<!-- local data cart -->
Number of Items (<span id="datacart_size2">{{ datacart.items.all|length }})</span>

<!-- remote data carts -->
{% if datacarts.items|length > 0 %}
&nbsp; | &nbsp;
<label for="dataCartSelect">My Other Data Carts</label>
<select name="dataCartSelect" id="dataCartSelect" onchange="javascript:handleOtherDataCartSelect(this)">
<option id="other_datacart">My Other Data Carts</option>
{% for openid, dc in datacarts.items %}
{% for site, value in dc.items %}
<option id="{{ site_name }}_datacart"
value="http://{{ site.domain }}/datacart/byopenid?openid={{openid}}">
{{ site.name }}: {{ value }}
</option>
{% endfor %}
{% endfor %}
</select>

{% endif %}

<!-- link back to search -->
{% if request.session.last_search_url %}
&nbsp; | &nbsp;
Expand Down
3 changes: 3 additions & 0 deletions cog/templates/cog/globus/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<div style="text-align: center; padding:5px;">
<table style="width: 400px; margin-left:auto; margin-right:auto;">
<tr><td style="text-align: right; font-weight: bold">OpenID:</td><td>{{openid}}</td></tr>
{% if username %}
<tr style="background-color: transparent"><td style="text-align: right; font-weight: bold; background-color: transparent">Username:</td><td style="background-color: transparent"><input style="width: 200px" type="text" name="username"/></td></tr>
{% endif %}
<tr style="background-color: transparent"><td style="text-align: right; font-weight: bold; background-color: transparent">Password:</td><td style="background-color: transparent"><input style="width: 200px" type="password" name="password"/></td></tr>
</table>
</div>
Expand Down
18 changes: 15 additions & 3 deletions cog/templates/cog/search/_record_display.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
<strong>{{record.fields.title.0}}</strong>
<div id="message_{{record.id}}" style="display:none; color: #FF0000;">Message</div>
{% if record.fields.description.0 %} <br/>Description: {{ record.fields.description.0 |urlizetrunc:30|linebreaksbr }}{% endif %}
{% if record.fields.data_node.0 %} <br/>Data Node: {{ record.fields.data_node.0 }}{% endif %}
{% if record.fields.data_node.0 %} <br/>Data Node: {{ record.fields.data_node.0 }}
{% if not record.fields.data_node.0|getDataNodeStatus %}
<span style="color: #FF0000;">is reported as unavailable. Any existing replica data sets can be seen by selecting 'Show All Replicas' .</span>
{% endif %}
{% endif %}
{% if record.fields.version.0 %} <br/>Version: {{ record.fields.version.0 }}{% endif %}
{% if record.fields.number_of_files.0 %} <br/>Total Number of Files (for all variables): {{ record.fields.number_of_files.0 }}{% endif %}
</div>
Expand Down Expand Up @@ -116,14 +120,22 @@
[ <a href="{{url.0}}" target="_blank"><strong>PID</strong></a> ]
</div>


{% elif url.2 == 'summary' %}
&nbsp;
<div style="display: inline-block;">
[ <a href="{{url.0}}"><strong>Tech Note</strong></a> ]
</div>


<!-- all other services -->
{% else %}
{% else %}
&nbsp;
<div style="display: inline-block;">
[ <a href="{{url.0}}"><strong>{{ url.2 }}</strong></a> ]
</div>

{% endif %}
{% endif %}

{% endfor %}

Expand Down
26 changes: 22 additions & 4 deletions cog/templates/cog/search/obs4mips.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h1>Obs4MIPs Data Table</h1>
<th><strong>Dataset Name</strong></th>
<th><strong>Variables</strong></th>
<th><strong>Tech Note</strong></th>
<th><strong>Supplementary Data</strong></th>
<th><strong>Maturity Indicators</strong></th>
</tr>

Expand All @@ -31,13 +32,30 @@ <h1>Obs4MIPs Data Table</h1>
{{ variable }} <br/>
{% endfor %}
</td>
<td style="width:60px;">

<td style="width:60px;">
{% for url in record|recordUrls %}
{% if url.2 == 'Tech Note' %}
<a href="{{url.0}}"><strong>{{ url.2 }}</strong></a>

{% if url.2 == 'summary' %}


<a href="{{url.0}}"><strong>Tech Note</strong></a>
{% elif url.2 == 'Tech Note' %}
<a href="{{url.0}}"><strong>Tech Note</strong></a>


{% endif %}


{% endfor %}
</td>
</td>
<td style="width:60px;">
{% for url in record|recordUrls %}
{% if url.2 == 'Supplementary Data' %}
<a href="{{url.0}}"><strong>{{url.2}}</strong></a>
{% endif %}
{% endfor %}
</td>
<td style="width:120px;">
<!-- Quality Control Flags -->
{% for qcflag, qcdict in record|qcflags %}
Expand Down
29 changes: 29 additions & 0 deletions cog/templates/cog/status/node_status.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "cog/common/layout_center.html" %}

{% block main %}

{% if no_status %}

<h2>This feature is not enabled on this node.</h2>

{% else %}
<table>
<tr><th width="200">&nbsp;</th><th width="300"><b>Data Node</b></th><th><b>Status</b></th>
</tr>
{% for nstatus in status_arr %}

<tr> <td>&nbsp;</td>
<td>{{ nstatus.0 }}</td>
<td>{% if nstatus.1 == 1%}
<font color="#00FF00"><b>UP</b></font>
{% else %}
<font color="#FF0000"><b>DOWN</b></font>
{% endif %}
</td>

</tr>
{% endfor %}
</table>
{% endif %}

{% endblock %}
26 changes: 25 additions & 1 deletion cog/templatetags/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ def recordUrls(record):

return sorted(urls, key = lambda url: url_order(url[1]))

@register.filter
def supplenoteUrls(record):

ret = []
return ret

@register.filter
def qcflags(record):
'''
Expand Down Expand Up @@ -178,11 +184,29 @@ def qcflag_url(qcflag_name):
qcflag_urls = getattr(settings,'QCFLAGS_URLS', {})
return qcflag_urls.get(qcflag_name, '') # return empty link by default

@register.filter
def getDataNodeStatus(data_node):

if not getattr(settings, 'HAS_DATANODE_STATUS', None):
return True

try:

dnstatusfn = getattr(settings, 'DATANODE_STATUS_FILE', None)
dnstatus = json.load(open(dnstatusfn))
except Exception as e:
return True

if data_node in dnstatus:
return (dnstatus[data_node]['status'] == 1)
return True

@register.filter
def sortResults(results, fieldName):

return sorted(results, key = lambda result: result.fields.get(fieldName,""))


@register.filter
def showSearchConfigMessage(message, project):

Expand All @@ -200,4 +224,4 @@ def showSearchConfigMessage(message, project):

def _getProjectSearchConfigFilePath(project):

return "$MEDIA_ROOT/config/%s/search.cfg" % project.short_name.lower()
return "$MEDIA_ROOT/config/%s/search.cfg" % project.short_name.lower()
3 changes: 2 additions & 1 deletion cog/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
url(r'^globus/oauth/$', cog.views.views_globus.oauth, name='globus_oauth'),
url(r'^globus/token/$', cog.views.views_globus.token, name='globus_token'),
url(r'^globus/submit/$', cog.views.views_globus.submit, name='globus_submit'),
url(r'^globus/script/$', cog.views.views_globus.script, name='globus_script'),
url(r'^globus/script/$', cog.views.views_globus.script, name='globus_script'),
url(r'^status/$', cog.views.node_status, name='node_status'),

]
3 changes: 2 additions & 1 deletion cog/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
from cog.views.views_share import *
from cog.views.views_access_control import *
from cog.views.views_globus import *
from cog.views.utils import *
from cog.views.utils import *
from views_status import *
15 changes: 2 additions & 13 deletions cog/views/views_datacart.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,10 @@ def datacart_display(request, site_id, user_id):
datacart = DataCart.objects.get(user=user)
except DataCart.DoesNotExist:
datacart = None

# inspect remote data carts
dcs = {}
# combine from possible multiple user openids
for openid in user.profile.openids():
_dcs = getDataCartsForUser(openid)
if len(_dcs) > 0:
dcs[openid] = {}
for site, size in _dcs.items():
print site, size
dcs[openid][site] = size


return render(request,
'cog/datacart/datacart.html',
{'datacart': datacart, 'datacarts': dcs})
{'datacart': datacart})


# view to display a user datacart by openid
Expand Down
Loading

0 comments on commit 001ff76

Please sign in to comment.