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:
|
odoo_instances:
|
||||||
- name: "ftacpa"
|
- name: "<instance_name_1>"
|
||||||
host: "10.1.1.31"
|
host: "<instance_host_1>"
|
||||||
port: 8069
|
port: <instance_port_1>
|
||||||
database: "ftacpa"
|
database: "<instance_database_1>"
|
||||||
username: "nextzen"
|
modules:
|
||||||
password: "smartyourlife"
|
- "<module_1>"
|
||||||
type: "systemctl"
|
- "<module_2>"
|
||||||
service_name: "odoo18"
|
- "<module_3>"
|
||||||
git:
|
<<: *common # Inherit common settings
|
||||||
repo_url: "https://hoangvv:smartyourlife@git.nextzenos.com/NextERP/Odoo18-FTACPA.git"
|
|
||||||
branch: "community/demo/ftacpa"
|
- name: "<instance_name_2>"
|
||||||
local_path: "/opt/odoo18/addons"
|
host: "<instance_host_2>"
|
||||||
ssh:
|
port: <instance_port_2>
|
||||||
user: root
|
database: "<instance_database_2>"
|
||||||
key_path: "/root/.ssh/privatessh.key"
|
modules:
|
||||||
# - name: "server1_test"
|
- "<module_4>"
|
||||||
# host: "server1.example.com"
|
- "<module_5>"
|
||||||
# port: 8069
|
- "<module_6>"
|
||||||
# database: "test_db1"
|
<<: *common # Inherit common settings
|
||||||
# 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"
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
common: &common
|
common: &common
|
||||||
|
host: "10.1.1.34"
|
||||||
|
port: 8069
|
||||||
username: "nextzen"
|
username: "nextzen"
|
||||||
password: "smartyourlife"
|
password: "smartyourlife"
|
||||||
type: "systemctl"
|
type: "systemctl"
|
||||||
@ -10,22 +12,22 @@ common: &common
|
|||||||
ssh: &ssh_config
|
ssh: &ssh_config
|
||||||
user: root
|
user: root
|
||||||
key_path: "/root/.ssh/privatessh.key"
|
key_path: "/root/.ssh/privatessh.key"
|
||||||
modules: &module_list
|
|
||||||
|
|
||||||
|
odoo_instances:
|
||||||
|
- name: "server"
|
||||||
|
database: "server"
|
||||||
|
modules:
|
||||||
- "hr_holidays"
|
- "hr_holidays"
|
||||||
- "timesheet"
|
- "timesheet"
|
||||||
- "hr"
|
- "hr"
|
||||||
|
|
||||||
odoo_instances:
|
|
||||||
- name: "server"
|
|
||||||
host: "10.1.1.34"
|
|
||||||
port: 8069
|
|
||||||
database: "server"
|
|
||||||
modules: *module_list
|
|
||||||
<<: *common # Inherit common settings
|
<<: *common # Inherit common settings
|
||||||
|
|
||||||
- name: "server2"
|
- name: "server2"
|
||||||
host: "10.1.1.34"
|
|
||||||
port: 8069
|
|
||||||
database: "server2"
|
database: "server2"
|
||||||
modules: *module_list
|
modules:
|
||||||
|
- "crm"
|
||||||
|
- "project"
|
||||||
|
- "contacts"
|
||||||
|
- "hr_holidays"
|
||||||
<<: *common # Inherit common settings
|
<<: *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.git.handler import GitHandler
|
||||||
from services.odoo.connection import OdooConnection
|
from services.odoo.connection import OdooConnection
|
||||||
import subprocess
|
|
||||||
import lib.color_log as color_log
|
import lib.color_log as color_log
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user