ESXi
esxi6.5
vFRC
vflash
ManagedObject

How to configure ESXi 6.5 vFRC using the command line

Just like to setup vFRC without vCenter Server ... here is how ...
image.png

Prerequisite

  • Enable MOB

2018-02-06_113050.jpg

To enable or disable the Managed Object Browser by using the vSphere Web Client, complete the following steps:

Browse to the host in the vSphere Web Client navigator.
On the Manage tab and click Settings.
Under System, select Advanced System Settings.
Select the Config.HostAgent.plugins.solo.enableMob option and click Edit to enable or disable the Managed Object Browser.

cf. https://kb.vmware.com/s/article/2108405

How to configure vFRC - vSphere Flash Read Cache

  • login ESXi shell
[root@localhost:~] esxcli storage vflash device list

Name                    Size  Is Local  Is Used in vflash  Eligibility                    
--------------------  ------  --------  -----------------  -------------------------------
naa.55cd2e404c6e42c4  114473      true              false  No, there are other filesystems
naa.55cd2e404c6e433f  114473      true              false  Yes, this is a blank disk.     
  • new vffs partition

    • calculate end sector = #cylinders x #heads x #sectors/track - 1
    • 234436544=14593x255x63-1
[root@localhost:~] partedUtil getptbl /vmfs/devices/disks/naa.55cd2e404c6e433f 

gpt
14593 255 63 234441648
[root@localhost:~] partedUtil setptbl /vmfs/devices/disks/naa.55cd2e404c6e433f "gpt" "1 2048 234436544 AA31E02A400F11DB9590000C2911D1B8 0"

gpt
0 0 0 0
1 2048 234436544 AA31E02A400F11DB9590000C2911D1B8 0
[root@localhost:~] vmkfstools -C vmfsl /vmfs/devices/disks/naa.55cd2e404c6e433f:1 -S vffs-$(hostname -s)

create fs deviceName:'/vmfs/devices/disks/naa.55cd2e404c6e433f:1', fsShortName:'vmfsl', fsName:'vffs-localhost'
deviceFullPath:/dev/disks/naa.55cd2e404c6e433f:1 deviceFile:naa.55cd2e404c6e433f:1
Device:'/vmfs/devices/disks/naa.55cd2e404c6e433f:1' is allowed to be formatted as VMFSL 
Checking if remote hosts are using this device as a valid file system. This may take a few seconds...
Scanning for VMFS-3/VMFS-5 host activity (512 bytes/HB, 2048 HBs).
Creating vmfsl file system on "naa.55cd2e404c6e433f:1" with blockSize 1048576 and volume label "vffs-localhost".
Successfully created new volume: 5a78fbf0-5178d6a4-70a8-901b0e6e4600
[root@localhost:~] vmkfstools -Ph /vmfs/volumes/vffs-localhost

VFFS-1.00 (Raw Major Version: 14) file system spanning 1 partitions.
File system label (if any): vffs-localhost
Mode: public
Capacity 111.8 GB, 110.8 GB available, file block size 1 MB, max supported file size 62.9 TB
UUID: 5a78fbf0-5178d6a4-70a8-901b0e6e4600
Partitions spanned (on "lvm"):
    naa.55cd2e404c6e433f:1
Is Native Snapshot Capable: NO

UUID :5a78fbf0-5178d6a4-70a8-901b0e6e4600 <-- memo :exclamation:

  • refresh
[root@localhost:~] vim-cmd hostsvc/storage/refresh 

[root@localhost:~] esxcli storage vflash device list
Name                    Size  Is Local  Is Used in vflash  Eligibility                      
--------------------  ------  --------  -----------------  ---------------------------------
naa.55cd2e404c6e42c4  114473      true              false  No, there are other filesystems  
naa.55cd2e404c6e433f  114473      true               true  It has been configured for vflash
  • set HostVFlashManagerVFlashResourceConfigSpec <vffsUuid></vffsUuid>

https://localhost/mob/?moid=ha-vflash-manager&method=configureVFlashResource

image.png

  • edit vffsUuid with UUID above and click Invoke Method

image.png

  • confirm VFlashConfig

https://localhost/mob/?moid=ha-vflash-manager&doPath=vFlashConfigInfo.vFlashResourceConfigInfo.vffs

image.png

Done :smile:

References

How to automate vFRC configurations using the command-line in ESXi - Posted on 11/20/2013 by William Lam
https://www.virtuallyghetto.com/2013/11/how-to-automate-configuration-of-vfrc.html

  1. download
  2. download
  3. convert py into Python 3.x version with 2to3
    • change password accordingly
$ 2to3 -w addVirtualFlashResource.py
addVirtualFlashResource.py
# Author: William Lam
# Website: www.virtuallyghetto.com
# Product: VMware vSphere + vSphere Flash Read Cache (vFRC)
# Description: Python script that calls vSphere MOB to add Virtual Flash Resource
# Reference: http://www.virtuallyghetto.com/2013/11/how-to-automate-configuration-of-vfrc.html

import sys,re,os,urllib.request,urllib.parse,urllib.error,urllib.request,urllib.error,urllib.parse,base64

if len(sys.argv) == 1:
    print("\n\tUsage: " + str(sys.argv[0]) + " [VFFS-UUID]\n")
    sys.exit(1)
else:
    vffsUuid = str(sys.argv[1])

# mob url
url = "https://localhost/mob/?moid=ha-vflash-manager&method=configureVFlashResource"

# mob login credentials
username = "root"
password = "vmware123"

# Create global variables
global passman,authhandler,opener,req,page,page_content,nonce,headers,cookie,params,e_params

# Code to build opener with HTTP Basic Authentication
passman = urllib.request.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None,url,username,password)
authhandler = urllib.request.HTTPBasicAuthHandler(passman)
opener = urllib.request.build_opener(authhandler)
urllib.request.install_opener(opener)

### Code to capture required page data and cookie required for post back to meet CSRF requirements  ###
try:
    req = urllib.request.Request(url)
    page = urllib.request.urlopen(req)
    page_content= page.read()
except IOError as e:
    opener.close()
    sys.exit(1)
else:
    print("Successfully connected to vSphere MOB")

# regex to get the vmware-session-nonce value from the hidden form entry
reg = re.compile('name="vmware-session-nonce" type="hidden" value="?([^\s^"]+)"')
nonce = reg.search(page_content).group(1)

# get the page headers to capture the cookie
headers = page.info()
cookie = headers.get("Set-Cookie")

# Code to create HostVFlashManagerVFlashResourceConfigSpec
xml = '<spec xsi:type="HostVFlashManagerVFlashResourceConfigSpec"><vffsUuid>' + vffsUuid + '</vffsUuid></spec>'

try :
    params = {'vmware-session-nonce':nonce,'spec':xml}
    e_params = urllib.parse.urlencode(params)
    req = urllib.request.Request(url, e_params, headers={"Cookie":cookie})
    page = urllib.request.urlopen(req).read()
except IOError as e:
    opener.close()
    sys.exit(1)
else:
    print("Successfully issued configureVFlashResource() with VFFS UUID " + vffsUuid + "\n")