diff --git a/cli/database.py b/cli/database.py new file mode 100644 index 0000000..e69de29 diff --git a/config/settings.template b/config/settings.template index 1757ea2..78f4245 100644 --- a/config/settings.template +++ b/config/settings.template @@ -1,36 +1,33 @@ +common: &common + username: "" + password: "" + type: "" + service_name: "" + git: &git_config + repo_url: "" + branch: "" + local_path: "" + ssh: &ssh_config + user: + key_path: "" + odoo_instances: -- name: "ftacpa" - host: "10.1.1.31" - port: 8069 - database: "ftacpa" - username: "nextzen" - password: "smartyourlife" - type: "systemctl" - service_name: "odoo18" - git: - repo_url: "https://hoangvv:smartyourlife@git.nextzenos.com/NextERP/Odoo18-FTACPA.git" - branch: "community/demo/ftacpa" - local_path: "/opt/odoo18/addons" - ssh: - user: root - key_path: "/root/.ssh/privatessh.key" - # - name: "server1_test" - # host: "server1.example.com" - # port: 8069 - # database: "test_db1" - # username: "admin" - # password: "test_password" - # module_names: - # - "your_module" - # type: "docker" - # - name: "server2_prod" - # host: "server2.example.com" - # port: 8070 - # database: "prod_db2" - # username: "admin" - # password: "admin_password" - # module_names: - # - "your_module" - # - "custom_module" - # - "third_module" - # type: "systemctl" + - name: "" + host: "" + port: + database: "" + modules: + - "" + - "" + - "" + <<: *common # Inherit common settings + + - name: "" + host: "" + port: + database: "" + modules: + - "" + - "" + - "" + <<: *common # Inherit common settings diff --git a/config/settings.yaml b/config/settings.yaml index e393c15..c25147f 100644 --- a/config/settings.yaml +++ b/config/settings.yaml @@ -1,4 +1,6 @@ common: &common + host: "10.1.1.34" + port: 8069 username: "nextzen" password: "smartyourlife" type: "systemctl" @@ -10,22 +12,22 @@ common: &common ssh: &ssh_config user: root key_path: "/root/.ssh/privatessh.key" - modules: &module_list + + +odoo_instances: + - name: "server" + database: "server" + modules: - "hr_holidays" - "timesheet" - "hr" - -odoo_instances: - - name: "server" - host: "10.1.1.34" - port: 8069 - database: "server" - modules: *module_list <<: *common # Inherit common settings - name: "server2" - host: "10.1.1.34" - port: 8069 database: "server2" - modules: *module_list + modules: + - "crm" + - "project" + - "contacts" + - "hr_holidays" <<: *common # Inherit common settings \ No newline at end of file diff --git a/scripts/__init__.py b/scripts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/module.py b/scripts/module.py new file mode 100644 index 0000000..5e6b2e4 --- /dev/null +++ b/scripts/module.py @@ -0,0 +1,20 @@ +import argparse +import os +import subprocess +import sys + +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))) +from services import config as Config + + +def main(): + config = Config.Config(config_path="utility/config/settings.yaml") + instances = config.get_instances() + + for instance in instances: + cmd = "python utility/main.py" + subprocess.run(f"{cmd} module uninstall {instance['name']}", shell=True) + + +if __name__ == "__main__": + main() diff --git a/services/odoo/database.py b/services/odoo/database.py index e69de29..1f4c5c2 100644 --- a/services/odoo/database.py +++ b/services/odoo/database.py @@ -0,0 +1,36 @@ +from services.odoo.connection import OdooConnection + + +class OdooDatabaseManager: + def __init__(self, config_path: str = "config/settings.yaml"): + self.config = OdooConnection(config_path) + + def get_databases(self, instance_name: str = None) -> list: + """Get a list of databases for a specific Odoo instance.""" + print("Fetching databases...") + + def drop_database(self, instance_name: str, db_name: str) -> None: + """Drop a specific database from the Odoo instance.""" + print(f"Dropping database {db_name} from instance {instance_name}...") + + def create_database( + self, instance_name: str, db_name: str, demo: bool = False + ) -> None: + """Create a new database for the Odoo instance.""" + print(f"Creating database {db_name} for instance {instance_name}...") + + def backup_database(self, instance_name: str, db_name: str) -> None: + """Backup a specific database from the Odoo instance.""" + print(f"Backing up database {db_name} from instance {instance_name}...") + + def restore_database( + self, instance_name: str, db_name: str, backup_file: str + ) -> None: + """Restore a database from a backup file.""" + print(f"Restoring database {db_name} for instance {instance_name}...") + + def duplicate_database( + self, instance_name: str, source_db: str, target_db: str + ) -> None: + """Duplicate a database in the Odoo instance.""" + print(f"Duplicating database {source_db} to {target_db}...") diff --git a/services/odoo/module.py b/services/odoo/module.py index 10541a8..9af5187 100644 --- a/services/odoo/module.py +++ b/services/odoo/module.py @@ -1,6 +1,5 @@ from services.git.handler import GitHandler from services.odoo.connection import OdooConnection -import subprocess import lib.color_log as color_log