Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayfly277 committed Sep 29, 2024
1 parent 6ab9542 commit c98989a
Show file tree
Hide file tree
Showing 16 changed files with 13 additions and 51 deletions.
1 change: 0 additions & 1 deletion goad.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
import time
from goad.config import Config
from goad.jumpbox import JumpBox
from goad.lab_manager import LabManager
from goad.menu import print_menu, print_logo
from goad.labs import *
Expand Down
3 changes: 1 addition & 2 deletions goad/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from rich import print
import configparser
from goad.goadpath import GoadPath
from goad.utils import *
Expand Down Expand Up @@ -30,7 +29,7 @@ def create_config_file(self):
config.set('default', '; provider : virtualbox / vmware / aws / azure / proxmox')
config.set('default', 'provider', 'vmware')

config.set('default', "; provisioner method : local / runner / remote")
config.set('default', "; provisioner method : local / remote")
config.set('default', 'provisioner', 'local')

config.set('default', '; ip_range (3 first ip digits)')
Expand Down
2 changes: 0 additions & 2 deletions goad/goadpath.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os
from pathlib import Path
from goad.utils import *

sep = os.path.sep
Expand Down
13 changes: 4 additions & 9 deletions goad/instance.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import json
import os
import shutil
import string
import random
from jinja2 import Template, Environment, FileSystemLoader
from rich.table import Table
from rich import print
from goad.goadpath import *
from goad.jumpbox import JumpBox
from goad.log import Log
from goad.exceptions import ProviderPathNotFound, JumpBoxInitFailed
from goad.provisioner.ansible.local import LocalAnsibleProvisionerCmd
from goad.provisioner.ansible.runner import LocalAnsibleProvisionerEmbed
# from goad.provisioner.ansible.runner import LocalAnsibleProvisionerEmbed
from goad.provisioner.ansible.remote import RemoteAnsibleProvisioner


Expand Down Expand Up @@ -70,13 +65,13 @@ def load(self, labs, creation=False):

self.provider.set_instance_path(self.instance_provider_path)

if self.provisioner_name == PROVISIONING_RUNNER:
self.provisioner = LocalAnsibleProvisionerEmbed(self.lab_name, self.provider)
elif self.provisioner_name == PROVISIONING_LOCAL:
if self.provisioner_name == PROVISIONING_LOCAL:
self.provisioner = LocalAnsibleProvisionerCmd(self.lab_name, self.provider)
elif self.provisioner_name == PROVISIONING_REMOTE:
self.provisioner = RemoteAnsibleProvisioner(self.lab_name, self.provider)
self.provisioner.jumpbox = JumpBox(self, creation)
# elif self.provisioner_name == PROVISIONING_RUNNER:
# self.provisioner = LocalAnsibleProvisionerEmbed(self.lab_name, self.provider)

if self.provisioner is None:
Log.error('instance provisioner does not exist')
Expand Down
12 changes: 0 additions & 12 deletions goad/jumpbox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import platform
from goad.command.linux import LinuxCommand
from goad.command.windows import WindowsCommand
from goad.exceptions import JumpBoxInitFailed
from goad.log import Log
from goad.utils import *
from goad.goadpath import GoadPath
Expand Down Expand Up @@ -70,17 +69,6 @@ def sync_sources(self):
else:
Log.error('Can not sync source jumpbox ip is invalid')

# # sync sources:
# # ansible/
# # ad/<lab>/
# # scripts/
# # workspace/<instance_id>/
# # globalsettings.ini
# sources = [GoadPath.get_provisioner_path(), GoadPath.get_lab_path(self.lab_name), GoadPath.get_script_path(), self.instance_path, GoadPath.get_global_inventory_path()]
# destination = f'{self.username}@{self.ip}:~/GOAD/'
# for source in sources:
# self.command.scp(source, destination + Utils.get_relative_path(source), self.ssh_key)

def run_command(self, command, path):
ssh_cmd = f"ssh -t -o 'StrictHostKeyChecking no' -i {self.ssh_key} {self.username}@{self.ip} 'cd {path} && {command}'"
result = self.command.run_command(ssh_cmd, project_path)
Expand Down
5 changes: 1 addition & 4 deletions goad/provider/provider.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from abc import ABC
from goad.config import Config
import os
import platform
from goad.command.linux import LinuxCommand
from goad.command.windows import WindowsCommand
from goad.utils import *
from goad.log import Log


