Skip to content

Commit

Permalink
Update dns module variable for MC v14
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd-ntrf committed Sep 20, 2024
1 parent f7ad3cb commit 0f97003
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 25 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ services:
user: mcu
environment:
OS_CLIENT_CONFIG_FILE: /home/mcu/credentials/clouds.yaml
MAGIC_CASTLE_ACME_KEY_PEM: /home/mcu/credentials/acme_key.pem

cleanup:
build:
Expand Down
11 changes: 4 additions & 7 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ An example `configuration.json` is shown below.
},
"dns_providers": {
"cloudflare": {
"magic_castle_configuration": {
"email": "you@example.com"
},
"magic_castle_configuration": {},
"environment_variables": {
"CLOUDFLARE_API_TOKEN": "EXAMPLE_TOKEN",
"CLOUDFLARE_ZONE_API_TOKEN": "EXAMPLE_TOKEN",
Expand All @@ -30,7 +28,6 @@ An example `configuration.json` is shown below.
},
"gcloud": {
"magic_castle_configuration": {
"email": "you@example.com",
"project": "your-project-id",
"zone_name": "your-zone-name"
},
Expand Down Expand Up @@ -61,13 +58,13 @@ If `auth_type` is set to `"SAML"`, the values contained in `admins` are strings

### `cors_allowed_origins`

A list of origins allowed making HTTP requests to the server. This should be set to the frontend base URL.
A list of origins allowed making HTTP requests to the server. This should be set to the frontend base URL.

For instance, if you are running MC Hub locally, this may be set to `http://localhost:5000`. If you are running an additional Node development server, you can also add its url, which may look like `http://localhost:8080`.
For instance, if you are running MC Hub locally, this may be set to `http://localhost:5000`. If you are running an additional Node development server, you can also add its url, which may look like `http://localhost:8080`.

Otherwise, if you are running MC Hub in production, the origin url may look like `https://mc.computecanada.dev` (without an explicit port number).

> Note: The * wildcard origin can be used but is not recommended for security reasons. This way, a malicious web page could view and edit your clusters.
> Note: The \* wildcard origin can be used but is not recommended for security reasons. This way, a malicious web page could view and edit your clusters.
### `domains`

Expand Down
2 changes: 0 additions & 2 deletions mchub/configuration/magic_castle.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@
"gcloud": path.join(".", "dns", "gcloud"),
},
}

MAGIC_CASTLE_ACME_KEY_PEM = environ.get("MAGIC_CASTLE_ACME_KEY_PEM", "")
6 changes: 1 addition & 5 deletions mchub/models/cloud/dns_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ... configuration import config
from ... configuration.magic_castle import MAGIC_CASTLE_SOURCE, MAGIC_CASTLE_ACME_KEY_PEM
from ... configuration.magic_castle import MAGIC_CASTLE_SOURCE


class DnsManager:
Expand Down Expand Up @@ -36,17 +36,13 @@ def get_magic_castle_configuration(self):
"name": "${module.openstack.cluster_name}",
"domain": "${module.openstack.domain}",
"public_instances": "${module.openstack.public_instances}",
"ssh_private_key": "${module.openstack.ssh_private_key}",
"sudoer_username": "${module.openstack.accounts.sudoer.username}",
}
}
magic_castle_configuration["dns"].update(
config["dns_providers"][self.provider][
"magic_castle_configuration"
]
)
if MAGIC_CASTLE_ACME_KEY_PEM != "":
magic_castle_configuration["dns"]["acme_key_pem"] = f"${{file(\"{MAGIC_CASTLE_ACME_KEY_PEM}\")}}"

return magic_castle_configuration
else:
Expand Down
2 changes: 1 addition & 1 deletion mchub/models/cloud/openstack_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Magic Castle requires the following specs for each instance category
TAG_MINIMUM_REQUIREMENTS = {
"mgmt": {
"ram": 6144,
"ram": 8000,
"vcpus": 2
},
"login": {
Expand Down
4 changes: 1 addition & 3 deletions tests/mocks/configuration/config_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dns_providers": {
"cf1": {
"module": "cloudflare",
"magic_castle_configuration": {"email": "you@example.com"},
"magic_castle_configuration": {},
"environment_variables": {
"CLOUDFLARE_API_TOKEN": "EXAMPLE_TOKEN",
"CLOUDFLARE_ZONE_API_TOKEN": "EXAMPLE_TOKEN",
Expand All @@ -34,7 +34,6 @@
"gcloud1": {
"module": "gcloud",
"magic_castle_configuration": {
"email": "you@example.com",
"project": "your-project-name",
"zone_name": "your-zone-name",
},
Expand Down Expand Up @@ -75,4 +74,3 @@ def config_auth_none_mock(mocker):
mocker.patch(
"mchub.resources.api_view.config", new=configuration,
)

7 changes: 1 addition & 6 deletions tests/unit/cloud/test_dns_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from ... mocks.configuration.config_mock import config_auth_none_mock # noqa;
from ... test_helpers import * # noqa;


def test_initialize_disallowed_domain():
with pytest.raises(KeyError):
DnsManager("invalid.com")
Expand Down Expand Up @@ -33,25 +34,19 @@ def test_get_environment_variables_with_dns_provider():
def test_get_magic_castle_configuration_with_dns_provider():
assert DnsManager("calculquebec.cloud").get_magic_castle_configuration() == {
"dns": {
"email": "you@example.com",
"source": MAGIC_CASTLE_SOURCE["dns"]["cloudflare"],
"name": "${module.openstack.cluster_name}",
"domain": "${module.openstack.domain}",
"public_instances": "${module.openstack.public_instances}",
"ssh_private_key": "${module.openstack.ssh_private_key}",
"sudoer_username": "${module.openstack.accounts.sudoer.username}",
}
}
assert DnsManager("c3.ca").get_magic_castle_configuration() == {
"dns": {
"email": "you@example.com",
"project": "your-project-name",
"zone_name": "your-zone-name",
"source": MAGIC_CASTLE_SOURCE["dns"]["gcloud"],
"name": "${module.openstack.cluster_name}",
"domain": "${module.openstack.domain}",
"public_instances": "${module.openstack.public_instances}",
"ssh_private_key": "${module.openstack.ssh_private_key}",
"sudoer_username": "${module.openstack.accounts.sudoer.username}",
}
}

0 comments on commit 0f97003

Please sign in to comment.