Today I wrote a very interest script to set off a dog running on the shell command line terminal, of course, it is not a real dog (just a symbol formed dog), but I found myself really enjoy writing it and running it.
Purpose you can let it run as a screen saver for your shell command or it could be used as a foreground comedy waiting for the true background work running complete and return you the final results : )
That’s really fun, I enjoy setting it off running on my screen.
The detail code could refer the GitHub link attached below:
First, let’s warm up with some functions about time/date.
The purpose for doing such kind of boring things is for implementation requirements of the scheduler I will use in Windows environment.
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> import time
>>> print(datetime.datetime.now() + datetime.timedelta(minutes=3))
>>> print((datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%Y/%m/%d %H:%M:%S"))
>>> print((datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%H:%M:%S %p"))
>>> print((datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%I:%M:%S %p"))
Another improvement makes to the Image-downloader code.
- Introduced function “Inputchecker” to validate user input
- vaguely match the strings user inputs and try to match with the strings, if not match ask the user to re-type the number
- precisely matching the version number user input using regex
- separately handling onefs and insightiq image name and url path
- get the list of filename from URL path and dump to help the user choose insightiq version to download
Today, for re-use purpose, I re-constructed the first day PowerShell script to improve its scalability and maintainability of the script. To make sure it’s simple and could be used:
Scripts are listing below:
Today continue to share with you the automated scripts to upload ovf image to Vcenter
I implemented this function and sub-function using the following scripts(although there are some duplicate functions call, this will be improved using the same function calls across the entire scripts ):
- Using condition to avoid repeatedly calling and loading VMware modules, using condition to avoid repeatedly inputting the Vcenter host, username and password settings, using condition to escape related condition. Know how to add more conditions to “if-else” sentence to determine whether or not to execute the related scripts
- [string]::IsNullOrWhitespace($Datastore) to determine whether string is null or contains whitespace
- Using Powershell built-in Import-VApp, Get-VMHost to upload ovf to VCenter server or get related information
Wget in Nix world is well knows, it is really convenient to download files to your local path.
Today, when I am considering using another tool in Windows World to download the file from the normalized URL, I also found a tool called “system.net.webclient”. It is quite useful but to my option not as sharp as wget though:
Three implementations were carried out:
1.Download the file
2.Unzip the file to specified directory
3.Convert ova file format to ovf
4. Learn to introduce an indirect variable to import the one of array value to it each time
It will really save me a lot of time when doing testing and deploy OVF to Vcenter server:
Now I will share with you my labor, to some extent, hope it will be helpful for you 🙂