Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7f5f586
Define an API to retrieve available domains
cmd-ntrf Mar 8, 2023
e113a0c
Load domains from API only when the cluster does not exist
cmd-ntrf Mar 8, 2023
1aca808
Fix frontend test
cmd-ntrf Mar 8, 2023
933ae8b
Add missing await in frontend test
cmd-ntrf Mar 8, 2023
4e9ccbb
Fix loading
cmd-ntrf Mar 8, 2023
0a9493c
Use standard library cache decorator
cmd-ntrf Mar 9, 2023
bdf2358
Simplify pre_allocated logic
cmd-ntrf Mar 9, 2023
70af367
Reintegrate floatingip counting from terraform state
cmd-ntrf Mar 9, 2023
bfb1780
Rename available_floating_ip_count to available_floating_ip
cmd-ntrf Mar 9, 2023
fb5358c
Remove "max" from quota and return value directly
cmd-ntrf Mar 9, 2023
bfb8a99
Add port and security group to OSManager
cmd-ntrf Mar 9, 2023
78e7247
Add parsing of ports and security groups to tf parser
cmd-ntrf Mar 9, 2023
6a5c635
Include ports in instance quota computation
cmd-ntrf Mar 9, 2023
97ca84f
Fix tests
cmd-ntrf Mar 9, 2023
2a11123
Fix frontend tests
cmd-ntrf Mar 9, 2023
f48f59e
Remove image from terraform state
cmd-ntrf Mar 9, 2023
694fb48
Remove available_tags
cmd-ntrf Mar 10, 2023
333a894
Use dot notation for possibleResources in frontend
cmd-ntrf Mar 10, 2023
5613105
Add volume type to possible resources in OpenStack manager
cmd-ntrf Mar 10, 2023
649f336
Clean imports in openstackmanager
cmd-ntrf Mar 10, 2023
59ce4d1
Remove unused imports
cmd-ntrf Mar 10, 2023
7119f5e
Refactor form row and add region
cmd-ntrf Mar 14, 2023
2e0c99b
Add cloud.name before cloud.provider in title
cmd-ntrf Jun 6, 2023
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
342 changes: 193 additions & 149 deletions frontend/src/components/cluster/ClusterEditor.vue

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions frontend/src/components/cluster/ClustersList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@
<code>centos</code></v-col
>
</v-row>
<v-row>
<v-col>FreeIPA admin username</v-col>
<v-col>
<copy-button :color="expandedContentColor" text="admin" />
<code>admin</code></v-col
>
</v-row>
<v-row>
<v-col>FreeIPA admin password</v-col>
<v-col>
<template v-if="item.freeipa_passwd">
<copy-button :color="expandedContentColor" :text="item.freeipa_passwd" />
<password-display :password="item.freeipa_passwd" :color="expandedContentColor" />
</template>
<span v-else>not available</span>
</v-col>
</v-row>
<v-row>
<v-col>Guest usernames</v-col>
<v-col>
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/repositories/DomainsRepository.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Repository from "./Repository";

const resource = "/domains";

export default {
getDomains() {
return Repository.get(`${resource}/`);
},
};
62 changes: 39 additions & 23 deletions frontend/tests/unit/components/cluster/ClusterEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { cloneDeep } from "lodash";
import moxios from 'moxios';
import Repository from "@/repositories/Repository";

import { jest } from "@jest/globals";

jest.setTimeout(100);

Vue.use(Vuetify);

const localVue = createLocalVue();
Expand Down Expand Up @@ -58,16 +62,20 @@ const DEFAULT_POSSIBLE_RESOURCES = Object.freeze({
tag_types: {"mgmt": ["p4-6gb", "c2-7.5gb-31"], "login": ["p2-3gb", "p4-6gb"], "node": ["p2-3gb", "p4-6gb"]},
"types": ["p1-1.5gb", "p2-3gb", "p4-6gb"],
volumes: {},
});

const DEFAULT_DOMAINS = Object.freeze({
domain: ["magic-castle.cloud", "mc.ca"]
});

const DEFAULT_QUOTAS = Object.freeze({
instance_count: { max: 115 },
ram: { max: 221184 },
vcpus: { max: 224 },
volume_count: { max: 114 },
volume_size: { max: 490 },
ips: { max: 3 },
instance_count: 115,
ram: 221184,
vcpus: 224,
ports: 200,
volume_count: 114,
volume_size: 490,
ips: 3,
});

