ssh-key input parameter allowed
This commit is contained in:
parent
7c5adf8517
commit
a0fd38e966
@ -10,4 +10,4 @@ echo "--------------------------------------------------------------------------
|
|||||||
echo " Success! I guess..."
|
echo " Success! I guess..."
|
||||||
echo "############################"
|
echo "############################"
|
||||||
echo "Let's spawn some new machines!"
|
echo "Let's spawn some new machines!"
|
||||||
python just_do_everything.py --create
|
python just_do_everything.py $1 --create
|
@ -95,18 +95,17 @@ def create_client(creds_path):
|
|||||||
return client
|
return client
|
||||||
|
|
||||||
|
|
||||||
def load_key(key_folder, pub_key_name):
|
def load_key(pub_key_path):
|
||||||
home_path = Path.home().joinpath(key_folder, pub_key_name)
|
print(f"\t\tUsing the {pub_key_path} file")
|
||||||
print(f"\t\tUsing the {home_path} file")
|
with open(pub_key_path) as f:
|
||||||
with open(home_path) as f:
|
|
||||||
key = f.readline()
|
key = f.readline()
|
||||||
print("\t\tThe SSH KEY has been LOADED")
|
print("\t\tThe SSH KEY has been LOADED")
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
|
||||||
def create_key(client, key_name, key_folder, pub_key_name):
|
def create_key(client, key_name, pub_key_path):
|
||||||
print("The SSH KEY has been...")
|
print("The SSH KEY has been...")
|
||||||
key_of_power = load_key(key_folder, pub_key_name)
|
key_of_power = load_key(pub_key_path)
|
||||||
key = client.ssh_keys.create(name=key_name, public_key=key_of_power)
|
key = client.ssh_keys.create(name=key_name, public_key=key_of_power)
|
||||||
print("\tCREATED")
|
print("\tCREATED")
|
||||||
return key
|
return key
|
||||||
@ -231,10 +230,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
client = create_client("../tokens/token_file")
|
client = create_client("../tokens/token_file")
|
||||||
|
|
||||||
|
ssh_path = sys.argv[-2]
|
||||||
action = sys.argv[-1]
|
action = sys.argv[-1]
|
||||||
|
|
||||||
if action == "--create":
|
if action == "--create":
|
||||||
ssh_key = create_key(client, key_name, ".ssh", "id_ed25519.pub")
|
ssh_key = create_key(client, key_name, ssh_path)
|
||||||
vnet = create_network(client, net_name, "10.10.10.0/24")
|
vnet = create_network(client, net_name, "10.10.10.0/24")
|
||||||
volume = create_volume(client, volume_name, location)
|
volume = create_volume(client, volume_name, location)
|
||||||
db = create_db(client, db_name, ssh_key, vnet, location, INIT_DB_CONTENT)
|
db = create_db(client, db_name, ssh_key, vnet, location, INIT_DB_CONTENT)
|
||||||
|
Loading…
Reference in New Issue
Block a user