stuff
This commit is contained in:
377
data_loader.py
377
data_loader.py
@@ -1,147 +1,276 @@
|
||||
from models import Customer, CustomerService, Location, Host, Service, ServiceType, HostType, VPNType
|
||||
from typing import List
|
||||
from models import Customer, Location, Host
|
||||
|
||||
|
||||
def load_customers() -> List[Customer]:
|
||||
"""Load customer data. For now, returns mock data but can be replaced later."""
|
||||
"""Load customer data. Currently returns mock data for demonstration."""
|
||||
|
||||
# Create hosts for each location
|
||||
alpha_hq_hosts = [
|
||||
Host(name="Web Server", address="10.10.1.5", type="SSH"),
|
||||
Host(name="Admin Panel", address="https://10.10.1.10:8443", type="Web"),
|
||||
Host(name="Database", address="10.10.1.20", type="SSH"),
|
||||
customers = []
|
||||
|
||||
# Customer 1: TechCorp Solutions
|
||||
techcorp = Customer(name="TechCorp Solutions")
|
||||
|
||||
# TechCorp's cloud services
|
||||
techcorp.services = [
|
||||
CustomerService("Office 365", "https://portal.office.com", "Email & Office"),
|
||||
CustomerService("Pascom Cloud PBX", "https://techcorp.pascom.cloud", "Phone System"),
|
||||
CustomerService("Salesforce CRM", "https://techcorp.salesforce.com", "CRM")
|
||||
]
|
||||
|
||||
alpha_branch_hosts = [
|
||||
Host(name="File Server", address="10.10.2.5", type="SMB"),
|
||||
Host(name="Backup Server", address="10.10.2.10", type="SSH"),
|
||||
]
|
||||
|
||||
beta_main_hosts = [
|
||||
Host(name="Main Portal", address="https://portal.beta.local", type="Web"),
|
||||
Host(name="File Server", address="192.168.50.10", type="SMB"),
|
||||
]
|
||||
|
||||
gamma_dc_hosts = [
|
||||
Host(name="Application Server", address="172.16.0.100", type="SSH"),
|
||||
Host(name="Monitoring Dashboard", address="https://monitor.gamma.net", type="Web"),
|
||||
Host(name="Backup Server", address="172.16.0.150", type="SSH"),
|
||||
]
|
||||
|
||||
gamma_dr_hosts = [
|
||||
Host(name="DR Server", address="172.16.1.100", type="SSH"),
|
||||
Host(name="Backup Storage", address="172.16.1.150", type="SMB"),
|
||||
]
|
||||
|
||||
delta_dev_hosts = [
|
||||
Host(name="Development Server", address="10.20.30.40", type="SSH"),
|
||||
Host(name="CI/CD Pipeline", address="https://jenkins.delta.local:8080", type="Web"),
|
||||
]
|
||||
|
||||
epsilon_prod_hosts = [
|
||||
Host(name="Production API", address="https://api.epsilon.com", type="Web"),
|
||||
Host(name="Database Cluster", address="10.5.0.50", type="PostgreSQL"),
|
||||
Host(name="Redis Cache", address="10.5.0.60", type="Redis"),
|
||||
]
|
||||
|
||||
epsilon_staging_hosts = [
|
||||
Host(name="Staging API", address="https://staging-api.epsilon.com", type="Web"),
|
||||
Host(name="Test Database", address="10.5.1.50", type="PostgreSQL"),
|
||||
]
|
||||
|
||||
# Create locations
|
||||
alpha_hq = Location(
|
||||
name="Headquarters",
|
||||
vpn_type="OpenVPN",
|
||||
connected=False,
|
||||
active=True,
|
||||
hosts=alpha_hq_hosts
|
||||
)
|
||||
|
||||
alpha_branch = Location(
|
||||
name="Branch Office",
|
||||
vpn_type="WireGuard",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=alpha_branch_hosts
|
||||
)
|
||||
|
||||
beta_main = Location(
|
||||
# TechCorp's main office location
|
||||
main_office = Location(
|
||||
name="Main Office",
|
||||
vpn_type="WireGuard",
|
||||
vpn_type=VPNType.OPENVPN,
|
||||
connected=True,
|
||||
active=True,
|
||||
hosts=beta_main_hosts
|
||||
vpn_config="/etc/openvpn/techcorp-main.ovpn"
|
||||
)
|
||||
|
||||
gamma_dc = Location(
|
||||
name="Data Center",
|
||||
vpn_type="IPSec",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=gamma_dc_hosts
|
||||
# Proxmox hypervisor with VMs
|
||||
proxmox_host = Host(
|
||||
name="PVE-01",
|
||||
ip_address="192.168.1.10",
|
||||
host_type=HostType.PROXMOX,
|
||||
description="Main virtualization server",
|
||||
services=[
|
||||
Service("Web Interface", ServiceType.WEB_GUI, 8006),
|
||||
Service("SSH", ServiceType.SSH, 22)
|
||||
]
|
||||
)
|
||||
|
||||
gamma_dr = Location(
|
||||
name="DR Site",
|
||||
vpn_type="OpenVPN",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=gamma_dr_hosts
|
||||
)
|
||||
|
||||
delta_dev = Location(
|
||||
name="Development Lab",
|
||||
vpn_type="OpenVPN",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=delta_dev_hosts
|
||||
)
|
||||
|
||||
epsilon_prod = Location(
|
||||
name="Production",
|
||||
vpn_type="WireGuard",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=epsilon_prod_hosts
|
||||
)
|
||||
|
||||
epsilon_staging = Location(
|
||||
name="Staging",
|
||||
vpn_type="OpenVPN",
|
||||
connected=False,
|
||||
active=False,
|
||||
hosts=epsilon_staging_hosts
|
||||
)
|
||||
|
||||
# Create customers
|
||||
customers = [
|
||||
Customer(
|
||||
name="Customer Alpha Corp",
|
||||
locations=[alpha_hq, alpha_branch]
|
||||
# VMs running on Proxmox
|
||||
proxmox_host.sub_hosts = [
|
||||
Host(
|
||||
name="DC-01",
|
||||
ip_address="192.168.1.20",
|
||||
host_type=HostType.WINDOWS_SERVER,
|
||||
description="Domain Controller",
|
||||
services=[
|
||||
Service("RDP", ServiceType.RDP, 3389),
|
||||
Service("Admin Web", ServiceType.WEB_GUI, 8080)
|
||||
]
|
||||
),
|
||||
Customer(
|
||||
name="Beta Industries",
|
||||
locations=[beta_main]
|
||||
),
|
||||
Customer(
|
||||
name="Gamma Solutions",
|
||||
locations=[gamma_dc, gamma_dr]
|
||||
),
|
||||
Customer(
|
||||
name="Delta Tech",
|
||||
locations=[delta_dev]
|
||||
),
|
||||
Customer(
|
||||
name="Epsilon Systems",
|
||||
locations=[epsilon_prod, epsilon_staging]
|
||||
Host(
|
||||
name="FILE-01",
|
||||
ip_address="192.168.1.21",
|
||||
host_type=HostType.LINUX,
|
||||
description="File Server (Samba)",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("SMB Share", ServiceType.SMB, 445),
|
||||
Service("Web Panel", ServiceType.WEB_GUI, 9000)
|
||||
]
|
||||
),
|
||||
Host(
|
||||
name="DB-01",
|
||||
ip_address="192.168.1.22",
|
||||
host_type=HostType.LINUX,
|
||||
description="PostgreSQL Database",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("PostgreSQL", ServiceType.DATABASE, 5432),
|
||||
Service("pgAdmin", ServiceType.WEB_GUI, 5050)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
# Network infrastructure
|
||||
router = Host(
|
||||
name="FW-01",
|
||||
ip_address="192.168.1.1",
|
||||
host_type=HostType.ROUTER,
|
||||
description="pfSense Firewall/Router",
|
||||
services=[
|
||||
Service("Web Interface", ServiceType.WEB_GUI, 443),
|
||||
Service("SSH", ServiceType.SSH, 22)
|
||||
]
|
||||
)
|
||||
|
||||
switch = Host(
|
||||
name="SW-01",
|
||||
ip_address="192.168.1.2",
|
||||
host_type=HostType.SWITCH,
|
||||
description="Managed Switch",
|
||||
services=[
|
||||
Service("Web Interface", ServiceType.WEB_GUI, 80),
|
||||
Service("SSH", ServiceType.SSH, 22)
|
||||
]
|
||||
)
|
||||
|
||||
main_office.hosts = [proxmox_host, router, switch]
|
||||
|
||||
# Branch office location
|
||||
branch_office = Location(
|
||||
name="Branch Office",
|
||||
vpn_type=VPNType.WIREGUARD,
|
||||
connected=False,
|
||||
active=False,
|
||||
vpn_config="/etc/wireguard/techcorp-branch.conf"
|
||||
)
|
||||
|
||||
branch_server = Host(
|
||||
name="BRANCH-01",
|
||||
ip_address="10.10.1.10",
|
||||
host_type=HostType.LINUX,
|
||||
description="Branch office server",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("File Share", ServiceType.SMB, 445),
|
||||
Service("Local Web", ServiceType.WEB_GUI, 8080)
|
||||
]
|
||||
)
|
||||
|
||||
branch_office.hosts = [branch_server]
|
||||
|
||||
techcorp.locations = [main_office, branch_office]
|
||||
customers.append(techcorp)
|
||||
|
||||
# Customer 2: MedPractice Group
|
||||
medpractice = Customer(name="MedPractice Group")
|
||||
|
||||
# MedPractice's cloud services
|
||||
medpractice.services = [
|
||||
CustomerService("Google Workspace", "https://workspace.google.com", "Email & Office"),
|
||||
CustomerService("Practice Management", "https://medpractice.emr-system.com", "EMR System"),
|
||||
CustomerService("VoIP Provider", "https://medpractice.voip.com", "Phone System")
|
||||
]
|
||||
|
||||
# Clinic location
|
||||
clinic_location = Location(
|
||||
name="Main Clinic",
|
||||
vpn_type=VPNType.WIREGUARD,
|
||||
connected=False,
|
||||
active=False,
|
||||
vpn_config="/etc/wireguard/medpractice.conf"
|
||||
)
|
||||
|
||||
# ESXi hypervisor
|
||||
esxi_host = Host(
|
||||
name="ESXi-01",
|
||||
ip_address="10.0.1.10",
|
||||
host_type=HostType.ESXI,
|
||||
description="VMware ESXi Host",
|
||||
services=[
|
||||
Service("vSphere Web", ServiceType.WEB_GUI, 443),
|
||||
Service("SSH", ServiceType.SSH, 22)
|
||||
]
|
||||
)
|
||||
|
||||
# VMs on ESXi
|
||||
esxi_host.sub_hosts = [
|
||||
Host(
|
||||
name="WIN-SRV-01",
|
||||
ip_address="10.0.1.20",
|
||||
host_type=HostType.WINDOWS_SERVER,
|
||||
description="Windows Server 2022",
|
||||
services=[
|
||||
Service("RDP", ServiceType.RDP, 3389),
|
||||
Service("IIS Web", ServiceType.WEB_GUI, 80)
|
||||
]
|
||||
),
|
||||
Host(
|
||||
name="BACKUP-01",
|
||||
ip_address="10.0.1.21",
|
||||
host_type=HostType.LINUX,
|
||||
description="Backup Server",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("Backup Web UI", ServiceType.WEB_GUI, 8080)
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
# Physical server
|
||||
physical_server = Host(
|
||||
name="PHYS-01",
|
||||
ip_address="10.0.1.50",
|
||||
host_type=HostType.LINUX,
|
||||
description="Physical Linux Server",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("Docker Portainer", ServiceType.WEB_GUI, 9000),
|
||||
Service("Nginx Proxy", ServiceType.WEB_GUI, 8080)
|
||||
]
|
||||
)
|
||||
|
||||
clinic_location.hosts = [esxi_host, physical_server]
|
||||
medpractice.locations = [clinic_location]
|
||||
customers.append(medpractice)
|
||||
|
||||
# Customer 3: Manufacturing Inc
|
||||
manufacturing = Customer(name="Manufacturing Inc")
|
||||
|
||||
# Manufacturing's cloud services
|
||||
manufacturing.services = [
|
||||
CustomerService("Microsoft 365", "https://portal.office.com", "Email & Office"),
|
||||
CustomerService("SAP Cloud", "https://manufacturing.sap.com", "ERP System")
|
||||
]
|
||||
|
||||
# Factory location
|
||||
factory_location = Location(
|
||||
name="Factory Floor",
|
||||
vpn_type=VPNType.IPSEC,
|
||||
connected=False,
|
||||
active=True,
|
||||
vpn_config="/etc/ipsec.d/manufacturing.conf"
|
||||
)
|
||||
|
||||
# Manufacturing infrastructure - simpler setup
|
||||
linux_server = Host(
|
||||
name="PROD-01",
|
||||
ip_address="172.16.1.10",
|
||||
host_type=HostType.LINUX,
|
||||
description="Production Server",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("Web Portal", ServiceType.WEB_GUI, 8443),
|
||||
Service("FTP", ServiceType.FTP, 21)
|
||||
]
|
||||
)
|
||||
|
||||
nas_server = Host(
|
||||
name="NAS-01",
|
||||
ip_address="172.16.1.20",
|
||||
host_type=HostType.LINUX,
|
||||
description="Network Attached Storage",
|
||||
services=[
|
||||
Service("SSH", ServiceType.SSH, 22),
|
||||
Service("Web Interface", ServiceType.WEB_GUI, 5000),
|
||||
Service("SMB Share", ServiceType.SMB, 445)
|
||||
]
|
||||
)
|
||||
|
||||
factory_location.hosts = [linux_server, nas_server]
|
||||
|
||||
# Office location
|
||||
office_location = Location(
|
||||
name="Administrative Office",
|
||||
vpn_type=VPNType.OPENVPN,
|
||||
connected=False,
|
||||
active=False,
|
||||
vpn_config="/etc/openvpn/manufacturing-office.ovpn"
|
||||
)
|
||||
|
||||
office_server = Host(
|
||||
name="OFFICE-01",
|
||||
ip_address="172.16.2.10",
|
||||
host_type=HostType.WINDOWS_SERVER,
|
||||
description="Office domain controller",
|
||||
services=[
|
||||
Service("RDP", ServiceType.RDP, 3389),
|
||||
Service("File Share", ServiceType.SMB, 445)
|
||||
]
|
||||
)
|
||||
|
||||
office_location.hosts = [office_server]
|
||||
|
||||
manufacturing.locations = [factory_location, office_location]
|
||||
customers.append(manufacturing)
|
||||
|
||||
return customers
|
||||
|
||||
|
||||
def save_customers(customers: List[Customer]) -> None:
|
||||
"""Save customer data. Placeholder for future implementation."""
|
||||
# TODO: Implement saving to file/database
|
||||
"""Save customer data. Currently a placeholder."""
|
||||
# TODO: Implement actual persistence (JSON file, database, etc.)
|
||||
pass
|
||||
Reference in New Issue
Block a user