const DEFAULT_RESOURCE_DETAILS = Object.freeze({
Expand All @@ -93,6 +101,7 @@ async function getDefaultClusterEditorWrapper(existingCluster=true, hostname="te
}
});
await wrapper.vm.promise;
await wrapper.vm.promise_dns;
return wrapper;
}

Expand All @@ -102,23 +111,30 @@ describe("ClusterEditor", () => {
// import and pass your custom axios instance to this method
moxios.install(Repository)
moxios.wait(function () {
let request = moxios.requests.mostRecent();
if(request.url.includes("/available-resources")) {
request.respondWith({
status: 200,
response: {
'possible_resources': DEFAULT_POSSIBLE_RESOURCES,
'quotas': DEFAULT_QUOTAS,
'resource_details': DEFAULT_RESOURCE_DETAILS
}
})
} else if (request.url.includes("/users/me")) {
request.respondWith({
status: 200,
response: DEFAULT_USER
})
} else {
console.log(request.url);
for(let i = 0; i < moxios.requests.count(); i++) {
let request = moxios.requests.at(i);
if(request.url.includes("/available-resources")) {
request.respondWith({
status: 200,
response: {
'possible_resources': DEFAULT_POSSIBLE_RESOURCES,
'quotas': DEFAULT_QUOTAS,
'resource_details': DEFAULT_RESOURCE_DETAILS
}
})
} else if (request.url.includes("/users/me")) {
request.respondWith({
status: 200,
response: DEFAULT_USER
})
} else if (request.url.includes("/domains")) {
request.respondWith({
status: 200,
response: DEFAULT_DOMAINS
})
} else {
console.log(request.url);
}
}
})
})
Expand Down
12 changes: 10 additions & 2 deletions mchub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def create_app(db_path=None):
from .database import db
from .resources.magic_castle_api import MagicCastleAPI
from .resources.progress_api import ProgressAPI
from .resources.available_resources_api import AvailableResourcesApi
from .resources.available_resources_api import AvailableResourcesAPI
from .resources.domains_api import DomainsAPI
from .resources.user_api import UserAPI
from .resources.project_api import ProjectAPI
from .resources.template_api import TemplateAPI
Expand Down Expand Up @@ -54,7 +55,14 @@ def create_app(db_path=None):
methods=["GET"],
)

available_resources_view = AvailableResourcesApi.as_view("available_resources")
domains_view = DomainsAPI.as_view("domains")
app.add_url_rule(
"/api/domains/",
view_func=domains_view,
methods=["GET"],
)

available_resources_view = AvailableResourcesAPI.as_view("available_resources")
app.add_url_rule(
"/api/available-resources/host/<string:hostname>",
view_func=available_resources_view,
Expand Down
36 changes: 23 additions & 13 deletions mchub/models/cloud/cloud_manager.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
from ..cloud.openstack_manager import OpenStackManager
from ..cloud.dns_manager import DnsManager

MANAGER_CLASSES = {
"openstack": OpenStackManager,
}

class CloudManager:
def __init__(self, project, **kwargs):
manager_class = MANAGER_CLASSES.get(project.provider)
if manager_class:
self.manager = manager_class(project=project, **kwargs)
def __init__(self, project, allocated_resources):
if project:
manager_class = MANAGER_CLASSES.get(project.provider)
if manager_class:
self.manager = manager_class(project, allocated_resources)
else:
raise ValueError(f"Unknown cloud provider {project.provider}")
else:
raise ValueError("Invalid cloud provider")
self.manager = DefaultCloudManager(project, allocated_resources)

@property
def available_resources(self):
"""
Retrieves the available cloud resources including resources from OpenStack
and available domains.
Retrieves the available cloud resources from the cloud provider.
"""
available_resources = self.manager.available_resources
available_resources["possible_resources"][
"domain"
] = DnsManager.get_available_domains()
return available_resources
return self.manager.available_resources

class DefaultCloudManager:
def __init__(self, project, allocated_resources):
self.project = project
self.allocated_resources = allocated_resources

@property
def available_resources(self):
return {
"quotas": {},
"possible_resources": {},
"resource_details": {},
}
Loading