Skip to content

Commit

Permalink
TMP ⚰️ Remove SHM domain controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jemrobinson committed Apr 10, 2024
1 parent 4fffb5d commit e44cde8
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 80 deletions.
17 changes: 9 additions & 8 deletions data_safe_haven/commands/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from data_safe_haven.config import Config, ContextSettings
from data_safe_haven.exceptions import DataSafeHavenError
from data_safe_haven.external import GraphApi
from data_safe_haven.functions import password

# from data_safe_haven.functions import password
from data_safe_haven.infrastructure import SHMStackManager, SREStackManager
from data_safe_haven.provisioning import SHMProvisioningManager, SREProvisioningManager
from data_safe_haven.provisioning import SREProvisioningManager
from data_safe_haven.utility import LoggingSingleton

deploy_command_group = typer.Typer()
Expand Down Expand Up @@ -75,12 +76,12 @@ def shm(
stack.output("networking")["fqdn_nameservers"],
)

# Provision SHM with anything that could not be done in Pulumi
manager = SHMProvisioningManager(
subscription_name=config.context.subscription_name,
stack=stack,
)
manager.run()
# # Provision SHM with anything that could not be done in Pulumi
# manager = SHMProvisioningManager(
# subscription_name=config.context.subscription_name,
# stack=stack,
# )
# manager.run()
except DataSafeHavenError as exc:
msg = f"Could not deploy Data Safe Haven Management environment.\n{exc}"
raise DataSafeHavenError(msg) from exc
Expand Down
75 changes: 35 additions & 40 deletions data_safe_haven/infrastructure/stacks/declarative_shm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

from data_safe_haven.config import Config

from .shm.bastion import SHMBastionComponent, SHMBastionProps
from .shm.data import SHMDataComponent, SHMDataProps
from .shm.domain_controllers import (
SHMDomainControllersComponent,
SHMDomainControllersProps,
)
from .shm.firewall import SHMFirewallComponent, SHMFirewallProps
from .shm.monitoring import SHMMonitoringComponent, SHMMonitoringProps
from .shm.networking import SHMNetworkingComponent, SHMNetworkingProps
Expand Down Expand Up @@ -61,17 +56,17 @@ def run(self) -> None:
tags=self.cfg.tags.model_dump(),
)

# Deploy firewall and routing
SHMBastionComponent(
"shm_bastion",
self.stack_name,
SHMBastionProps(
location=self.cfg.azure.location,
resource_group_name=networking.resource_group_name,
subnet=networking.subnet_bastion,
),
tags=self.cfg.tags.model_dump(),
)
# # Deploy firewall and routing
# SHMBastionComponent(
# "shm_bastion",
# self.stack_name,
# SHMBastionProps(
# location=self.cfg.azure.location,
# resource_group_name=networking.resource_group_name,
# subnet=networking.subnet_bastion,
# ),
# tags=self.cfg.tags.model_dump(),
# )

# Deploy data storage
data = SHMDataComponent(
Expand Down Expand Up @@ -116,32 +111,32 @@ def run(self) -> None:
tags=self.cfg.tags.model_dump(),
)

