Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cp minoredits #306

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions coldfront/config/plugins/fasrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
INSTALLED_APPS += [ 'coldfront.plugins.fasrc' ]

NEO4JP = ENV.str('NEO4JP')
ATT_VERIFY = ENV.str('ATT_VERIFY', default=True)

LOGGING['handlers']['fasrc'] = {
'class': 'logging.handlers.TimedRotatingFileHandler',
Expand Down
1 change: 1 addition & 0 deletions coldfront/config/plugins/xdmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

XDMOD_USER = ENV.str('XDMOD_USER', default='')
XDMOD_PASS = ENV.str('XDMOD_PASS', default='')
XDMOD_VERIFY = ENV.str('XDMOD_VERIFY', default=True)
XDMOD_API_URL = ENV.str('XDMOD_API_URL')


Expand Down
12 changes: 9 additions & 3 deletions coldfront/core/project/templates/project/project_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ <h4>Cluster</h4>
<tr>
<th scope="col">Resource Name</th>
<th scope="col">User Count</th>
<th scope="col">Used</th>
<th scope="col">Quarterly Usage (CPU Hours)</th>
<th scope="col" class="nosort">Actions</th>
</tr>
</thead>
Expand Down Expand Up @@ -224,7 +224,7 @@ <h3 class="d-inline"><i class="fas fa-list" aria-hidden="true"></i> Allocation H
<th scope="col">Resource Type</th>
<th scope="col">Path</th>
<th scope="col">User Count</th>
<th scope="col">Total Space (TB)</th>
<th scope="col">Total</th>
<th scope="col">Status</th>
<th scope="col">Created</th>
<th scope="col">Deactivated</th>
Expand All @@ -242,7 +242,13 @@ <h3 class="d-inline"><i class="fas fa-list" aria-hidden="true"></i> Allocation H
<td>{{ allocation.get_parent_resource.resource_type.name }}</td>
<td>{{ allocation.path }}</td>
<td>{{ allocation.allocationuser_set.count }}</td>
<td>{{ allocation.size|floatformat:1 }}</td>
<td>{{ allocation.size|floatformat:1 }}
{% if allocation.get_parent_resource.resource_type.name == 'Cluster' %}
CPU Hours
{% else %}
TB
{% endif %}
</td>

{% if allocation.status.name in 'New,In Progress,On Hold' %}
<td class="text-success">Requested</td>
Expand Down
8 changes: 4 additions & 4 deletions coldfront/core/project/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def test_func(self):
"""UserPassesTestMixin Tests"""
project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk'))
# if project_obj.has_perm(self.request.user, ProjectPermission.UPDATE):
if self.request.user.is_superuser or self.request.user == project.pi:
if self.request.user.is_superuser or self.request.user == project_obj.pi:
return True
return False

Expand Down Expand Up @@ -490,7 +490,7 @@ def test_func(self):
"""UserPassesTestMixin Tests"""
project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk'))
# if project_obj.has_perm(self.request.user, ProjectPermission.UPDATE):
if self.request.user.is_superuser or self.request.user == project.pi:
if self.request.user.is_superuser or self.request.user == project_obj.pi:
return True
return False

Expand Down Expand Up @@ -563,7 +563,7 @@ def test_func(self):
"""UserPassesTestMixin Tests"""
project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk'))
# if project_obj.has_perm(self.request.user, ProjectPermission.UPDATE):
if self.request.user.is_superuser or self.request.user == project.pi:
if self.request.user.is_superuser or self.request.user == project_obj.pi:
return True
err = 'You do not have permission to add users to the project.'
messages.error(self.request, err)
Expand Down Expand Up @@ -722,7 +722,7 @@ def test_func(self):
"""UserPassesTestMixin Tests"""
project_obj = get_object_or_404(Project, pk=self.kwargs.get('pk'))
# if project_obj.has_perm(self.request.user, ProjectPermission.UPDATE):
if self.request.user.is_superuser or self.request.user == project.pi:
if self.request.user.is_superuser or self.request.user == project_obj.pi:
return True
return False

Expand Down
7 changes: 4 additions & 3 deletions coldfront/plugins/fasrc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

logger = logging.getLogger(__name__)

ATT_VERIFY = import_from_settings('ATT_VERIFY')

class ATTAllocationQuery:

Expand Down Expand Up @@ -73,8 +74,8 @@ def produce_query_statement(self, vol_type, volumes=None):
'fs_path': 'LogicalVolume',
'path_replace': '/dev/data/',
'usedgb': 'UsedGB',
'sizebytes': 'SizeGB * 1073741824',
'usedbytes': 'UsedGB * 1073741824',
'sizebytes': 'SizeGB * 1000000000',
'usedbytes': 'UsedGB * 1000000000',
'server_replace': '.rc.fas.harvard.edu',
'unique': 'datetime(e.DotsLVSUpdateDate) as update_date, \
datetime(e.DotsLVDisplayUpdateDate) as display_date'
Expand Down Expand Up @@ -170,7 +171,7 @@ def __init__(self, volumes=None):
self.volumes = volumes

def post_query(self, query):
resp = requests.post(self.url, headers=self.headers, data=json.dumps(query))
resp = requests.post(self.url, headers=self.headers, data=json.dumps(query), verify=ATT_VERIFY)
return json.loads(resp.text)

def format_query_results(self, resp_json):
Expand Down
4 changes: 3 additions & 1 deletion coldfront/plugins/xdmod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

XDMOD_API_URL = import_from_settings('XDMOD_API_URL')

XDMOD_VERIFY = import_from_settings('XDMOD_VERIFY')

_ENDPOINT_CORE_HOURS = '/controllers/user_interface.php'

_DEFAULT_PARAMS = {
Expand Down Expand Up @@ -71,7 +73,7 @@ def __init__(self, start=QUARTER_START, end=QUARTER_END, resources=None):
self.group_by = {'total':'pi', 'per-user':'person'}

def fetch_data(self, payload, search_item=None):
r = requests.get(self.url, params=payload)
r = requests.get(self.url, params=payload, verify=XDMOD_VERIFY)
logger.info(r.url)
logger.info(r.text)

Expand Down
Loading