Skip to main content

thStorage

thStorage is a simple app to connect to th clusters’ storage system

detail documentation is in the “docs” directory

Quick start

1.Install based pubgins [django restframework;requests] like this:

'pip install djangorestframework==3.11.0' 'pip install requests'

2.Add “rest_framework” and “thStorage” to your INSTALLED_APPS setting like this:

INSTALL_APPS = [ ... 'thStorage', 'rest_framework', ]

3.Include the thStorage URLconf in your project urls.py like this:

from thStorage import urls as thStorageUrls urlpatterns = [ path('admin/', admin.site.urls), path('login/', main.login), ] + thStorageUrls.urlpatterns

4.Run python manage.py migrate to create thStorage models

5.Run python manage.py collectstatic to migrate thStorage statics

6.Set django project settings like:

REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', ) } # restful api csrftoken!!!!!!

X_FRAME_OPTIONS = 'ALLOWALL' # (or your host name) STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR,"static").replace("\","/") TH_STORAGE_CONFIG = { 'TOKEN_UPDATE_IMTERVAL': 36000000, 'STORAGE_BACKEND_HOST':'thstorage backend server', 'STORAGE_BACKEND_APPID':'your thstorage appid', 'STORAGE_BACKEND_APPKEY':'your thstorage appkey', }

7.Login thstorage when your project’s user login like this:

from thStorage.models import THStorageUser ... systemUsername = user.username # systemUsername is tianhe system (in nscc-tj) username, and username is your project username cluster = "TH-HPC1" # cluster is tianhe system cluster name thStorageUser = THStorageUser(username,cluster,systemUsername) thStorageUser.Login()

8.Set LocalStorage in login redirect page like this:

from thStorage.thstorage import THStorageUser ... username = request.user.username systemUsername = request.session.get("systemUsername","") cluster = request.session.get("cluster","") thStorageUser = THStorageUser(username, cluster, systemUsername) t, u, c, s = thStorageUser.Login() thst = {"token": t, "username": s, "cluster": c,"platform":"default"} return render(request, 'index.html', {"thst":thst})

edit index.html

<script> var platform = "{{thst.platform}}"; var username = "{{thst.username}}"; var cluster = "{{thst.cluster}}"; var token = "{{thst.token}}"; localStorage.setItem("platform", platform); localStorage.setItem("username", username); localStorage.setItem("cluster", cluster); localStorage.setItem("token", token); </script>

9.Add url “/thStorage” to your storage page by iframe:

<body>
your html elements
<iframe id="myiframe" src="/thstorage" frameborder="0" width="100%" height="100%"></iframe>
</body> <script> var ifm= document.getElementById("myiframe"); //or set as your div element's height ifm.height=document.documentElement.clientHeight; </script>

10.Add thStorage’s NetDiskUser to admin:

from thStorage.models import NetDiskUser
  1. Register your models here. admin.site.register(NetDiskUser)

12.Test thStorage:: Run python manage.py createsuperuser add a admin user add a test user to thStorage’s NetDiskUser by admin (user must map to real th systemuser)

13.Start the development server and visit http://127.0.0.1:8000/yourLoginUrl then login and enjoy it!

Metadata

Release files for django-thStorage 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-thStorage 1.1.2
File Size Uploaded
django-thStorage-1.1.2.tar.gz 1.1 MB Details

Release files / django-thStorage-1.1.2.tar.gz

Download URL django-thStorage-1.1.2.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
0aa22751238f939bd0c379b7efff928b15388bc2885410b64472b6be534746ca
BLAKE2b-256 checksum
How to use checksums
469da7b05013c7b66d23fc51f58869773b803e6bac04b33b5f5a9899fa454c5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/2.7.16

Release history Release notifications | RSS feed

This release

1.1.2 This release

1 release file

1.1.0

1 release file

1.0.8

1 release file

1.0.6

1 release file

1.0.4

1 release file

1.0.2

1 release file

1.0.0

1 release file

0.1.4

1 release file

0.1.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page