class Provider(ABC):
lab_name = ''
provider_name = None
default_provisioner = PROVISIONING_LOCAL
allowed_provisioners = [PROVISIONING_LOCAL, PROVISIONING_RUNNER, PROVISIONING_REMOTE]
allowed_provisioners = ALLOWED_PROVISIONER
use_jumpbox = False

def __init__(self, lab_name):
Expand Down
1 change: 0 additions & 1 deletion goad/provider/terraform/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from rich import print
from azure.identity import DefaultAzureCredential
from azure.core.exceptions import ClientAuthenticationError
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient

Expand Down
2 changes: 1 addition & 1 deletion goad/provider/terraform/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class ProxmoxProvider(TerraformProvider):
provider_name = PROXMOX
default_provisioner = PROVISIONING_LOCAL
allowed_provisioners = [PROVISIONING_LOCAL, PROVISIONING_RUNNER, PROVISIONING_REMOTE]
allowed_provisioners = PROXMOX_ALLOWED_PROVISIONER

def check(self):
check_disk = self.command.check_disk()
Expand Down
4 changes: 0 additions & 4 deletions goad/provider/vagrant/vagrant.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import os
import shutil
from goad.provider.provider import Provider
from goad.log import Log
from goad.goadpath import GoadPath


class VagrantProvider(Provider):
Expand Down
2 changes: 1 addition & 1 deletion goad/provider/vagrant/virtualbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class VirtualboxProvider(VagrantProvider):
provider_name = VIRTUALBOX
default_provisioner = PROVISIONING_LOCAL
allowed_provisioners = [PROVISIONING_LOCAL, PROVISIONING_RUNNER]
allowed_provisioners = VIRTUALBOX_ALLOWED_PROVISIONER

def check(self):
super_check = super().check()
Expand Down
2 changes: 1 addition & 1 deletion goad/provider/vagrant/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class VmwareProvider(VagrantProvider):
provider_name = VMWARE
default_provisioner = PROVISIONING_LOCAL
allowed_provisioners = [PROVISIONING_LOCAL, PROVISIONING_RUNNER]
allowed_provisioners = VMWARE_ALLOWED_PROVISIONER

def check(self):
super_check = super().check()
Expand Down
4 changes: 0 additions & 4 deletions goad/provisioner/ansible/local.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import time

import ansible_runner

from goad.log import Log
from goad.utils import *
from goad.provisioner.ansible.ansible import Ansible
Expand Down
2 changes: 0 additions & 2 deletions goad/provisioner/ansible/remote.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from goad.jumpbox import JumpBox
from goad.log import Log
from goad.provisioner.ansible.ansible import Ansible
from goad.exceptions import JumpBoxInitFailed
from goad.utils import *


Expand Down
2 changes: 0 additions & 2 deletions goad/provisioner/provisioner.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from abc import ABC
from goad.config import Config
import os
import platform
from goad.command.linux import LinuxCommand
from goad.command.windows import WindowsCommand
Expand Down
8 changes: 4 additions & 4 deletions goad/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
PROVISIONING_LOCAL = 'local'
PROVISIONING_RUNNER = 'runner'
PROVISIONING_REMOTE = 'remote'
ALLOWED_PROVISIONER = [PROVISIONING_LOCAL, PROVISIONING_RUNNER, PROVISIONING_REMOTE]
ALLOWED_PROVISIONER = [PROVISIONING_LOCAL, PROVISIONING_REMOTE]

# provisioner allowed
AWS_ALLOWED_PROVISIONER = [PROVISIONING_REMOTE]
AZURE_ALLOWED_PROVISIONER = [PROVISIONING_REMOTE]
PROXMOX_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL, PROVISIONING_RUNNER]
VMWARE_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL, PROVISIONING_RUNNER]
VIRTUALBOX_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL, PROVISIONING_RUNNER]
PROXMOX_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL]
VMWARE_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL]
VIRTUALBOX_ALLOWED_PROVISIONER = [PROVISIONING_LOCAL]

project_path = os.path.normpath(os.path.dirname(os.path.abspath(__file__)) + os.path.sep + '..')

Expand Down
1 change: 0 additions & 1 deletion requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ansible-core==2.12.6
pywinrm
# AZURE
azure-identity
azure-mgmt-resource
azure-mgmt-compute
azure-mgmt-network
# AWS
Expand Down

0 comments on commit c98989a

Please sign in to comment.