Skip to content

Commit

Permalink
Merge pull request #499 from ucb-rit/develop
Browse files Browse the repository at this point in the history
Add commands for managing billing IDs, creating projects; introduce refmlab cluster; fix Apache bug
  • Loading branch information
matthew-li authored Jan 27, 2023
2 parents e664234 + e5df4ff commit 4c6d3df
Show file tree
Hide file tree
Showing 28 changed files with 1,764 additions and 108 deletions.
2 changes: 1 addition & 1 deletion bootstrap/ansible/wsgi_conf_ssl.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ WSGIPassAuthorization On

</VirtualHost>

<VirtualHost {{ host_ip }}:80>
<VirtualHost *:80>

{% if cloudflare_enabled | bool %}
ServerName {{ cloudflare_local_server_name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_user_filter(self):

def test_project_filter(self):
"""Test that querying by project filters results properly."""
project = self.project0.name
project = self.fc_project0.name

url = self.endpoint_url()
query_parameters = {
Expand All @@ -125,14 +125,14 @@ def test_project_filter(self):

def test_resources_filter(self):
"""Test that querying by resource filters results properly."""
allocation = Allocation.objects.get(project=self.project0)
allocation = Allocation.objects.get(project=self.fc_project0)
resource_type = ResourceType.objects.get(name='Cluster')
resource = Resource.objects.create(
name='Other Compute', resource_type=resource_type)
allocation.resources.add(resource)

first = allocation.pk
second = Allocation.objects.get(project=self.project1).pk
second = Allocation.objects.get(project=self.fc_project1).pk
allocation_ids_iterator = iter([first, first, first, first,
second, second, second, second])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_no_filters(self):

def test_project_filter(self):
"""Test that querying by project filters results properly."""
project = self.project0.name
project = self.fc_project0.name

url = self.endpoint_url()
query_parameters = {
Expand All @@ -97,7 +97,7 @@ def test_project_filter(self):

def test_resources_filter(self):
"""Test that querying by resource filters results properly."""
allocation = Allocation.objects.get(project=self.project0)
allocation = Allocation.objects.get(project=self.fc_project0)
resource_type = ResourceType.objects.get(name='Cluster')
resource = Resource.objects.create(
name='Other Compute', resource_type=resource_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def setUp(self):
status_choices = ClusterAccessRequestStatusChoice.objects.all()
for i in range(4):
kwargs = {
'allocation_user': AllocationUser.objects.get(user__username=f'user{i}',
allocation__project__name='project0'),
'allocation_user': AllocationUser.objects.get(
user__username=f'user{i}',
allocation__project__name='fc_project0'),
'request_time': utc_now_offset_aware(),
}
if i == 0:
Expand All @@ -60,7 +61,7 @@ def setUp(self):

self.allocation_user0 = \
AllocationUser.objects.get(user=self.user0,
allocation__project=self.project0)
allocation__project=self.fc_project0)

self.allocation_su_attr = AllocationAttribute.objects.get(
allocation_attribute_type__name='Service Units',
Expand Down Expand Up @@ -193,7 +194,7 @@ def _get_cluster_account_status_attr(self, allocation_user):
return cluster_access_attribute

def _assert_complete_emails_sent(self):
email_body = [f'now has access to the project {self.project0.name}.',
email_body = [f'now has access to the project {self.fc_project0.name}.',
f'supercluster username is - {self.new_username}',
f'If this is the first time you are accessing',
f'start with the below Logging In page:']
Expand All @@ -209,7 +210,7 @@ def _assert_complete_emails_sent(self):
self.assertEqual(settings.EMAIL_SENDER, email.from_email)

def _assert_denial_emails_sent(self):
email_body = [f'access request under project {self.project0.name}',
email_body = [f'access request under project {self.fc_project0.name}',
f'and allocation '
f'{self.allocation_user0.allocation.pk} '
f'has been denied.']
Expand Down Expand Up @@ -300,7 +301,7 @@ def test_read_only_fields_ignored(self):
'allocation_user': {'id': 12,
'allocation': 3,
'user': 'user3',
'project': 'project0',
'project': 'fc_project0',
'status': 'Complete'},
'username': 'new_username',
'cluster_uid': '1234'
Expand Down
4 changes: 2 additions & 2 deletions coldfront/api/allocation/tests/test_allocation_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def setUp(self):
for i in range(2):
# Create a Project and ProjectUsers.
project = Project.objects.create(
name=f'project{i}', status=project_status)
setattr(self, f'project{i}', project)
name=f'fc_project{i}', status=project_status)
setattr(self, f'fc_project{i}', project)
for j in range(4):
ProjectUser.objects.create(
user=getattr(self, f'user{j}'), project=project,
Expand Down
8 changes: 4 additions & 4 deletions coldfront/api/statistics/tests/test_job_view_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setUp(self):
allocation_amount = Decimal('1000.00')
for i in range(self.num_projects):
project = Project.objects.create(
name=f'PROJECT_{i}', status=project_status)
name=f'fc_project_{i}', status=project_status)
allocation_objects = create_project_allocation(
project, allocation_amount)
allocation_objects.allocation.start_date = \
Expand All @@ -88,7 +88,7 @@ def setUp(self):
for i in range(self.num_users):
user = User.objects.get(username=f'user{i}')
project = Project.objects.get(
name=f'PROJECT_{i // self.num_projects}')
name=f'fc_project_{i // self.num_projects}')
status = ProjectUserStatusChoice.objects.get(name='Active')
ProjectUser.objects.create(
user=user, project=project, role=role, status=status)
Expand Down Expand Up @@ -212,9 +212,9 @@ def test_account_filter(self):
self.assert_results(url, status_code, count)
# PROJECT_0 submitted 4 jobs.
try:
account = Project.objects.get(name='PROJECT_0')
account = Project.objects.get(name='fc_project_0')
except Project.DoesNotExist:
self.fail('A Project with name "PROJECT_0" should exist.')
self.fail('A Project with name "fc_project_0" should exist.')
url = TestJobList.get_url(account=account.name)
status_code, count = 200, 4
results_dict = self.assert_results(url, status_code, count)
Expand Down
38 changes: 15 additions & 23 deletions coldfront/core/allocation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
SecureDirAddUserRequest,
SecureDirAddUserRequestStatusChoice,
SecureDirRemoveUserRequest,
SecureDirRemoveUserRequestStatusChoice,
SecureDirRequest,
SecureDirRequestStatusChoice)
SecureDirRemoveUserRequestStatusChoice)
from coldfront.core.allocation.signals import allocation_activate_user
from coldfront.core.project.models import Project
from coldfront.core.resource.models import Resource
Expand Down Expand Up @@ -157,26 +155,20 @@ def get_project_compute_resource_name(project_obj):
The name is based on currently-enabled flags (i.e., BRC, LRC). If
one cannot be determined, return the empty string."""
if flag_enabled('BRC_ONLY'):
if project_obj.name == 'abc':
resource_name = 'ABC Compute'
elif project_obj.name.startswith('vector_'):
resource_name = 'Vector Compute'
else:
resource_name = get_primary_compute_resource_name()
return resource_name
if flag_enabled('LRC_ONLY'):
computing_allowance_interface = ComputingAllowanceInterface()
project_name_prefixes = tuple([
computing_allowance_interface.code_from_name(allowance.name)
for allowance in computing_allowance_interface.allowances()])
if project_obj.name.startswith(project_name_prefixes):
resource_name = get_primary_compute_resource_name()
else:
# TODO: Verify this behavior.
resource_name = f'{project_obj.name.upper()} Compute'
return resource_name
return ''
project_name = project_obj.name

computing_allowance_interface = ComputingAllowanceInterface()
project_name_prefixes = tuple([
computing_allowance_interface.code_from_name(allowance.name)
for allowance in computing_allowance_interface.allowances()])
if project_name.startswith(project_name_prefixes):
return get_primary_compute_resource_name()

if flag_enabled('BRC_ONLY') and project_name.startswith('vector_'):
cluster_name = 'Vector'
else:
cluster_name = project_name.upper()
return f'{cluster_name} Compute'


def get_project_compute_allocation(project_obj):
Expand Down
Empty file.
Empty file.
Loading

0 comments on commit 4c6d3df

Please sign in to comment.