Milestone 4.1 Automation with pyvmomi - Oliver-Mustoe/Oliver-Mustoe-Tech-Journal GitHub Wiki
This page journals content related to SYS-350 milestone 3.
Table of Contents:
pfSense Open VM Tools install
(NOTE: Installed VSCode first but not used till later so it was moved into the VSCode setup area.)
On mgmt1 I went to https://10.0.17.2
in the browser:
Then I went to "System" > "Package Manager" > "Available Packages":
Then I searched for vmware and pressed to install and confirmed the "Open-VM-Tools" install:
Package installed:
VSCode setup
First I installed visual studio code on mgmt1 with:
sudo snap install code --classic
Then I opened VScode via the search bar:
Then in a terminal I installed python3-pip and pyvmomi:
sudo apt update
sudo apt install python3-pip -y
pip3 install wheel
pip3 install pyvmomi
pip3 install pyvim
And then I cloned my git repository:
sudo apt install git -y
git clone https://github.com/Oliver-Mustoe/Oliver-Mustoe-Tech-Journal.git
As well I opened the folder with CTRL+K
and then CTRL+O
in VSCode (folder shown selected below):
I would create a folder for SYS-350 (as well opened a terminal with CTRL+SHIFT+`):
Inside the VScode terminal, tested out my pyvmomi connection:
From the extensions I would then install the Python extension;
I would then work on the lab - using git to continually save (when I used the VScode terminal to run the standard git commands VScode automatically prompted me for my git user and password, i would fill it out and allowed what VScode asked for so I could use the VScode gui to upload git code.)
I would contain this code in a file called m4reqs.py.
Mgmt1 Open VM Tools setup
I would install open-vm-tools on my mgmt:
sudo apt install open-vm-tools -y
Reflection
This Project as a whole went pretty well for me. I had a fun time exploring the Managed Object Browser and seeing how the different parts of vCenter connected to one another. Using this made the scripting experience fairly easy and it gave me an oppurtunity to brush up on my Python skills. Looking at the examples from pyvmomi community I have been creating a small lib Python file for myself that might make some of the future assignments a little easier (particularly as I adapt and add certain features seen in the communities tools folder.)
Sources
-
https://www.programcreek.com/python/example/102579/pyVim.connect.SmartConnect
-
https://www.vcloudnine.de/first-steps-with-python-and-pyvmomi-vsphere-sdk-for-python/
-
https://stackoverflow.com/questions/39706470/pyvmomi-get-folders-name
-
https://www.geeksforgeeks.org/getpass-and-getuser-in-python-password-without-echo/
-
https://www.freecodecamp.org/news/python-new-line-and-how-to-python-print-without-a-newline/
-
https://stackoverflow.com/questions/9573244/how-to-check-if-the-string-is-empty-in-python