VMware {code} Community
helpme201110141
Contributor
Contributor

Getting file size and block size detail for creating datastore

Hi All,

while creating the datastore we can specify the block size. now my query is while creating a datastore, user is given a drop down with a list of file size and block size. are the values in drop down fix or is there a way that we can get this values using java api and show it to the user. If it is possible to show, then please let me know the process and in case it is not possible then is there a possiblity that it might change host to host depending upon ESX installed.

Thanks ,

Inder

Reply
0 Kudos
5 Replies
vijayagce
Enthusiast
Enthusiast

Hi,

As per my understaning, Java api will do that:

I think you can get the managed object reference for scsidisk which is going to use for Datastore creation. From that mob you can get the file size as follow:
DynamicProperty[] scsiArry = getDynamicProarray(host1, "config.storageDevice.scsiLun");
ScsiLun[] scsiLun = ((ScsiLun[])(scsiArry[0]).val);
ScsiLun NewLun = scsiLun[j];
long size = ((Vim25Api.HostScsiDisk)(NewLun)).capacity.block / (1024 / ((Vim25Api.HostScsiDisk)(NewLun)).capacity.blockSize);
Here size is the file size value.
Using this file size you can calculate block size for Datastore.
#Assign Blocksize to create vmfs file system
# 1MB block size 256GB maximum file size
# 2MB block size 512GB maximum file size
# 4MB block size 1024GB maximum file size
# 8MB block size 2048GB maximum file size
So If the file size less than 256GB then block size will be 1MB or If the file size is in between 256GB to 512GB then block size will be 2MB like that.
It may help to calculate file size and block size.
Thanks,
Reply
0 Kudos
helpme201110141
Contributor
Contributor

Hi,

       Thanks Vijayagce for your reply.........

           I agree with what you said................

           Actually we are working on a plugin where i have to show all the file size and block size possible to user to select for ds creation.

           No my question is can we get file size and bloxk size using API or it is always fix like you mentined

# 1MB block size 256GB maximum file size
# 2MB block size 512GB maximum file size
# 4MB block size 1024GB maximum file size
# 8MB block size 2048GB maximum file size
Does this detail depend on the esx installed on a host or it will be same irrespective of esx.
hope i am making some sense ...
Thanks  a lot
Ini
Reply
0 Kudos
vijayagce
Enthusiast
Enthusiast

Hi,
I can't get u clearly..
As per my understanding, If u change ur harddisk size then automatically the values which are used to calculate file size will be refreshed meaning like if u extend or modified disk size then its capacity.block and capacity.blockSize will be changed. So u can get the file size what is updated one.
I think below values are not dependent with any ESX. it will be same irrespective of esx because the values depends on the disk size only.
# 1MB block size 256GB maximum file size
# 2MB block size 512GB maximum file size
# 4MB block size 1024GB maximum file size
# 8MB block size 2048GB maximum file size
Thanks,
Reply
0 Kudos
vijayagce
Enthusiast
Enthusiast

Hi,
I am not sure whether i gave u any useful info..
I think u have to use API call for login and get all disk details.
for that u can use sample code as below:
DynamicProperty[] scsiArry = getDynamicProarray(host1, "config.storageDevice.scsiLun");
ScsiLun[] scsiLun = ((ScsiLun[])(scsiArry[0]).val);
for (int j = 0; j < scsiLun.Length; j++)
{
int[] filesize = ((Vim25Api.HostScsiDisk)(ScsiLun[j])).capacity.block / (1024 / ((Vim25Api.HostScsiDisk)(ScsiLun[j])).capacity.blockSize);
}
Here filesize array will give u all disk file size. using that file size of each disk u can calculate the blocksize without any API call. So to findout the filesize we need to login and get the disk details.
Reply
0 Kudos
satishchirala
Enthusiast
Enthusiast

Reply
0 Kudos