# Deploy domain controllers
domain_controllers = SHMDomainControllersComponent(
"shm_domain_controllers",
self.stack_name,
SHMDomainControllersProps(
automation_account=monitoring.automation_account,
automation_account_modules=monitoring.automation_account_modules,
automation_account_private_dns=monitoring.automation_account_private_dns,
domain_fqdn=networking.dns_zone.name,
domain_netbios_name=self.shm_name.upper(),
location=self.cfg.azure.location,
log_analytics_workspace=monitoring.log_analytics_workspace,
password_domain_admin=data.password_domain_admin,
password_domain_azuread_connect=data.password_domain_azure_ad_connect,
password_domain_searcher=data.password_domain_searcher,
private_ip_address=networking.domain_controller_private_ip,
subnet_identity_servers=networking.subnet_identity_servers,
subscription_name=self.cfg.context.subscription_name,
virtual_network_name=networking.virtual_network.name,
virtual_network_resource_group_name=networking.resource_group_name,
),
tags=self.cfg.tags.model_dump(),
)
# # Deploy domain controllers
# domain_controllers = SHMDomainControllersComponent(
# "shm_domain_controllers",
# self.stack_name,
# SHMDomainControllersProps(
# automation_account=monitoring.automation_account,
# automation_account_modules=monitoring.automation_account_modules,
# automation_account_private_dns=monitoring.automation_account_private_dns,
# domain_fqdn=networking.dns_zone.name,
# domain_netbios_name=self.shm_name.upper(),
# location=self.cfg.azure.location,
# log_analytics_workspace=monitoring.log_analytics_workspace,
# password_domain_admin=data.password_domain_admin,
# password_domain_azuread_connect=data.password_domain_azure_ad_connect,
# password_domain_searcher=data.password_domain_searcher,
# private_ip_address=networking.domain_controller_private_ip,
# subnet_identity_servers=networking.subnet_identity_servers,
# subscription_name=self.cfg.context.subscription_name,
# virtual_network_name=networking.virtual_network.name,
# virtual_network_resource_group_name=networking.resource_group_name,
# ),
# tags=self.cfg.tags.model_dump(),
# )

# Export values for later use
pulumi.export("domain_controllers", domain_controllers.exports)
# pulumi.export("domain_controllers", domain_controllers.exports)
pulumi.export("firewall", firewall.exports)
pulumi.export("monitoring", monitoring.exports)
pulumi.export("networking", networking.exports)
Expand Down
4 changes: 2 additions & 2 deletions data_safe_haven/provisioning/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Provisioning for deployed Data Safe Haven infrastructure."""

from .shm_provisioning_manager import SHMProvisioningManager
# from .shm_provisioning_manager import SHMProvisioningManager
from .sre_provisioning_manager import SREProvisioningManager

__all__ = [
"SHMProvisioningManager",
# "SHMProvisioningManager",
"SREProvisioningManager",
]
60 changes: 30 additions & 30 deletions data_safe_haven/provisioning/shm_provisioning_manager.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
"""Provisioning manager for a deployed SHM."""
# """Provisioning manager for a deployed SHM."""

from data_safe_haven.external import AzureApi
from data_safe_haven.infrastructure import SHMStackManager
# from data_safe_haven.external import AzureApi
# from data_safe_haven.infrastructure import SHMStackManager


class SHMProvisioningManager:
"""Provisioning manager for a deployed SHM."""
# class SHMProvisioningManager:
# """Provisioning manager for a deployed SHM."""

def __init__(
self,
subscription_name: str,
stack: SHMStackManager,
):
super().__init__()
self.subscription_name = subscription_name
domain_controllers_resource_group_name = stack.output("domain_controllers")[
"resource_group_name"
]
domain_controllers_vm_name = stack.output("domain_controllers")["vm_name"]
# def __init__(
# self,
# subscription_name: str,
# stack: SHMStackManager,
# ):
# super().__init__()
# self.subscription_name = subscription_name
# domain_controllers_resource_group_name = stack.output("domain_controllers")[
# "resource_group_name"
# ]
# domain_controllers_vm_name = stack.output("domain_controllers")["vm_name"]

# Construct DC restart parameters
self.dc_restart_params = {
"resource_group_name": domain_controllers_resource_group_name,
"vm_name": domain_controllers_vm_name,
}
# # Construct DC restart parameters
# self.dc_restart_params = {
# "resource_group_name": domain_controllers_resource_group_name,
# "vm_name": domain_controllers_vm_name,
# }

def restart_domain_controllers(self) -> None:
azure_api = AzureApi(self.subscription_name)
azure_api.restart_virtual_machine(
self.dc_restart_params["resource_group_name"],
self.dc_restart_params["vm_name"],
)
# def restart_domain_controllers(self) -> None:
# azure_api = AzureApi(self.subscription_name)
# azure_api.restart_virtual_machine(
# self.dc_restart_params["resource_group_name"],
# self.dc_restart_params["vm_name"],
# )

def run(self) -> None:
"""Apply SHM configuration"""
self.restart_domain_controllers()
# def run(self) -> None:
# """Apply SHM configuration"""
# self.restart_domain_controllers()

0 comments on commit e44cde8

Please sign in to comment.