Microsoft recently announced the new Windows 10 Insider Preview Build 14316 which includes the ability to run native bash on Ubuntu on Windows. First off BRILLIANT! Secondly I just had to get this working with the new Pure Storage Python Toolkit 1.6. Here is the short journey to get things working. The example script does the following:
- Connects to the Pure Storage FlashArray
- Creates a new volume
- Creates a snapshot of the new volume
- Creates a new volume from the new snapshot
- Create a Protection Group
- Adds the new volume from the snapshot to the Protection Group
- Creates a Protection Group snapshot
- Performs a cleanup of items 1 – 7
Steps
- Follow the steps in the following MSDN article, https://devblogs.microsoft.com/commandline/bash-on-ubuntu-on-windows-download-now-3/ to download and install the Windows 10 Insider Preview Build 14316 and get the Windows Subsystem for Linux (Beta) running.
- Once the Windows Subsystem for Linux is running open a Command Prompt (Admin) and type bash.
- Run all of the following commands:
12345wget <a href=“https://pypi.python.org/packages/source/p/purestorage/purestorage-1.6.0.tar.gz”>https://pypi.python.org/packages/source/p/purestorage/purestorage-1.6.0.tar.gz</a>apt–get updateapt–get install python–pippip install requestspip install purestorage–1.6.0.tar.gz - Basic Python script creation:
1vim PS–BASHTEST.py
12345678910111213141516171819202122232425from purestorage import purestoragearray = purestorage.FlashArray(target=“1.1.1.1”, username=”pureuser“,password=”xxxxxxx“)print “Creating volume...“array.create_volume(“BASH–VOL1“, size=”1T“)print “Creating snapshot...“array.create_snapshots([‘BASH-VOL1’], suffix=”FOO“)print “Creating new volume from snapshot...“array.copy_volume(source=”BASH–VOL1.FOO“, dest=”BASH–TEST“)print “Creating Protection Group and adding Volume...“array.create_pgroup(pgroup=”BASH–PG1“)array.set_pgroup(pgroup=”BASH–PG1“,addvollist=[‘BASH-TEST’])print “Creating Protection Group snapshot...“array.create_pgroup_snapshot(source=”BASH–PG1“)print “CLEANUP——————————————————————————–“response = raw_input(“Do you want to remove everything? y/n “)if response == “y“:array.destroy_pgroup(“BASH–PG1“)array.eradicate_pgroup(“BASH–PG1“)array.destroy_volume(“BASH–TEST“)array.eradicate_volume(“BASH–TEST“)array.destroy_volume(“BASH–VOL1“)array.eradicate_volume(“BASH–VOL1“)print(“n All objects destroyed and eradicated.“)else:print(“n Nothing destroyed.“) - Save and Exit
1ESC :x - Run the script:
123python PS–BASHTEST.py<a href=“https://www.purepowershellguy.com/wp-content/uploads/2016/04/ps-bashtest.png”><img title=“ps-bashtest” src=“https://www.purepowershellguy.com/wp-content/uploads/2016/04/ps-bashtest_thumb.png” alt=“ps-bashtest” width=“701” height=“381” border=“0” /></a>
Best new feature in Windows I’ve seen in years!
Cheers,
Barkz