VMware {code} Community
karthimin
Contributor
Contributor
Jump to solution

Create datastore Partiotion

Hi all,

Can any tell how to set the "HostDiskPartitionSpec" ->partition property.

please help me.

for more information please see below this is what i need to set i have SAN vdisk size i do know how to set the following property mainly "attributes","statr sector","endsector"

Data Object - HostDiskPartitionAttributes

Property of

[file:///C:/vmware/doc/ReferenceGuide/vim.host.DiskPartitionInfo.Specification.html#field_detail]

Extends

[file:///C:/vmware/doc/ReferenceGuide/vmodl.DynamicData.html]

Data Object

Description

Information about a single disk partition. A partition is a contiguous

set of blocks on a disk that is marked for use. The typeId identifies

the purpose of the data in the partition.

Properties

Name

Type

Description

attributes

xsd:byte

The attributes on the partition.

endSector

xsd:long

The end sector.

logical

xsd:boolean

The flag to indicate whether or not the partition is

logical. If true, the partition

number should be greater than 4.

partition

xsd:int

The partition number. Must be a positive integer.

startSector

xsd:long

The start sector.

type

xsd:string

Type of data in the partition. If it is a well-known partition type,

it will be one of the defined types. If it is not, then it will be

reported as a hexadecimal number. For example, "none", "vmfs", "linux",

and "0x20" are all valid values.

See

Properties inherited from

,

please reply me ASAP.

Reply
0 Kudos
1 Solution

Accepted Solutions
njain
Expert
Expert
Jump to solution

"partition" property is a positive integer, that uniquely identifies the disk partition. So if you are creating a logical partition, (i.e., setting the property "logical" to true) then you should assign any positive integer number that is greater than 4 to this property.

Hope this helps.

View solution in original post

Reply
0 Kudos
6 Replies
Steve_Jin
Expert
Expert
Jump to solution

The HostDiskPartitionSpec is part of the HostDiskPartitionInfo, which is returned by the retrieveDiskPartitionInfo method:

Try the method, you can see what is there in the existing HostDiskPartitionSpec, then you will have an idea how to create a new one.

Good luck!

Steve JIN, VMware Engineering

Creator of VI Java API:

Steve JIN Author of VMware VI and vSphere SDK; Creator of open source VI Java API (http://vijava.sf.net); Blogger at http://www.doublecloud.org
njain
Expert
Expert
Jump to solution

"partition" property is a positive integer, that uniquely identifies the disk partition. So if you are creating a logical partition, (i.e., setting the property "logical" to true) then you should assign any positive integer number that is greater than 4 to this property.

Hope this helps.

Reply
0 Kudos
karthimin
Contributor
Contributor
Jump to solution

Thanks Steve,

It worked out thanks for your help and support and thanks for every one...

Reply
0 Kudos
fordian
Hot Shot
Hot Shot
Jump to solution

Hello,

Could you help me and show me how you have coded this. I would like to have informations on each partition (startSector, type ...) I tried with RetrieveDiskPartitionInfo but there is something I do not do correctly.

Thank you

Dominic

Reply
0 Kudos
karthimin
Contributor
Contributor
Jump to solution

Hi Dominic,

i pasted my code for your reference.

//

// Change the layout partition settings.This is default setting for datastore partititon allign.

//

HostDiskPartitionLayout^ HdiskPartLay = gcnew HostDiskPartitionLayout();

if(hostpart!= nullptr && hostpart->Length > 0)

{

hostpart[0]->layout->partition[0]->partition = 1;

hostpart[0]->layout->partition[0]->partitionSpecified = true;

hostpart[0]->layout->partition[0]->type = "vmfs";

// Setting HostDiskPartitionLayout object.

HdiskPartLay = hostpart[0]->layout;

}

//

// Getting the best partition calculation like end sector value,start sector value according to vdisk size.

//

HostDiskPartitionInfo^ HdPartInfo = pVim->ComputeDiskPartitionInfo(m_pHcm->storageSystem,p_DiskDevicePath,HdiskPartLay);

/// Only check for partitioning info in case of assign as datastore where we will create datastore

/// Based on user input

bool createDatastore = true;

if(p_bCheckPartition)

{

/// Check if any datastore appeared after rescanning with the name as vdisk name.

/// Aks user confirmation only if datastore is not reappeared.

if(!CheckIfDatastoreAppeared(pVDisk->Name))

{

createDatastore = SendPartitionMessageToIM(pVDisk->Name,spartitionType,"Datastore");

}

else

{

createDatastore = false;

}

}

if(createDatastore)

{

if(p_DiskDevicePath)

{

if(nullptr != HdPartInfo->spec->partition)

{

vmfsDSoptions = pVmwSession->getVimService()->QueryVmfsDatastoreCreateOptions(imor,p_DiskDevicePath);

(((VimApi::HostVmfsSpec)((((VimApi::VmfsDatastoreCreateSpec)(((VimApi::VmfsDatastoreSpec^)(vmfsDSoptions[0]->spec)))))->vmfs)))->volumeName = sDatastoreName;

(((VimApi::HostVmfsSpec)((((VimApi::VmfsDatastoreCreateSpec)(((VimApi::VmfsDatastoreSpec^)(vmfsDSoptions[0]->spec)))))->vmfs)))->blockSizeMb = iBlockSize;

(((VimApi::HostDiskPartitionSpec)((((VimApi::VmfsDatastoreCreateSpec)(((VimApi::VmfsDatastoreSpec^)(vmfsDSoptions[0]->spec)))))->partition)))->partition = HdPartInfo->spec->partition;

//

// Create the datastore

//

ManagedObjectReference createDatastore = pVmwSession->getVimService()->CreateVmfsDatastore(imor,(VimApi::VmfsDatastoreCreateSpec)vmfsDSoptions[0]->spec);

bRet = true;

}

else

{

LOG_WARN("Could not able to fetch the partition information for new datastore");

}

}

Please Note: for partition i used " ComputeDiskPartitionInfo" to calculate. just go through this method.

//

// Getting the best partition calculation like end sector value,start sector value according to vdisk size.

//

HostDiskPartitionInfo^ HdPartInfo = pVim->ComputeDiskPartitionInfo(m_pHcm->storageSystem,p_DiskDevicePath,HdiskPartLay);

Regards

Karthi

Reply
0 Kudos
fordian
Hot Shot
Hot Shot
Jump to solution

Thank you for your help.

Dominic

Reply
0 Kudos