You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Mike Tutkowski <mi...@solidfire.com> on 2013/06/02 04:07:29 UTC

Re: VMware API Question

Hi Vijay,

I was wondering - if you had a few moments - if you might give me some
pointers on how to translate this code I've written in the VI Java API to
the VI API, which we use in CloudStack?

Below is my createVmfsDatastore method.

Thanks for any time you might be able to spend on this!

 public static void createVmfsDatastore(String url, String username, String
password, String datacenterName, String clusterName,

 String datastoreName, String storageIpAddress, Integer portNumber, String
iqn) throws Exception

{

 ServiceInstance si = new ServiceInstance(new URL(url), username, password,
true);

  ManagedEntity datacenter =
si.getSearchIndex().findByInventoryPath(datacenterName);

  if (datacenter == null)

 {

 throw new Exception("Datacenter '" + datacenterName + "' was not found.");

 }

  InventoryNavigator inventoryNavigator =
newInventoryNavigator(si.getRootFolder());

  ClusterComputeResource cluster =
(ClusterComputeResource)inventoryNavigator.searchManagedEntity(
"ClusterComputeResource", clusterName);

  if (cluster == null)

 {

 throw new Exception("Cluster '" + clusterName + "' was not found.");

 }

  HostSystem[] aHostSystems = cluster.getHosts();

  if (aHostSystems == null || aHostSystems.length == 0)

 {

 throw new Exception("There are no hosts in cluster '" + clusterName + "'."
);

 }

  HostInternetScsiHbaStaticTarget target = newHostInternetScsiHbaStaticTarget();

  target.setAddress(storageIpAddress);

 target.setPort(portNumber);

 target.setIScsiName(iqn);

  HostInternetScsiHbaAuthenticationProperties auth =
newHostInternetScsiHbaAuthenticationProperties();

  String strAuthType = "chapRequired";

  auth.setChapAuthEnabled(true);

 auth.setChapInherited(false);

 auth.setChapAuthenticationType(strAuthType);

 auth.setChapName("admin");

 auth.setChapSecret("solidfire");

 auth.setMutualChapInherited(false);

 auth.setMutualChapAuthenticationType(strAuthType);

 auth.setMutualChapName("admin2");

 auth.setMutualChapSecret("solidfire2");

  target.setAuthenticationProperties(auth);

  HostInternetScsiHbaStaticTarget[] aTargets =
newHostInternetScsiHbaStaticTarget[1];

  aTargets[0] = target;

  for (HostSystem hostSystem : aHostSystems)

 {

 boolean iScsiHbaConfigured = false;

   HostStorageSystem hostStorageSystem = hostSystem.getHostStorageSystem();

   for (HostHostBusAdapter hba :
hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter())

 {

  if (hba instanceof HostInternetScsiHba)

  {

  // just finding an instance of HostInternetScsiHba means that we have
found at least one configured iSCSI HBA

  // at least one iSCSI HBA must be configured before a CloudStack user can
use this host for iSCSI storage

  iScsiHbaConfigured = true;

     String iScsiHbaDevice = hba.getDevice();

     hostStorageSystem.addInternetScsiStaticTargets(iScsiHbaDevice,
aTargets);

     hostStorageSystem.rescanHba(iScsiHbaDevice);

  }

 }

   if (!iScsiHbaConfigured)

 {

  throw new Exception("An iSCSI HBA must be configured before a host can
use iSCSI storage.");

 }

 }

  HostDatastoreSystem hostDatastoreSystem =
aHostSystems[0].getHostDatastoreSystem();

  HostScsiDisk[] aHostScsiDisks =
hostDatastoreSystem.queryAvailableDisksForVmfs(null);

  HostStorageSystem hostStorageSystem =
aHostSystems[0].getHostStorageSystem();

  HostScsiDisk hostScsiDisk =
getHostScsiDisk(hostStorageSystem.getStorageDeviceInfo().getScsiTopology(),
aHostScsiDisks, iqn);

  if (hostScsiDisk == null)

 {

 throw new Exception("A relevant SCSI disk could not be located to use to
create a datastore.");

 }

  // just grab the first instance of VmfsDatastoreOption

 VmfsDatastoreOption vmfsDatastoreOption =
hostDatastoreSystem.queryVmfsDatastoreCreateOptions(hostScsiDisk.getDevicePath())[0];

 VmfsDatastoreCreateSpec vmfsDatastoreCreateSpec =
(VmfsDatastoreCreateSpec)vmfsDatastoreOption.getSpec();

  // set the name of the datastore to be created

 vmfsDatastoreCreateSpec.getVmfs().setVolumeName(datastoreName);

  Datastore datastore =
hostDatastoreSystem.createVmfsDatastore(vmfsDatastoreCreateSpec);

  if (datastore == null)

 {

 throw new Exception ("Datastore '" + datastoreName + "' could not be
created.");

 }

  System.out.println("Datastore '" + datastoreName + "' was successfully
created.");

}


On Wed, May 29, 2013 at 7:50 PM, Mike Tutkowski <
mike.tutkowski@solidfire.com> wrote:

> OK - thanks, Vijay!
>
>
> On Wed, May 29, 2013 at 5:05 PM, Vijayendra Bhamidipati <
> vijayendra.bhamidipati@citrix.com> wrote:
>
>> Hi Mike,
>>
>> Your opensource vi java code will be close to what you would implement
>> using the closed source vi sdk, so though you will have to rewrite some
>> code, it should be possible to reuse much of your core code, especially
>> with spec preparation and the like. Cloudstack code already has useful
>> functions that let you retrieve dynamic properties etc from MORs, so you
>> would need to replace some of your vi java code with those functions. You
>> cannot however mix vi java with vi sdk in cloudstack, which uses only vi
>> sdk. You also won't need to setup the vmware service context, it's already
>> there in Vmwareresource.java, so you can use that.
>>
>> Regards,
>> Vijay
>>
>>
>> -----Original Message-----
>> From: Mike Tutkowski [mailto:mike.tutkowski@solidfire.com]
>> Sent: Wednesday, May 29, 2013 2:40 PM
>> To: dev@cloudstack.apache.org
>> Subject: VMware API Question
>>
>> Hi,
>>
>> I recently completed work in the new storage framework related to
>> XenServer where I dynamically create a storage repository when attaching a
>> newly created volume, if need be.
>>
>> I now need to implement the same concept for VMware.
>>
>> The idea is that I have zone-wide primary storage that is backed by a
>> plug-in (all new in 4.2).
>>
>> When the user creates a volume, we still just add a row to the volumes
>> table that describes this volume.
>>
>> When the user goes to attach this volume to a VM, the storage framework
>> invokes my plug-in and my plug-in goes off to its SAN to create a
>> volume...returning info like IQN.
>>
>> Next the VMware attach logic is invoked. In this dynamic kind of
>> zone-wide storage, I need to detect in this VMware code that we do not yet
>> have a datastore and create this datastore based on the IQN I returned
>> earlier (and other info like IP address).
>>
>> I have this all working for XenServer and am now turning my attention to
>> VMware.
>>
>> My question is simply this:
>>
>> It looks like VmwareResourse is written with VI SDK. Since I have my
>> "create/delete datastore" logic already written in the VI Java API (
>> http://vijava.sourceforge.net/), I was wondering if it's possible to mix
>> these two approaches or if I will have to re-write my code.
>>
>> Thanks!
>>
>> --
>> *Mike Tutkowski*
>> *Senior CloudStack Developer, SolidFire Inc.*
>> e: mike.tutkowski@solidfire.com
>> o: 303.746.7302
>> Advancing the way the world uses the
>> cloud<http://solidfire.com/solution/overview/?video=play>
>> *(tm)*
>>
>
>
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *™*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

Re: VMware API Question

Posted by Mike Tutkowski <mi...@solidfire.com>.
Hi Vijay,

I have a quick question for you. :)

I have about 99% of the VMware-related code written.

This is what it does and how it fits in with my storage plug-in.

* Let's say an admin creates a Disk Offering for a volume that is 1 GB and
has certain Min, Max, and Burst IOPS set.

* An end user later executes this Disk Offering and a row is added to the
volumes table.

* Next the end user wants to attach this disk to a VM running in a VMware
cluster.

* Edison's storage framework realizes that the SAN volume needs to be
created and calls into my plug-in, which creates a 1 GB volume with the
appropriate Min, Max, and Burst IOPS.

* Next VmResource's execute(AttachVolumeCmd) method is invoked.

* My new code recognizes that the type of storage involved is dynamic,
zone-wide storage (dynamic in the sense that a datastore needs to be
created because one does not yet exist for the storage system's volume).

* My new code creates a datastore (basing it on the storage IP address of
the SAN and the IQN of the volume).

* By default, the new datastore will take up all of the space provided by
the SAN volume (this is ideal).

So, here's my question:

The time comes to attach the disk to the VM. I see when we are preparing
the VirtualDisk object that we do not call the setCapacityInKB(long) method
on the disk object.

Do you know what the default size of the disk will be? Ideally it will
consume as much of the datastore as remains (which is probably not the
entire datastore since a little of it is probably already consumed by
VMware metadata).

I'm not sure of the behavior of setCapacityInKB and the docs I've seen are
vague. Perhaps if I call this method, it fixes the size of the disk? I
expect that whatever the behavior, the disk must have a size anyways that
the VM sees.

Thanks!



On Sun, Jun 2, 2013 at 12:01 AM, Mike Tutkowski <
mike.tutkowski@solidfire.com> wrote:

> Hi Vijay,
>
> I think I understand how to translate this code.
>
> Perhaps you might be willing to do a quick review of what I have when it's
> ready?
>
> Talk to you later,
>
>
> On Sat, Jun 1, 2013 at 8:07 PM, Mike Tutkowski <
> mike.tutkowski@solidfire.com> wrote:
>
>> Hi Vijay,
>>
>> I was wondering - if you had a few moments - if you might give me some
>> pointers on how to translate this code I've written in the VI Java API to
>> the VI API, which we use in CloudStack?
>>
>> Below is my createVmfsDatastore method.
>>
>> Thanks for any time you might be able to spend on this!
>>
>>  public static void createVmfsDatastore(String url, String username,
>> String password, String datacenterName, String clusterName,
>>
>>  String datastoreName, String storageIpAddress, Integer portNumber,
>> String iqn) throws Exception
>>
>> {
>>
>>  ServiceInstance si = new ServiceInstance(new URL(url), username,
>> password, true);
>>
>>   ManagedEntity datacenter =
>> si.getSearchIndex().findByInventoryPath(datacenterName);
>>
>>   if (datacenter == null)
>>
>>  {
>>
>>  throw new Exception("Datacenter '" + datacenterName + "' was not found."
>> );
>>
>>  }
>>
>>   InventoryNavigator inventoryNavigator = newInventoryNavigator(si.getRootFolder());
>>
>>   ClusterComputeResource cluster =
>> (ClusterComputeResource)inventoryNavigator.searchManagedEntity(
>> "ClusterComputeResource", clusterName);
>>
>>   if (cluster == null)
>>
>>  {
>>
>>  throw new Exception("Cluster '" + clusterName + "' was not found.");
>>
>>  }
>>
>>   HostSystem[] aHostSystems = cluster.getHosts();
>>
>>   if (aHostSystems == null || aHostSystems.length == 0)
>>
>>  {
>>
>>  throw new Exception("There are no hosts in cluster '" + clusterName +
>> "'.");
>>
>>  }
>>
>>   HostInternetScsiHbaStaticTarget target = newHostInternetScsiHbaStaticTarget();
>>
>>   target.setAddress(storageIpAddress);
>>
>>  target.setPort(portNumber);
>>
>>  target.setIScsiName(iqn);
>>
>>   HostInternetScsiHbaAuthenticationProperties auth = newHostInternetScsiHbaAuthenticationProperties();
>>
>>   String strAuthType = "chapRequired";
>>
>>   auth.setChapAuthEnabled(true);
>>
>>  auth.setChapInherited(false);
>>
>>  auth.setChapAuthenticationType(strAuthType);
>>
>>  auth.setChapName("admin");
>>
>>  auth.setChapSecret("solidfire");
>>
>>  auth.setMutualChapInherited(false);
>>
>>  auth.setMutualChapAuthenticationType(strAuthType);
>>
>>  auth.setMutualChapName("admin2");
>>
>>  auth.setMutualChapSecret("solidfire2");
>>
>>   target.setAuthenticationProperties(auth);
>>
>>   HostInternetScsiHbaStaticTarget[] aTargets = newHostInternetScsiHbaStaticTarget[1];
>>
>>   aTargets[0] = target;
>>
>>   for (HostSystem hostSystem : aHostSystems)
>>
>>  {
>>
>>  boolean iScsiHbaConfigured = false;
>>
>>    HostStorageSystem hostStorageSystem =
>> hostSystem.getHostStorageSystem();
>>
>>    for (HostHostBusAdapter hba :
>> hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter())
>>
>>  {
>>
>>   if (hba instanceof HostInternetScsiHba)
>>
>>   {
>>
>>   // just finding an instance of HostInternetScsiHba means that we have
>> found at least one configured iSCSI HBA
>>
>>   // at least one iSCSI HBA must be configured before a CloudStack user
>> can use this host for iSCSI storage
>>
>>   iScsiHbaConfigured = true;
>>
>>      String iScsiHbaDevice = hba.getDevice();
>>
>>      hostStorageSystem.addInternetScsiStaticTargets(iScsiHbaDevice,
>> aTargets);
>>
>>      hostStorageSystem.rescanHba(iScsiHbaDevice);
>>
>>   }
>>
>>  }
>>
>>    if (!iScsiHbaConfigured)
>>
>>  {
>>
>>   throw new Exception("An iSCSI HBA must be configured before a host can
>> use iSCSI storage.");
>>
>>  }
>>
>>  }
>>
>>   HostDatastoreSystem hostDatastoreSystem =
>> aHostSystems[0].getHostDatastoreSystem();
>>
>>   HostScsiDisk[] aHostScsiDisks =
>> hostDatastoreSystem.queryAvailableDisksForVmfs(null);
>>
>>   HostStorageSystem hostStorageSystem =
>> aHostSystems[0].getHostStorageSystem();
>>
>>   HostScsiDisk hostScsiDisk =
>> getHostScsiDisk(hostStorageSystem.getStorageDeviceInfo().getScsiTopology(),
>> aHostScsiDisks, iqn);
>>
>>   if (hostScsiDisk == null)
>>
>>  {
>>
>>  throw new Exception("A relevant SCSI disk could not be located to use
>> to create a datastore.");
>>
>>  }
>>
>>   // just grab the first instance of VmfsDatastoreOption
>>
>>  VmfsDatastoreOption vmfsDatastoreOption =
>> hostDatastoreSystem.queryVmfsDatastoreCreateOptions(hostScsiDisk.getDevicePath())[0];
>>
>>  VmfsDatastoreCreateSpec vmfsDatastoreCreateSpec =
>> (VmfsDatastoreCreateSpec)vmfsDatastoreOption.getSpec();
>>
>>   // set the name of the datastore to be created
>>
>>  vmfsDatastoreCreateSpec.getVmfs().setVolumeName(datastoreName);
>>
>>   Datastore datastore =
>> hostDatastoreSystem.createVmfsDatastore(vmfsDatastoreCreateSpec);
>>
>>   if (datastore == null)
>>
>>  {
>>
>>  throw new Exception ("Datastore '" + datastoreName + "' could not be
>> created.");
>>
>>  }
>>
>>   System.out.println("Datastore '" + datastoreName + "' was successfully
>> created.");
>>
>> }
>>
>>
>> On Wed, May 29, 2013 at 7:50 PM, Mike Tutkowski <
>> mike.tutkowski@solidfire.com> wrote:
>>
>>> OK - thanks, Vijay!
>>>
>>>
>>> On Wed, May 29, 2013 at 5:05 PM, Vijayendra Bhamidipati <
>>> vijayendra.bhamidipati@citrix.com> wrote:
>>>
>>>> Hi Mike,
>>>>
>>>> Your opensource vi java code will be close to what you would implement
>>>> using the closed source vi sdk, so though you will have to rewrite some
>>>> code, it should be possible to reuse much of your core code, especially
>>>> with spec preparation and the like. Cloudstack code already has useful
>>>> functions that let you retrieve dynamic properties etc from MORs, so you
>>>> would need to replace some of your vi java code with those functions. You
>>>> cannot however mix vi java with vi sdk in cloudstack, which uses only vi
>>>> sdk. You also won't need to setup the vmware service context, it's already
>>>> there in Vmwareresource.java, so you can use that.
>>>>
>>>> Regards,
>>>> Vijay
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: Mike Tutkowski [mailto:mike.tutkowski@solidfire.com]
>>>> Sent: Wednesday, May 29, 2013 2:40 PM
>>>> To: dev@cloudstack.apache.org
>>>> Subject: VMware API Question
>>>>
>>>> Hi,
>>>>
>>>> I recently completed work in the new storage framework related to
>>>> XenServer where I dynamically create a storage repository when attaching a
>>>> newly created volume, if need be.
>>>>
>>>> I now need to implement the same concept for VMware.
>>>>
>>>> The idea is that I have zone-wide primary storage that is backed by a
>>>> plug-in (all new in 4.2).
>>>>
>>>> When the user creates a volume, we still just add a row to the volumes
>>>> table that describes this volume.
>>>>
>>>> When the user goes to attach this volume to a VM, the storage framework
>>>> invokes my plug-in and my plug-in goes off to its SAN to create a
>>>> volume...returning info like IQN.
>>>>
>>>> Next the VMware attach logic is invoked. In this dynamic kind of
>>>> zone-wide storage, I need to detect in this VMware code that we do not yet
>>>> have a datastore and create this datastore based on the IQN I returned
>>>> earlier (and other info like IP address).
>>>>
>>>> I have this all working for XenServer and am now turning my attention
>>>> to VMware.
>>>>
>>>> My question is simply this:
>>>>
>>>> It looks like VmwareResourse is written with VI SDK. Since I have my
>>>> "create/delete datastore" logic already written in the VI Java API (
>>>> http://vijava.sourceforge.net/), I was wondering if it's possible to
>>>> mix these two approaches or if I will have to re-write my code.
>>>>
>>>> Thanks!
>>>>
>>>> --
>>>> *Mike Tutkowski*
>>>> *Senior CloudStack Developer, SolidFire Inc.*
>>>> e: mike.tutkowski@solidfire.com
>>>> o: 303.746.7302
>>>> Advancing the way the world uses the
>>>> cloud<http://solidfire.com/solution/overview/?video=play>
>>>> *(tm)*
>>>>
>>>
>>>
>>>
>>> --
>>> *Mike Tutkowski*
>>>  *Senior CloudStack Developer, SolidFire Inc.*
>>> e: mike.tutkowski@solidfire.com
>>> o: 303.746.7302
>>> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
>>> *™*
>>>
>>
>>
>>
>> --
>> *Mike Tutkowski*
>> *Senior CloudStack Developer, SolidFire Inc.*
>> e: mike.tutkowski@solidfire.com
>> o: 303.746.7302
>> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
>> *™*
>>
>
>
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *™*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

Re: VMware API Question

Posted by Mike Tutkowski <mi...@solidfire.com>.
Hi Vijay,

I think I understand how to translate this code.

Perhaps you might be willing to do a quick review of what I have when it's
ready?

Talk to you later,


On Sat, Jun 1, 2013 at 8:07 PM, Mike Tutkowski <mike.tutkowski@solidfire.com
> wrote:

> Hi Vijay,
>
> I was wondering - if you had a few moments - if you might give me some
> pointers on how to translate this code I've written in the VI Java API to
> the VI API, which we use in CloudStack?
>
> Below is my createVmfsDatastore method.
>
> Thanks for any time you might be able to spend on this!
>
>  public static void createVmfsDatastore(String url, String username,
> String password, String datacenterName, String clusterName,
>
>  String datastoreName, String storageIpAddress, Integer portNumber,
> String iqn) throws Exception
>
> {
>
>  ServiceInstance si = new ServiceInstance(new URL(url), username,
> password, true);
>
>   ManagedEntity datacenter =
> si.getSearchIndex().findByInventoryPath(datacenterName);
>
>   if (datacenter == null)
>
>  {
>
>  throw new Exception("Datacenter '" + datacenterName + "' was not found."
> );
>
>  }
>
>   InventoryNavigator inventoryNavigator = newInventoryNavigator(si.getRootFolder());
>
>   ClusterComputeResource cluster =
> (ClusterComputeResource)inventoryNavigator.searchManagedEntity(
> "ClusterComputeResource", clusterName);
>
>   if (cluster == null)
>
>  {
>
>  throw new Exception("Cluster '" + clusterName + "' was not found.");
>
>  }
>
>   HostSystem[] aHostSystems = cluster.getHosts();
>
>   if (aHostSystems == null || aHostSystems.length == 0)
>
>  {
>
>  throw new Exception("There are no hosts in cluster '" + clusterName +
> "'.");
>
>  }
>
>   HostInternetScsiHbaStaticTarget target = newHostInternetScsiHbaStaticTarget();
>
>   target.setAddress(storageIpAddress);
>
>  target.setPort(portNumber);
>
>  target.setIScsiName(iqn);
>
>   HostInternetScsiHbaAuthenticationProperties auth = newHostInternetScsiHbaAuthenticationProperties();
>
>   String strAuthType = "chapRequired";
>
>   auth.setChapAuthEnabled(true);
>
>  auth.setChapInherited(false);
>
>  auth.setChapAuthenticationType(strAuthType);
>
>  auth.setChapName("admin");
>
>  auth.setChapSecret("solidfire");
>
>  auth.setMutualChapInherited(false);
>
>  auth.setMutualChapAuthenticationType(strAuthType);
>
>  auth.setMutualChapName("admin2");
>
>  auth.setMutualChapSecret("solidfire2");
>
>   target.setAuthenticationProperties(auth);
>
>   HostInternetScsiHbaStaticTarget[] aTargets = newHostInternetScsiHbaStaticTarget[1];
>
>   aTargets[0] = target;
>
>   for (HostSystem hostSystem : aHostSystems)
>
>  {
>
>  boolean iScsiHbaConfigured = false;
>
>    HostStorageSystem hostStorageSystem =
> hostSystem.getHostStorageSystem();
>
>    for (HostHostBusAdapter hba :
> hostStorageSystem.getStorageDeviceInfo().getHostBusAdapter())
>
>  {
>
>   if (hba instanceof HostInternetScsiHba)
>
>   {
>
>   // just finding an instance of HostInternetScsiHba means that we have
> found at least one configured iSCSI HBA
>
>   // at least one iSCSI HBA must be configured before a CloudStack user
> can use this host for iSCSI storage
>
>   iScsiHbaConfigured = true;
>
>      String iScsiHbaDevice = hba.getDevice();
>
>      hostStorageSystem.addInternetScsiStaticTargets(iScsiHbaDevice,
> aTargets);
>
>      hostStorageSystem.rescanHba(iScsiHbaDevice);
>
>   }
>
>  }
>
>    if (!iScsiHbaConfigured)
>
>  {
>
>   throw new Exception("An iSCSI HBA must be configured before a host can
> use iSCSI storage.");
>
>  }
>
>  }
>
>   HostDatastoreSystem hostDatastoreSystem =
> aHostSystems[0].getHostDatastoreSystem();
>
>   HostScsiDisk[] aHostScsiDisks =
> hostDatastoreSystem.queryAvailableDisksForVmfs(null);
>
>   HostStorageSystem hostStorageSystem =
> aHostSystems[0].getHostStorageSystem();
>
>   HostScsiDisk hostScsiDisk =
> getHostScsiDisk(hostStorageSystem.getStorageDeviceInfo().getScsiTopology(),
> aHostScsiDisks, iqn);
>
>   if (hostScsiDisk == null)
>
>  {
>
>  throw new Exception("A relevant SCSI disk could not be located to use to
> create a datastore.");
>
>  }
>
>   // just grab the first instance of VmfsDatastoreOption
>
>  VmfsDatastoreOption vmfsDatastoreOption =
> hostDatastoreSystem.queryVmfsDatastoreCreateOptions(hostScsiDisk.getDevicePath())[0];
>
>  VmfsDatastoreCreateSpec vmfsDatastoreCreateSpec =
> (VmfsDatastoreCreateSpec)vmfsDatastoreOption.getSpec();
>
>   // set the name of the datastore to be created
>
>  vmfsDatastoreCreateSpec.getVmfs().setVolumeName(datastoreName);
>
>   Datastore datastore =
> hostDatastoreSystem.createVmfsDatastore(vmfsDatastoreCreateSpec);
>
>   if (datastore == null)
>
>  {
>
>  throw new Exception ("Datastore '" + datastoreName + "' could not be
> created.");
>
>  }
>
>   System.out.println("Datastore '" + datastoreName + "' was successfully
> created.");
>
> }
>
>
> On Wed, May 29, 2013 at 7:50 PM, Mike Tutkowski <
> mike.tutkowski@solidfire.com> wrote:
>
>> OK - thanks, Vijay!
>>
>>
>> On Wed, May 29, 2013 at 5:05 PM, Vijayendra Bhamidipati <
>> vijayendra.bhamidipati@citrix.com> wrote:
>>
>>> Hi Mike,
>>>
>>> Your opensource vi java code will be close to what you would implement
>>> using the closed source vi sdk, so though you will have to rewrite some
>>> code, it should be possible to reuse much of your core code, especially
>>> with spec preparation and the like. Cloudstack code already has useful
>>> functions that let you retrieve dynamic properties etc from MORs, so you
>>> would need to replace some of your vi java code with those functions. You
>>> cannot however mix vi java with vi sdk in cloudstack, which uses only vi
>>> sdk. You also won't need to setup the vmware service context, it's already
>>> there in Vmwareresource.java, so you can use that.
>>>
>>> Regards,
>>> Vijay
>>>
>>>
>>> -----Original Message-----
>>> From: Mike Tutkowski [mailto:mike.tutkowski@solidfire.com]
>>> Sent: Wednesday, May 29, 2013 2:40 PM
>>> To: dev@cloudstack.apache.org
>>> Subject: VMware API Question
>>>
>>> Hi,
>>>
>>> I recently completed work in the new storage framework related to
>>> XenServer where I dynamically create a storage repository when attaching a
>>> newly created volume, if need be.
>>>
>>> I now need to implement the same concept for VMware.
>>>
>>> The idea is that I have zone-wide primary storage that is backed by a
>>> plug-in (all new in 4.2).
>>>
>>> When the user creates a volume, we still just add a row to the volumes
>>> table that describes this volume.
>>>
>>> When the user goes to attach this volume to a VM, the storage framework
>>> invokes my plug-in and my plug-in goes off to its SAN to create a
>>> volume...returning info like IQN.
>>>
>>> Next the VMware attach logic is invoked. In this dynamic kind of
>>> zone-wide storage, I need to detect in this VMware code that we do not yet
>>> have a datastore and create this datastore based on the IQN I returned
>>> earlier (and other info like IP address).
>>>
>>> I have this all working for XenServer and am now turning my attention to
>>> VMware.
>>>
>>> My question is simply this:
>>>
>>> It looks like VmwareResourse is written with VI SDK. Since I have my
>>> "create/delete datastore" logic already written in the VI Java API (
>>> http://vijava.sourceforge.net/), I was wondering if it's possible to
>>> mix these two approaches or if I will have to re-write my code.
>>>
>>> Thanks!
>>>
>>> --
>>> *Mike Tutkowski*
>>> *Senior CloudStack Developer, SolidFire Inc.*
>>> e: mike.tutkowski@solidfire.com
>>> o: 303.746.7302
>>> Advancing the way the world uses the
>>> cloud<http://solidfire.com/solution/overview/?video=play>
>>> *(tm)*
>>>
>>
>>
>>
>> --
>> *Mike Tutkowski*
>>  *Senior CloudStack Developer, SolidFire Inc.*
>> e: mike.tutkowski@solidfire.com
>> o: 303.746.7302
>> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
>> *™*
>>
>
>
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *™*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*