a
This commit is contained in:
parent
d18df6f801
commit
a64b411ad4
14 changed files with 3 additions and 103 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33
app/abk.py
33
app/abk.py
|
|
@ -1,33 +0,0 @@
|
|||
import subprocess
|
||||
import os
|
||||
|
||||
from pipfile import Pipfile
|
||||
|
||||
|
||||
def globally_installed_py_packages():
|
||||
output = subprocess.check_output("pip list --format freeze".split(), env={})
|
||||
output = output.decode("utf-8")
|
||||
output = output.strip()
|
||||
global_packages = output.split("\n")
|
||||
return global_packages
|
||||
|
||||
|
||||
global_packages = globally_installed_py_packages()
|
||||
|
||||
name = "cow"
|
||||
p = Pipfile.load(filename=name)
|
||||
content = ""
|
||||
with open(name, "r") as f:
|
||||
content = f.read()
|
||||
|
||||
for pip_package in p.data["default"]:
|
||||
version = p.data["default"][pip_package]
|
||||
if version == "*":
|
||||
for package in global_packages:
|
||||
package = package.lower()
|
||||
if package.startswith(pip_package.lower()):
|
||||
substr = f'{pip_package} = "*"'
|
||||
content = content.replace(substr, package)
|
||||
|
||||
with open(name, "w") as f:
|
||||
f.write(content)
|
||||
28
app/ceph.py
28
app/ceph.py
|
|
@ -1,28 +0,0 @@
|
|||
import click
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
@click.group()
|
||||
def ceph():
|
||||
pass
|
||||
|
||||
|
||||
@ceph.command("setup")
|
||||
@click.option("--ceph_url", required=True)
|
||||
@click.option("--ssh_username", required=True)
|
||||
def setup(ceph_url, ssh_username):
|
||||
try:
|
||||
os.makedirs("/etc/ceph", exist_ok=True)
|
||||
command = f"sftp -b ./ceph_batch_cmd {ssh_username}@{ceph_url}:/etc/ceph"
|
||||
subprocess.check_output(command.split())
|
||||
except Exception:
|
||||
p = subprocess.check_output(f"ssh-keyscan {ceph_url}".split())
|
||||
keys = p.decode("utf-8").strip().split("\n")
|
||||
keys = "\n".join(keys)
|
||||
with open(os.path.expanduser("~/.ssh/known_hosts"), "a") as known_hosts:
|
||||
known_hosts.write(keys)
|
||||
|
||||
os.makedirs("/etc/ceph", exist_ok=True)
|
||||
command = f"sftp -b ./ceph_batch_cmd {ssh_username}@{ceph_url}:/etc/ceph"
|
||||
subprocess.check_output(command.split())
|
||||
Loading…
Add table
Add a link
Reference in a new issue