the rest of the owl

This commit is contained in:
Emilia Allison 2024-01-09 16:22:43 -05:00
parent c776582b41
commit 3eb104e1e3
Signed by: emilia
GPG Key ID: 05D5D1107E5100A1
2 changed files with 44 additions and 27 deletions

3
.gitignore vendored
View File

@ -5,3 +5,6 @@ token
# ADG itself # ADG itself
AutoDatabaseGenerator/ AutoDatabaseGenerator/
# Python things
__pycache__/

View File

@ -37,31 +37,39 @@ class AdgClient:
return [x.replace("INFO|", "") for x in skip_footer] return [x.replace("INFO|", "") for x in skip_footer]
def create_database(self, name: str): def create_database(self, name: str):
res = self._run(["ccdb", "-u system", "-p oracle", f"-d {name}"]) res = self._run(["ccdb",
"-u", "system",
"-p", "oracle",
"-v", "4",
"-d", f"{name.upper()}"])
if res.returncode > 0: if res.returncode > 0:
raise Exception("Failed to create database") raise Exception("Failed to create database", res.stdout, res.args)
self.set_system_name(name)
def create_system(self, name: str = "", switch_ip: str = "", def create_system(self, name: str = "", switch_ip: str = "",
host_name: str = ""): host_name: str = ""):
if not name: if not name:
name = self.system_name name = self.system_name
else:
self.set_system_name(name)
extra_args = [] extra_args = []
if switch_ip: if switch_ip:
extra_args.append(f"-a {switch_ip}") extra_args += ["-a", f"{switch_ip}"]
if host_name: if host_name:
extra_args.append(f"-h {host_name}") extra_args += ["-h", f"{host_name}"]
res = self._run(["csd", res = self._run(["csd",
f"-n {name}", "-s", f"{name}",
f"-d {name}", "-d", f"{name}",
*extra_args]) *extra_args])
if res.returncode > 0: if res.returncode > 0:
raise Exception("Failed to create system") raise Exception("Failed to create system", res.stdout, res.args)
def create_normal_resource(self, name: str, def create_normal_resource(self, name: str,
location: int, envelope: int, location: int, envelope: int,
driver_path: str, package_path: str = "", driver_path: str = "Drivers\\",
package_path: str = "",
driver_description: str = "", driver_description: str = "",
connection_parameters: str = "", connection_parameters: str = "",
system: str = ""): system: str = ""):
@ -75,24 +83,27 @@ class AdgClient:
if not system: if not system:
system = self.system_name system = self.system_name
if not driver_path:
driver_path = "Drivers\\"
extra_args = [] extra_args = []
if package_path: if package_path:
extra_args.append(f"-p {package_path}") extra_args += ["-p", f"{package_path}"]
elif driver_description: elif driver_description:
extra_args.append(f"-r {driver_description}") extra_args += ["-r", f"{driver_description}"]
if connection_parameters: if connection_parameters:
extra_args.append(f"-c {connection_parameters}") extra_args.append(f"-c {connection_parameters}")
res = self._run(["cnr", res = self._run(["cnr",
f"-s {system}", "-s", f"{system}",
f"-n {name}", "-n", f"{name}",
f"-l {location}", "-l", f"{location}",
f"-e {envelope}", "-e", f"{envelope}",
f"-d {driver_path}", *extra_args]) "-d", f"{driver_path}", *extra_args])
if res.returncode > 0: if res.returncode > 0:
raise Exception("Failed to add resource") raise Exception("Failed to add resource", res.stdout, res.args)
def create_platehotel(self, name: str, def create_platehotel(self, name: str,
location: int, envelope: int, location: int, envelope: int,
@ -103,22 +114,25 @@ class AdgClient:
system = self.system_name system = self.system_name
res = self._run(["csr", res = self._run(["csr",
f"-s {system}", "-s", f"{system}",
f"-n {name}", "-n", f"{name}",
f"-l {location}", "-l", f"{location}",
f"-e {envelope}", "-e", f"{envelope}",
"-p platehotel"]) "-p", "platehotel"])
if res.returncode > 0: if res.returncode > 0:
raise Exception("Failed to create platehotel") raise Exception("Failed to create platehotel",
res.stdout, res.args)
if type and rows > 0: if type and rows > 0:
storage_res = self._run(["crs", storage_res = self._run(["crs",
f"-s {system}", "-s", f"{system}",
f"-n {name}", "-n", f"{name}",
f"-r {rows}", "-r", f"{rows}",
f"-t {type}"]) "-t", f"{type}"])
if storage_res.returncode > 0: if storage_res.returncode > 0:
raise Exception("Failed to add storage to platehotel") raise Exception("Failed to add storage to platehotel",
storage_res.stdout,
storage_res.args)
def _create_unique_database_name(self, prefix: str) -> str: def _create_unique_database_name(self, prefix: str) -> str:
MAX_ATTEMPTS = 100 MAX_ATTEMPTS = 100