Tuesday, September 26, 2017

How to use objtool to manipulate a vSAN object

One of the coolest (and most dangerous) commands in vSAN is objtool. Since this datastore is not vmfs but vsanfs (and object based), the objtool command is the utility that performs different tasks such as creating, resizing and deleting objects.

What follows is a series of examples on how to use such command:

# find / -name objtool
/usr/lib/vmware/osfs/bin/objtool

# cd /usr/lib/vmware/osfs/bin

Want to learn how to use the command?

# ./objtool --help
usage: ./objtool <cmd> <options>
Commands:
create    Create an object.
  -s/--size n              size in bytes (or KB, MB, GB or TB)
  -n/--name <string>       Optional user-friendly name.
  -m/--haMetaData <string> Optional HA metadata.
  -p/--policy <string>     Optional VSAN policy.
  -g/--groupUuid <string>  Optional groupUuid of the object.
  -a/--allocType <value>   Allocation Type.
                           0 - Thick (default)
                           1 - Eager Zeroed Thick
                           2 - Zeroed Thick
                           3 - Thin
  --capabilities <value>   Capability flags.
                           0 - None (default)
                           1 - Strict GWE (VsanSparse)
  -t/--objClass <value>    Object Class.
                           0 - vdisk (default)
                           1 - snapshot
                           2 - vmnamespace
                           3 - vmswap
                           4 - vmem
                           5 - sidecar
                           6 - hbrpersist
                           7 - coredump

delete     Delete an object.
  -u/--uuid          UUID of the object
  -f/--forceDelete   Optional force delete mode

open       Create a node for an object in DevFS.
  -u/--uuid          UUID of the object

setAttr    Set attributes of an object
  -u/--uuid                UUID of the object
  -n/--name <string>       Optional user-friendly name.
  -m/--haMetaData <string> Optional HA metadata.
  -d/--descPath <string>   Optional descriptor path.
  --capabilities <value>   Capability flags.
                           0 - None (default)
                           1 - Strict GWE (VsanSparse)

getAttr    Get attributes of an object
  -u/--uuid                UUID of the object
  -c/--isComponent         Specified uuid is a component uuid
  -x/--diskUuid            Disk uuid of the component
  --bypassDom              Bypass DOM and read from LSOM
  --format                 Pretty print the output
                           (Currently, only JSON)
resize     Resize an object
  -u/--uuid          UUID of the object
  -s/--size n        size in bytes (or KB, MB, GB or TB)
  -l/--lockFilePath <path> Lock file path for the object

truncate   Truncate an object
  -u/--uuid          UUID of the object
  -s/--size n        size in bytes (or KB, MB, GB or TB)

setPolicy  Set policy of an object
  -u/--uuid             UUID of the object.
  -p/--policy <string>  VSAN policy.

setMirror  Set the read mirror for an object
  -u/--uuid          UUID of the object
  -r/--readMirror n  mirror to use (-1 to unset)

reset  Reset object.
  -u/--uuid   UUID of the object

Global Options
  -v/--verbose       Verbosity level.
  -q/--quiet         No need to print success messages
  -h/--help          Print this message.

# cat /vmfs/volumes/vsanDatastore/testvm/testvm.vmdk
# Disk DescriptorFile
version=4
encoding="UTF-8"
CID=d68d61b2
parentCID=ffffffff
isNativeSnapshot="no"
createType="vmfs"

# Extent description
RW 2097152 VMFS "vsan://2cc4ca59-f4d8-43c3-9a0b-005056013df7" <-- notice this object id

# The Disk Data Base
#DDB

ddb.adapterType = "lsilogic"
ddb.deletable = "true"
ddb.geometry.cylinders = "512"
ddb.geometry.heads = "128"
ddb.geometry.sectors = "32"
ddb.longContentID = "14bf5c5d81a00d863d0b300fd68d61b2"
ddb.thinProvisioned = "1"
ddb.uuid = "60 00 C2 9b 2d 72 3f 5c-1c 8a 12 5f ca f9 2d 38"
ddb.virtualHWVersion = "13"

Want to delete an object? Better have a backup...

# ./objtool delete -u 2cc4ca59-f4d8-43c3-9a0b-005056013df7 -f

Will this delete the object? You bet... Better have a good backup.


Notice that after the components for the virtual disk object are no longer present.

What about renaming an object? Objtool to the rescue...

# ls -lh
total 5120
drwxr-xr-t    1 root     root        2.1K Sep 26 21:18 26c4ca59-1028-c0c6-e31d-005056013df7
drwxr-xr-t    1 root     root        1.9K Sep 12 15:38 3fc7ad59-ef19-ba92-6088-005056013e28
drwxr-xr-t    1 root     root        1.4K Sep 26 17:56 6986ca59-70d0-0591-c8ff-005056013df7
drwxr-xr-t    1 root     root        3.0K Sep 26 21:18 bfc6ad59-b712-25d2-8939-005056013e24
drwxr-xr-t    1 root     root        1.9K Sep 15 17:40 cac7ad59-f2ac-2d3c-e054-005056013e28
lrwxr-xr-x    1 root     root          36 Sep 26 21:27 javier01 -> 6986ca59-70d0-0591-c8ff-005056013df7
lrwxr-xr-x    1 root     root          36 Sep 26 21:27 testvm -> 26c4ca59-1028-c0c6-e31d-005056013df7           <--notice this line and the name
lrwxr-xr-x    1 root     root          36 Sep 26 21:27 ub1404lts1 -> bfc6ad59-b712-25d2-8939-005056013e24
lrwxr-xr-x    1 root     root          36 Sep 26 21:27 ub1404lts2 -> 3fc7ad59-ef19-ba92-6088-005056013e28
lrwxr-xr-x    1 root     root          36 Sep 26 21:27 ub1404lts5 -> cac7ad59-f2ac-2d3c-e054-005056013e28

