diff --git a/run_uwsgi.sh b/run_uwsgi.sh
index 4adebee2..d88b2781 100755
--- a/run_uwsgi.sh
+++ b/run_uwsgi.sh
@@ -1,4 +1,5 @@
#!/bin/bash
+
python manage.py makemigrations
python manage.py migrate auth
python manage.py makemigrations users
@@ -8,4 +9,13 @@ python manage.py makemigrations logs
python manage.py migrate
python manage.py collectstatic --noinput
service cron start
+
+if grep -Fxq "PLUGINS_ENABLED+=[\"globus\"]" /code/shub/settings/config.py
+then
+ # When configured, we can start the endpoint
+ echo "Starting Globus Connect Personal"
+ export USER="tunel-user"
+ /opt/globus/globusconnectpersonal -start &
+fi
+
uwsgi uwsgi.ini
diff --git a/scripts/globus/globus-install.sh b/scripts/globus/globus-install.sh
index f2c84494..3600a09a 100755
--- a/scripts/globus/globus-install.sh
+++ b/scripts/globus/globus-install.sh
@@ -19,4 +19,4 @@ git clone https://github.com/sirosen/globusconnectpersonal-py3-patched && \
# Create globus user
useradd -ms /bin/bash tunel-user
-echo "gtunel-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
+echo "tunel-user ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
diff --git a/shub/plugins/globus/actions.py b/shub/plugins/globus/actions.py
index cda39dc0..e02956b0 100644
--- a/shub/plugins/globus/actions.py
+++ b/shub/plugins/globus/actions.py
@@ -42,7 +42,7 @@ def get_endpoints(user, client=None):
if client is not None:
for scope in ['my-endpoints', 'shared-with-me']:
for ep in client.endpoint_search(filter_scope=scope):
- if ep.__dict__['_data']['name'] != settings.GLOBUS_ENDPOINT_ID:
+ if ep.__dict__['_data']['name'] != settings.PLUGIN_GLOBUS_ENDPOINT:
endpoints.append(ep.__dict__['_data'])
return endpoints
@@ -56,7 +56,7 @@ def search_endpoints(term, user, client=None):
if client is not None:
for ep in client.endpoint_search(term, filter_scope="all"):
- if ep.__dict__['_data']['name'] != settings.GLOBUS_ENDPOINT_ID:
+ if ep.__dict__['_data']['name'] != settings.PLUGIN_GLOBUS_ENDPOINT:
endpoints.append(ep.__dict__['_data'])
return endpoints
@@ -66,13 +66,14 @@ def search_endpoints(term, user, client=None):
def do_transfer(user, endpoint, container):
# Use relative paths, we are in container and endpoint is mapped
- source = container.get_image_path().replace(settings.MEDIA_ROOT,'').strip('/')
+ source = container.get_image_path()
client = get_transfer_client(user)
- source_endpoint = settings.GLOBUS_ENDPOINT_ID
+ source_endpoint = settings.PLUGIN_GLOBUS_ENDPOINT
tdata = globus_sdk.TransferData(client, source_endpoint,
endpoint,
label="Singularity Registry Transfer",
sync_level="checksum")
- tdata.add_item(source, source)
+ tdata.add_item(source.replace(settings.MEDIA_ROOT,'/code/images'),
+ source.replace(settings.MEDIA_ROOT,'').strip('/'))
transfer_result = client.submit_transfer(tdata)
return transfer_result
diff --git a/shub/plugins/globus/templates/globus/transfer.html b/shub/plugins/globus/templates/globus/transfer.html
index 0472698c..7caed5b9 100644
--- a/shub/plugins/globus/templates/globus/transfer.html
+++ b/shub/plugins/globus/templates/globus/transfer.html
@@ -25,8 +25,9 @@
{{ request.user.username }}:
-
+ {% if endpoints %}
+
Search Endpoints
{% if container %}
@@ -40,9 +41,11 @@
{{ request.user.username }}:
-
+ {% endif %}
+
+
@@ -53,11 +56,10 @@
{{ request.user.username }}:
-
+
- {% if container %}
{% if endpoints|length == 0 %}
@@ -67,36 +69,68 @@
{{ request.user.username }}:
{% endif %}
- {% for ep in endpoints %}
-
-
-
- From Singularity Hub
-
-
-
-
-
To {{ ep.display_name }}
-
-
-
- {% endfor %}
- {% else %}
-
-
-
-
- You are connected to Globus! Browse container collections and look for the icon to select an endpoint to transfer the image..
-
-
-
- {% endif %}
+
+{% if endpoints %}
+
+
+
+
+
+
+ endpoint ID |
+ |
+ name |
+ email |
+ organization |
+ |
+
+
+
+
+ endpoint ID |
+ |
+ name |
+ email |
+ organization |
+ |
+
+
+
+ {% for endpoint in endpoints %}
+
+
+ {% if endpoint.activated %}{{ endpoint.id }}{% else %}
+ ACTIVATE {{ endpoint.id }}{% endif %}
+ |
+
+ {% if endpoint.activated %}activated{% endif %}
+ {% if endpoint.is_globus_connect %}globus connect{% endif %}
+ {% if endpoint.public %}public{% endif %}
+ |
+ {{ endpoint.display_name }} |
+ {% if endpoint.contact_email %}{{ endpoint.contact_email }}{% endif %} |
+ {% if endpoint.organization %}{{ endpoint.organization }}{% endif %} |
+ {% if endpoint.activated %}{% if container.id %}
+ {% endif %}{% endif %} |
+
+ {% endfor %}
+
+
+
+{% else %}
+
+
+
+
+ You are connected to Globus! Browse container collections and look for the icon to select an endpoint to transfer the image..
+
+
+
+{% endif %}
+
@@ -179,6 +213,45 @@
}
});
}
+
+ {% if needs_update %}
+ {% else %}
+
+ $('.makeactive').click(function(){
+ uid = $(this).attr('data-uid');
+ message='Once you have authenticated for the endpoint in the Globus portal,';
+ {% if container %}
+ message+='view the endpoint details.';
+ {% else %}
+ message+='view the endpoint details.';
+ {% endif %}
+ $('#message-activate').append(message);
+ $('#message-activate').show();
+ });
+
+ function tableSearch() {
+
+ // https://www.w3schools.com/howto/howto_js_filter_table.asp
+
+ var input, filter, table, tr, td, i;
+ input = document.getElementById("searchInput");
+ filter = input.value.toUpperCase();
+ table = document.getElementById("label_table");
+ tr = table.getElementsByClassName("tableRow");
+
+ for (i = 0; i < tr.length; i++) {
+ $.each(tr[i].children, function(e, child){
+ text = $(child).attr('data-search');
+ if (text.toUpperCase().indexOf(filter) > -1) {
+ tr[i].style.display = "";
+ } else {
+ tr[i].style.display = "none";
+ }
+ })
+ }
+ }
+ {% endif %}
+
{% endif %}
})
diff --git a/shub/plugins/globus/urls.py b/shub/plugins/globus/urls.py
index 8375be5a..77b62eab 100644
--- a/shub/plugins/globus/urls.py
+++ b/shub/plugins/globus/urls.py
@@ -5,7 +5,8 @@
url(r'^login/$', views.globus_login, name="globus_login"),
url(r'^logout/$', views.globus_logout, name="globus_logout"),
url(r'^transfer$', views.globus_transfer, name="globus_transfer"),
+ url(r'^endpoint/(?P.+?)/(?P\d+)?$', views.globus_endpoint, name='globus_endpoint'),
+ url(r'^endpoint/(?P\d+)/?$', views.globus_endpoint, name='globus_endpoint'),
url(r'^transfer/(?P\d+)/?$', views.globus_transfer, name='globus_transfer'),
url(r'^transfer/(?P.+?)/container/(?P\d+)/?$', views.submit_transfer,name='submit_transfer'),
]
-
diff --git a/shub/plugins/globus/views.py b/shub/plugins/globus/views.py
index 1e810faa..db35a650 100644
--- a/shub/plugins/globus/views.py
+++ b/shub/plugins/globus/views.py
@@ -36,9 +36,14 @@
from .decorators import has_globus_association
from shub.plugins.globus.utils import (
get_client,
+ get_transfer_client,
associate_user
)
+from globus_sdk.exc import TransferAPIError
+
+
+
@login_required
@has_globus_association
def globus_logout(request):
@@ -126,6 +131,31 @@ def globus_transfer(request, cid=None, endpoints=None):
return render(request, 'globus/transfer.html', context)
+@login_required
+@has_globus_association
+def globus_endpoint(request, endpoint_id=None, cid=None):
+ ''' Show information for a single endpoint only.
+ '''
+ container = None
+ if cid is not None:
+ container = get_container(cid)
+
+ context = {'user': request.user,
+ 'container': container,
+ 'endpoint_search_term': "Search for..." }
+
+ # Get the endpoint
+ try:
+ client = get_transfer_client(request.user)
+ endpoints = [client.get_endpoint(endpoint_id).data]
+ except TransferAPIError:
+ endpoints = get_endpoints(request.user)
+
+ context['endpoints'] = endpoints
+
+ return render(request, 'globus/transfer.html', context)
+
+
@login_required
@has_globus_association
def submit_transfer(request, endpoint, cid):
@@ -141,7 +171,11 @@ def submit_transfer(request, endpoint, cid):
result = do_transfer(user=request.user,
endpoint=endpoint,
container=container)
- message = result['message']
- status = {'message': message }
+
+ link = "https://globus.org/app/activity/%s" %result['task_id']
+ m = result['message']
+ m = "%s: view task" %(m, link)
+
+ status = {'message': m }
return JsonResponse(status)
diff --git a/shub/settings/config.py b/shub/settings/config.py
index 65ec8dac..e047abc8 100644
--- a/shub/settings/config.py
+++ b/shub/settings/config.py
@@ -108,7 +108,5 @@
# 'ldap_auth'
]
PLUGINS_ENABLED+=["globus"]
-ROBOTNAME='crusty-malarkey-2922'
-PLUGIN_GLOBUS_ENDPOINT="502635e0-4418-11e8-8e06-0a6d4e044368"
ROBOTNAME='sticky-blackbean-9783'
PLUGIN_GLOBUS_ENDPOINT="ba5b80c2-4798-11e8-8ee0-0a6d4e044368"