update
This commit is contained in:
parent
fc8e53bd67
commit
fdf854d6d4
0
cli/database.py
Normal file
0
cli/database.py
Normal file
@ -1,36 +1,33 @@
|
||||
common: &common
|
||||
username: "<username>"
|
||||
password: "<password>"
|
||||
type: "<service_type>"
|
||||
service_name: "<service_name>"
|
||||
git: &git_config
|
||||
repo_url: "<git_repo_url>"
|
||||
branch: "<branch_name>"
|
||||
local_path: "<local_git_path>"
|
||||
ssh: &ssh_config
|
||||
user: <ssh_user>
|
||||
key_path: "<ssh_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: "<instance_name_1>"
|
||||
host: "<instance_host_1>"
|
||||
port: <instance_port_1>
|
||||
database: "<instance_database_1>"
|
||||
modules:
|
||||
- "<module_1>"
|
||||
- "<module_2>"
|
||||
- "<module_3>"
|
||||
<<: *common # Inherit common settings
|
||||
|
||||
- name: "<instance_name_2>"
|
||||
host: "<instance_host_2>"
|
||||
port: <instance_port_2>
|
||||
database: "<instance_database_2>"
|
||||
modules:
|
||||
- "<module_4>"
|
||||
- "<module_5>"
|
||||
- "<module_6>"
|
||||
<<: *common # Inherit common settings
|
||||
|
@ -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
|
0
scripts/__init__.py
Normal file
0
scripts/__init__.py
Normal file
20
scripts/module.py
Normal file
20
scripts/module.py
Normal file
@ -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()
|
@ -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}...")
|
@ -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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user