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
AutoDatabaseGenerator/
# Python things
__pycache__/

View File

@ -37,31 +37,39 @@ class AdgClient:
return [x.replace("INFO|", "") for x in skip_footer]
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:
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 = "",
host_name: str = ""):
if not name:
name = self.system_name
else:
self.set_system_name(name)
extra_args = []
if switch_ip:
extra_args.append(f"-a {switch_ip}")
extra_args += ["-a", f"{switch_ip}"]
if host_name:
extra_args.append(f"-h {host_name}")
extra_args += ["-h", f"{host_name}"]
res = self._run(["csd",
f"-n {name}",
f"-d {name}",
"-s", f"{name}",
"-d", f"{name}",
*extra_args])
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,
location: int, envelope: int,
driver_path: str, package_path: str = "",
driver_path: str = "Drivers\\",
package_path: str = "",
driver_description: str = "",
connection_parameters: str = "",
system: str = ""):
@ -75,24 +83,27 @@ class AdgClient:
if not system:
system = self.system_name
if not driver_path:
driver_path = "Drivers\\"
extra_args = []
if package_path:
extra_args.append(f"-p {package_path}")
extra_args += ["-p", f"{package_path}"]
elif driver_description:
extra_args.append(f"-r {driver_description}")
extra_args += ["-r", f"{driver_description}"]
if connection_parameters:
extra_args.append(f"-c {connection_parameters}")
res = self._run(["cnr",
f"-s {system}",
f"-n {name}",
f"-l {location}",
f"-e {envelope}",
f"-d {driver_path}", *extra_args])
"-s", f"{system}",
"-n", f"{name}",
"-l", f"{location}",
"-e", f"{envelope}",
"-d", f"{driver_path}", *extra_args])
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,
location: int, envelope: int,
@ -103,22 +114,25 @@ class AdgClient:
system = self.system_name
res = self._run(["csr",
f"-s {system}",
f"-n {name}",
f"-l {location}",
f"-e {envelope}",
"-p platehotel"])
"-s", f"{system}",
"-n", f"{name}",
"-l", f"{location}",
"-e", f"{envelope}",
"-p", "platehotel"])
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:
storage_res = self._run(["crs",
f"-s {system}",
f"-n {name}",
f"-r {rows}",
f"-t {type}"])
"-s", f"{system}",
"-n", f"{name}",
"-r", f"{rows}",
"-t", f"{type}"])
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:
MAX_ATTEMPTS = 100