vm-tool 1.0.13__tar.gz → 1.0.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {vm_tool-1.0.13/vm_tool.egg-info → vm_tool-1.0.14}/PKG-INFO +1 -1
- {vm_tool-1.0.13 → vm_tool-1.0.14}/setup.py +1 -1
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/cli.py +1 -1
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/ssh.py +12 -12
- {vm_tool-1.0.13 → vm_tool-1.0.14/vm_tool.egg-info}/PKG-INFO +1 -1
- {vm_tool-1.0.13 → vm_tool-1.0.14}/LICENSE +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/MANIFEST.in +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/README.md +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/setup.cfg +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/__init__.py +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/runner.py +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/vm_setup/cloud_inventory.yml +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/vm_setup/docker/create_docker_service.yml +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/vm_setup/docker/install_docker_and_compose.yml +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/vm_setup/inventory.yml +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool/vm_setup/setup.yml +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool.egg-info/SOURCES.txt +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool.egg-info/dependency_links.txt +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool.egg-info/entry_points.txt +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool.egg-info/requires.txt +0 -0
- {vm_tool-1.0.13 → vm_tool-1.0.14}/vm_tool.egg-info/top_level.txt +0 -0
|
@@ -11,7 +11,7 @@ else:
|
|
|
11
11
|
|
|
12
12
|
setup(
|
|
13
13
|
name='vm_tool',
|
|
14
|
-
version='1.0.
|
|
14
|
+
version='1.0.14', # This will be updated by bump2version
|
|
15
15
|
packages=find_packages(),
|
|
16
16
|
description='A Comprehensive Tool for Setting Up Virtual Machines Using Ansible.',
|
|
17
17
|
long_description=long_description,
|
|
@@ -2,7 +2,7 @@ import argparse
|
|
|
2
2
|
|
|
3
3
|
def main():
|
|
4
4
|
parser = argparse.ArgumentParser(description='Setup VMs using Ansible.')
|
|
5
|
-
parser.add_argument('--version', action='version', version='1.0.
|
|
5
|
+
parser.add_argument('--version', action='version', version='1.0.14')
|
|
6
6
|
|
|
7
7
|
args = parser.parse_args()
|
|
8
8
|
|
|
@@ -32,7 +32,7 @@ class SSHSetup:
|
|
|
32
32
|
self.client = paramiko.SSHClient()
|
|
33
33
|
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
34
34
|
|
|
35
|
-
def
|
|
35
|
+
def __generate_ssh_key(self, email):
|
|
36
36
|
"""
|
|
37
37
|
Generates an SSH key pair.
|
|
38
38
|
|
|
@@ -42,7 +42,7 @@ class SSHSetup:
|
|
|
42
42
|
print(f"Generating SSH key for email: {email}")
|
|
43
43
|
os.system(f'ssh-keygen -t rsa -b 4096 -C "{email}"')
|
|
44
44
|
|
|
45
|
-
def
|
|
45
|
+
def __read_or_generate_public_key(self, email):
|
|
46
46
|
"""
|
|
47
47
|
Reads the public SSH key or generates a new one if it doesn't exist.
|
|
48
48
|
|
|
@@ -54,12 +54,12 @@ class SSHSetup:
|
|
|
54
54
|
"""
|
|
55
55
|
public_key_path = f'{self.private_key_path}.pub'
|
|
56
56
|
if not os.path.exists(public_key_path):
|
|
57
|
-
self.
|
|
57
|
+
self.__generate_ssh_key(email)
|
|
58
58
|
with open(public_key_path, 'r') as file:
|
|
59
59
|
print(f"Reading public key from {public_key_path}")
|
|
60
60
|
return file.read()
|
|
61
61
|
|
|
62
|
-
def
|
|
62
|
+
def __configure_vm(self, vm_ip, vm_password, public_key):
|
|
63
63
|
"""
|
|
64
64
|
Configures the VM by adding the public SSH key to the authorized keys.
|
|
65
65
|
|
|
@@ -73,7 +73,7 @@ class SSHSetup:
|
|
|
73
73
|
self.client.exec_command(f'echo "{public_key}" >> ~/.ssh/authorized_keys')
|
|
74
74
|
self.client.close()
|
|
75
75
|
|
|
76
|
-
def
|
|
76
|
+
def __update_ssh_config(self):
|
|
77
77
|
"""
|
|
78
78
|
Updates the local SSH config file with the VM details.
|
|
79
79
|
"""
|
|
@@ -89,14 +89,14 @@ Host {self.hostname}
|
|
|
89
89
|
with open(f'{os.path.expanduser("~")}/.ssh/config', 'a') as file:
|
|
90
90
|
file.write(config)
|
|
91
91
|
|
|
92
|
-
def
|
|
92
|
+
def __establish_connection(self):
|
|
93
93
|
"""
|
|
94
94
|
Establishes an SSH connection to the VM.
|
|
95
95
|
"""
|
|
96
96
|
print(f"Establishing SSH connection to {self.hostname}.")
|
|
97
97
|
self.client.connect(self.hostname, username=self.username, key_filename=self.private_key_path)
|
|
98
98
|
|
|
99
|
-
def
|
|
99
|
+
def __close_connection(self):
|
|
100
100
|
"""
|
|
101
101
|
Closes the SSH connection.
|
|
102
102
|
"""
|
|
@@ -109,9 +109,9 @@ Host {self.hostname}
|
|
|
109
109
|
Sets up the SSH configuration and keys for the VM.
|
|
110
110
|
"""
|
|
111
111
|
print("Starting SSH setup.")
|
|
112
|
-
public_key = self.
|
|
113
|
-
self.
|
|
114
|
-
self.
|
|
115
|
-
self.
|
|
116
|
-
self.
|
|
112
|
+
public_key = self.__read_or_generate_public_key(self.email)
|
|
113
|
+
self.__configure_vm(self.hostname, self.password, public_key)
|
|
114
|
+
self.__update_ssh_config()
|
|
115
|
+
self.__establish_connection()
|
|
116
|
+
self.__close_connection()
|
|
117
117
|
print("SSH setup completed.")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|