# /usr/lib/vmware/osfs/bin/objtool setAttr -u 26c4ca59-1028-c0c6-e31d-005056013df7 -n newtestvm
Object set attribute succeeded

# /etc/init.d/osfsd restart
watchdog-osfsd: Terminating watchdog process with PID 312029
Waiting for process to terminate...
osfsd stopped
osfsd started

# ls -lh
total 5120
drwxr-xr-t    1 root     root        2.1K Sep 26 21:18 26c4ca59-1028-c0c6-e31d-005056013df7
drwxr-xr-t    1 root     root        1.9K Sep 12 15:38 3fc7ad59-ef19-ba92-6088-005056013e28
drwxr-xr-t    1 root     root        1.4K Sep 26 17:56 6986ca59-70d0-0591-c8ff-005056013df7
drwxr-xr-t    1 root     root        3.0K Sep 26 21:18 bfc6ad59-b712-25d2-8939-005056013e24
drwxr-xr-t    1 root     root        1.9K Sep 15 17:40 cac7ad59-f2ac-2d3c-e054-005056013e28
lrwxr-xr-x    1 root     root          36 Sep 26 21:30 javier01 -> 6986ca59-70d0-0591-c8ff-005056013df7
lrwxr-xr-x    1 root     root          36 Sep 26 21:30 newtestvm -> 26c4ca59-1028-c0c6-e31d-005056013df7   <-- notice the new name
lrwxr-xr-x    1 root     root          36 Sep 26 21:30 ub1404lts1 -> bfc6ad59-b712-25d2-8939-005056013e24
lrwxr-xr-x    1 root     root          36 Sep 26 21:30 ub1404lts2 -> 3fc7ad59-ef19-ba92-6088-005056013e28
lrwxr-xr-x    1 root     root          36 Sep 26 21:30 ub1404lts5 -> cac7ad59-f2ac-2d3c-e054-005056013e28

Want information about an object?

# /usr/lib/vmware/osfs/bin/objtool getAttr -u 26c4ca59-1028-c0c6-e31d-005056013df7
Object Attributes --

UUID:26c4ca59-1028-c0c6-e31d-005056013df7

Object type:vsan

Object size:273804165120

User friendly name:newtestvm

HA metadata:(null)

Allocation type:Thick

Policy:((\"stripeWidth\" i1) (\"cacheReservation\" i0) (\"proportionalCapacity\" i0) (\"hostFailuresToTolerate\" i1) (\"forceProvisioning\" i0) (\"spbmProfileId\" \"aa6d5a82-1c88-45da-85d3-3d74b91a5bad\") (\"spbmProfileGenerationNumber\" l+0) (\"spbmProfileName\" \"vSAN Default Storage Policy\"))

Object class: vmnamespace

Object capabilities: NONE

Object path: /vmfs/volumes/vsan:521305e4430dd845-d59b1943736fdc88/

And how do I create an object?

# /usr/lib/vmware/osfs/bin/objtool create -s 1KB -a 1 -t 0-n javierobject

Creating object of size 1024 bytes
Setting object class to 0
UUID:3184dd59-c0ea-6ab8-b241-005056013df7how do I create my own object?



Note:  The previous command creates an object using the default policy.  This could be verified also with the rvc.




Note: Add the -t 0 option to the previous command to create a vdisk object. This can also be verified with the rvc.

How to create and remove directories in a vSAN datastore with osfs-mkdir and osfs-rmdir

Creating and removing directories in a vSAN datastore is not as simple as using mkdir and rmdir or rm -rf because the vSAN datastore is object based. In order to do that, special vSAN related commands exist to perform such tasks.

Notice what happens if you try to use the mkdir command:

# cd /vmfs/volumes/vsanDatastore
# mkdir testdir
mkdir: can't create directory 'testdir': Function not implemented

The commands that follow perform the same tasks as the icon with the green plus sign on the web client. These commands should be used if the vCenter server is not available.


How to do it:

Step 1: Access the folder that contains the utilities

# cd /usr/lib/vmware/osfs/bin

Step 2: List the contents of that directory

# ls
objtool     osfs-ls     osfs-mkdir  osfs-rmdir  osfsd

Step 3: Verify that a directory called testdir does not exist

# ls -lh /vmfs/volumes/vsanDatastore/testdir
ls: /vmfs/volumes/vsanDatastore/testdir: No such file or directory

Step 4: Create such directory

# ./osfs-mkdir /vmfs/volumes/vsanDatastore/testdir
92c0ca59-0c9a-84f0-d2f0-005056013e28

Step 5: Verify that it exists

# ls -lh /vmfs/volumes/vsanDatastore/testdir
lrwxr-xr-x    1 root     root          36 Sep 26 21:03 /vmfs/volumes/vsanDatastore/testdir -> 92c0ca59-0c9a-84f0-d2f0-005056013e28

Step 6: Delete the directory

# ./osfs-rmdir /vmfs/volumes/vsanDatastore/testdir
Deleting directory 92c0ca59-0c9a-84f0-d2f0-005056013e28 in container id 521305e4430dd845d59b1943736fdc88 backed by vsan (force=False)

Step 7: Verify that it is gone

# ls -lh /vmfs/volumes/vsanDatastore/testdir
ls: /vmfs/volumes/vsanDatastore/testdir: No such file or directory




Friday, September 1, 2017

VMworld 2017 Photos

Some photos for those who could not attend ...


It all starts with registration.


The calm before the storm.


Getting ready to greet participants...


Pat in action...


Nice Backpacks guys :)