From da38ee1c758813a244b74cb59d2c365b3dbc4459 Mon Sep 17 00:00:00 2001 From: Charles N Wyble Date: Mon, 16 Dec 2024 09:45:53 -0600 Subject: [PATCH] First bits of client code from the monolith refactor --- .../HyperV-LifeCycle-CreateAndDestroy/stub | 1 + Lifecycle-Virtual/HyperV-LifeCycle-PowerMgmt/stub | 1 + .../KVM-LifeCycle-PowerMgmt/kvm-PowerCycle.sh | 12 ++++++++++++ .../KVM-LifeCycle-PowerMgmt/kvm-PowerOff.sh | 11 +++++++++++ .../KVM-LifeCycle-PowerMgmt/kvm-PowerOn.sh | 10 ++++++++++ .../esxi-delete.ps1 | 11 +++++++++++ .../esxi-resource-limit.ps1 | 12 ++++++++++++ .../VmWare-LifeCycle-PowerMgmt/README.md | 1 + .../VmWare-LifeCycle-PowerMgmt/esxi-PowerCycle.ps1 | 12 ++++++++++++ .../VmWare-LifeCycle-PowerMgmt/esxi-PowerOff.ps1 | 11 +++++++++++ .../VmWare-LifeCycle-PowerMgmt/esxi-PowerOn.ps1 | 11 +++++++++++ createLxc.sh => Provision-Container/createLxc.sh | 0 12 files changed, 93 insertions(+) create mode 100644 Lifecycle-Virtual/HyperV-LifeCycle-CreateAndDestroy/stub create mode 100644 Lifecycle-Virtual/HyperV-LifeCycle-PowerMgmt/stub create mode 100644 Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerCycle.sh create mode 100644 Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOff.sh create mode 100644 Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOn.sh create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-delete.ps1 create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-resource-limit.ps1 create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/README.md create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerCycle.ps1 create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOff.ps1 create mode 100644 Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOn.ps1 rename createLxc.sh => Provision-Container/createLxc.sh (100%) diff --git a/Lifecycle-Virtual/HyperV-LifeCycle-CreateAndDestroy/stub b/Lifecycle-Virtual/HyperV-LifeCycle-CreateAndDestroy/stub new file mode 100644 index 0000000..f0b8111 --- /dev/null +++ b/Lifecycle-Virtual/HyperV-LifeCycle-CreateAndDestroy/stub @@ -0,0 +1 @@ +Merge hyperv code from monolith \ No newline at end of file diff --git a/Lifecycle-Virtual/HyperV-LifeCycle-PowerMgmt/stub b/Lifecycle-Virtual/HyperV-LifeCycle-PowerMgmt/stub new file mode 100644 index 0000000..fe9b50f --- /dev/null +++ b/Lifecycle-Virtual/HyperV-LifeCycle-PowerMgmt/stub @@ -0,0 +1 @@ +Merge Hyperv-V code from monolith \ No newline at end of file diff --git a/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerCycle.sh b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerCycle.sh new file mode 100644 index 0000000..5cb212f --- /dev/null +++ b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerCycle.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +VMHOSTFULL="$1" +USER_SUPPLIED_VMNAME="$2" +SSH_ALIAS="ssh -q" + +VIRSH_ALIAS="virsh -c qemu+ssh://root@$VMHOSTFULL/system?no_verify=1" + + + +$VIRSH_ALIAS destroy $USER_SUPPLIED_VMNAME +$VIRSH_ALIAS start $USER_SUPPLIED_VMNAME \ No newline at end of file diff --git a/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOff.sh b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOff.sh new file mode 100644 index 0000000..cec39f7 --- /dev/null +++ b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOff.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +VMHOSTFULL="$1" +USER_SUPPLIED_VMNAME="$2" +SSH_ALIAS="ssh -q" + +VIRSH_ALIAS="virsh -c qemu+ssh://root@$VMHOSTFULL/system?no_verify=1" + + + +$VIRSH_ALIAS destroy $USER_SUPPLIED_VMNAME \ No newline at end of file diff --git a/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOn.sh b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOn.sh new file mode 100644 index 0000000..93462d5 --- /dev/null +++ b/Lifecycle-Virtual/KVM-LifeCycle-PowerMgmt/kvm-PowerOn.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +VMHOSTFULL="$1" +USER_SUPPLIED_VMNAME="$2" +SSH_ALIAS="ssh -q" + +VIRSH_ALIAS="virsh -c qemu+ssh://root@$VMHOSTFULL/system?no_verify=1" + + +$VIRSH_ALIAS start $USER_SUPPLIED_VMNAME \ No newline at end of file diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-delete.ps1 b/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-delete.ps1 new file mode 100644 index 0000000..84e304d --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-delete.ps1 @@ -0,0 +1,11 @@ +param( +[string]$vcenter, +[string]$vm, +[string]$un, +[string]$pw +) + +Get-Module -ListAvailable PowerCLI* | Import-Module -Verbose:$false > /dev/null +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false > /dev/null +Connect-ViServer -Server $vcenter -User "$un" -Password "$pw" -Verbose:$false > /dev/null +Remove-VM -VM $vm -DeleteFromDisk -Confirm:$false -Verbose:$false > /dev/null \ No newline at end of file diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-resource-limit.ps1 b/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-resource-limit.ps1 new file mode 100644 index 0000000..ad9730b --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-CreateAndDestroy/esxi-resource-limit.ps1 @@ -0,0 +1,12 @@ +param( +[string]$vcenter, +[string]$vmName, +[string]$un, +[string]$pw +) + +Get-Module -ListAvailable PowerCLI* | Import-Module -Verbose:$false +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false +Connect-ViServer -Server $vcenter -User $un -Password $pw -Verbose:$false + +Get-VM -Name "$vmName" | Get-VMResourceConfiguration |Set-VMResourceConfiguration -CpuLimitMhz 3000 diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/README.md b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/README.md new file mode 100644 index 0000000..c7f0877 --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/README.md @@ -0,0 +1 @@ +Power management for kvm/vmware guests at RackRental/TSYS \ No newline at end of file diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerCycle.ps1 b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerCycle.ps1 new file mode 100644 index 0000000..eb2e77f --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerCycle.ps1 @@ -0,0 +1,12 @@ +param( +[string]$vcenter, +[string]$vm, +[string]$un, +[string]$pw +) + +Get-Module -ListAvailable PowerCLI* | Import-Module -Verbose:$false > /dev/null +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false > /dev/null +Connect-ViServer -Server $vcenter -User "$un" -Password "$pw" -Verbose:$false > /dev/null +Stop-VM -RunAsync -VM "$vm" -Confirm:$false -Verbose:$false > /dev/null +Start-VM -RunAsync -VM "$vm" -Confirm:$false -Verbose:$false > /dev/null \ No newline at end of file diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOff.ps1 b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOff.ps1 new file mode 100644 index 0000000..afef9e8 --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOff.ps1 @@ -0,0 +1,11 @@ +param( +[string]$vcenter, +[string]$vm, +[string]$un, +[string]$pw +) + +Get-Module -ListAvailable PowerCLI* | Import-Module -Verbose:$false > /dev/null +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false > /dev/null +Connect-ViServer -Server $vcenter -User "$un" -Password "$pw" -Verbose:$false > /dev/null +Stop-VM -RunAsync -VM "$vm" -Confirm:$false -Verbose:$false > /dev/null diff --git a/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOn.ps1 b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOn.ps1 new file mode 100644 index 0000000..48e924c --- /dev/null +++ b/Lifecycle-Virtual/VmWare-LifeCycle-PowerMgmt/esxi-PowerOn.ps1 @@ -0,0 +1,11 @@ +param( +[string]$vcenter, +[string]$vm, +[string]$un, +[string]$pw +) + +Get-Module -ListAvailable PowerCLI* | Import-Module -Verbose:$false > /dev/null +Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false > /dev/null +Connect-ViServer -Server $vcenter -User "$un" -Password "$pw" -Verbose:$false > /dev/null +Start-VM -RunAsync -VM "$vm" -Confirm:$false -Verbose:$false > /dev/null \ No newline at end of file diff --git a/createLxc.sh b/Provision-Container/createLxc.sh similarity index 100% rename from createLxc.sh rename to Provision-Container/createLxc.sh