iSCSI Initiator Configuration using C#
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
iSCSI Initiator Configuration using C#

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Storage System
Author Message
Charlie Becker
Guest





Posted: Fri Apr 30, 2004 12:01 am    Post subject: iSCSI Initiator Configuration using C# Reply with quote

I'm trying to configure the Microsoft iSCSI Initiator programatically from within C#. I've found very little documentation about how to do this using WMI. Basically I want to:

Create a target portal
Once a target has been discovered, log in to the target persistently

If this can't be done with WMI, are there any examples, good documentation, or can someone point me to the correct methods to do this using the iSCSI DDK (using C).

Thanks!

Charlie Becker
Back to top
Jeff Goldner [MS]
Guest





Posted: Fri Apr 30, 2004 8:15 am    Post subject: Re: iSCSI Initiator Configuration using C# Reply with quote

There is an SDK available under NDA that has documentation of all the WMI
classes and Win32 APIs.

Basically, you already have the MOFs (which get copied to C:\Program
Files\Microsoft\Microsoft iSCSI Initiator when you install the initiator.
To do what you want, create a new instance of
MSiSCSIInitiator_SendTargetPortalClass to create a new target portal and
then call the Login method on the MSiSCSIInitiator_TargetClass class and
specify IsPersistent parameter as TRUE.

This will work with C#, VBScript, etc.

Jeff [MSFT]

"Charlie Becker" <anonymous@discussions.microsoft.com> wrote in message
news:1BBD227C-1691-4714-9A80-C5E1090BC931@microsoft.com...
Quote:
I'm trying to configure the Microsoft iSCSI Initiator programatically from
within C#. I've found very little documentation about how to do this
using WMI. Basically I want to:

Create a target portal
Once a target has been discovered, log in to the target persistently

If this can't be done with WMI, are there any examples, good
documentation, or can someone point me to the correct methods to do this
using the iSCSI DDK (using C).

Thanks!

Charlie Becker

Back to top
Charlie Becker
Guest





Posted: Sat May 01, 2004 1:01 am    Post subject: Re: iSCSI Initiator Configuration using C# Reply with quote

Jeff, thanks for your message. I tried to implement what you said but I'm running into a lot of problems ... mostly because the documentation is so light... I'm getting an error "Invalid method Parameters(s)" on the last line of the code below. I think the biggest problem is not knowing what properties we need to fill in or not. Can you look at the code and give me any recommendations? Am I on the right track

BTW, my company does have a NDA with Microsoft, who would I contact about getting full documentation for WMI and win32 api calls

Thanks

Charli

ManagementClass mc_SendTargetPortalClass = new ManagementClass (@"root\wmi:MSiSCSIInitiator_SendTargetPortalClass")
ManagementObject mo_SendTargetPortalClass = mc_SendTargetPortalClass.CreateInstance()
mo_SendTargetPortalClass["PortalAddress"] = "127.0.0.1"
mo_SendTargetPortalClass["PortalPort"] = 3260
/
uint32 Login
[in,Description("Indicates whether this is informational session") : amended] boolean IsInformationalSession,
[in,Description("Initiator Port Number") : amended] uint32 InitiatorPortNumber
[in,Description("Target Portal") : amended] MSiSCSIInitiator_Portal TargetPortal
[in,Description("Security Flags") : amended, ISCSI_SECURITY_FLAGS_QUALIFIERS] uint64 SecurityFlags
[in,Description("Mappings") : amended] MSiSCSIInitiator_TargetMapping Mappings[]
[in,Description("Login Options") : amended] MSiSCSIInitiator_TargetLoginOptions LoginOptions
[in,Description("Key") : amended] uint8 Key[]
[in,Description("IsPersistent") : amended] boolean IsPersistent
[out,Description("Unique Session ID") : amended] string UniqueSessionId
[out,Description("Unique Connection ID") : amended] string UniqueConnectionId)
*

//Create Objects Required, then pass them in..
ManagementClass mc_TargetPortal = new ManagementClass (@"root\wmi:MSiSCSIInitiator_Portal")
ManagementObject mo_TargetPortal = mc_TargetPortal.CreateInstance()
mo_TargetPortal["Address"] = "127.0.0.1"
mo_TargetPortal["Port"] = 3260

ManagementClass mc_TargetMappings = new ManagementClass (@"root\wmi:MSiSCSIInitiator_TargetMappings")
ManagementObject[] mo_TargetMappings = new ManagementObject[1]
mo_TargetMappings[0] = mc_TargetMappings.CreateInstance()
mo_TargetMappings[0]["TargetName"] = "local"

ManagementClass mc_TargetLoginOptions = new ManagementClass (@"root\wmi:MSiSCSIInitiator_TargetLoginOptions")
ManagementObject mo_TargetLoginOptions = mc_TargetLoginOptions.CreateInstance()
int[] pwd ={0}
int[] uname ={0}
mo_TargetLoginOptions["Password"] = pwd
mo_TargetLoginOptions["Username"]= uname

int[] keyVal = {0}

//Get the object on which the method will be invoke
ManagementClass processClass = new ManagementClass(@"root\wmi:MSiSCSIInitiator_TargetClass")

//Get an input parameters object for this metho
ManagementBaseObject inParams = processClass.GetMethodParameters("Login")

//Fill in input parameter value
inParams["IsInformationalSession"] = false; //boolea
inParams["InitiatorPortNumber"] = 3260; //uint3
inParams["TargetPortal"] = mo_TargetPortal; //MSiSCSIInitiator_Porta
inParams["SecurityFlags"] = 0; //uint6
inParams["Mappings"] = mo_TargetMappings; //MSiSCSIInitiator_TargetMappings [
inParams["LoginOptions"] = mo_TargetLoginOptions; //MSiSCSIInitiator_TargetLoginOption
inParams["Key"] = keyVal; //uint8 [
inParams["IsPersistent"] = true; //boolea

//Execute the metho
ManagementBaseObject outParams = processClass.InvokeMethod ("Login", inParams, null);
Back to top
Jeff Goldner [MS]
Guest





Posted: Fri May 14, 2004 8:59 am    Post subject: Re: iSCSI Initiator Configuration using C# Reply with quote

Send mail to iscsi@microsoft.com

"Charlie Becker" <anonymous@discussions.microsoft.com> wrote in message
news:69C8AEFD-9461-4785-A77E-BF87218B85C9@microsoft.com...
Quote:
Jeff, thanks for your message. I tried to implement what you said but I'm
running into a lot of problems ... mostly because the documentation is so
light... I'm getting an error "Invalid method Parameters(s)" on the last
line of the code below. I think the biggest problem is not knowing what
properties we need to fill in or not. Can you look at the code and give
me any recommendations? Am I on the right track?

BTW, my company does have a NDA with Microsoft, who would I contact about
getting full documentation for WMI and win32 api calls?

Thanks!

Charlie

ManagementClass mc_SendTargetPortalClass = new ManagementClass
(@"root\wmi:MSiSCSIInitiator_SendTargetPortalClass");
ManagementObject mo_SendTargetPortalClass =
mc_SendTargetPortalClass.CreateInstance();
mo_SendTargetPortalClass["PortalAddress"] = "127.0.0.1";
mo_SendTargetPortalClass["PortalPort"] = 3260;
/*
uint32 Login(
[in,Description("Indicates whether this is informational session") :
amended] boolean IsInformationalSession,
[in,Description("Initiator Port Number") : amended] uint32
InitiatorPortNumber,
[in,Description("Target Portal") : amended] MSiSCSIInitiator_Portal
TargetPortal,
[in,Description("Security Flags") : amended,
ISCSI_SECURITY_FLAGS_QUALIFIERS] uint64 SecurityFlags,
[in,Description("Mappings") : amended] MSiSCSIInitiator_TargetMapping
Mappings[],
[in,Description("Login Options") : amended]
MSiSCSIInitiator_TargetLoginOptions LoginOptions,
[in,Description("Key") : amended] uint8 Key[],
[in,Description("IsPersistent") : amended] boolean IsPersistent,
[out,Description("Unique Session ID") : amended] string UniqueSessionId,
[out,Description("Unique Connection ID") : amended] string
UniqueConnectionId);
*/

//Create Objects Required, then pass them in...
ManagementClass mc_TargetPortal = new ManagementClass
(@"root\wmi:MSiSCSIInitiator_Portal");
ManagementObject mo_TargetPortal = mc_TargetPortal.CreateInstance();
mo_TargetPortal["Address"] = "127.0.0.1";
mo_TargetPortal["Port"] = 3260;

ManagementClass mc_TargetMappings = new ManagementClass
(@"root\wmi:MSiSCSIInitiator_TargetMappings");
ManagementObject[] mo_TargetMappings = new ManagementObject[1];
mo_TargetMappings[0] = mc_TargetMappings.CreateInstance();
mo_TargetMappings[0]["TargetName"] = "local";

ManagementClass mc_TargetLoginOptions = new ManagementClass
(@"root\wmi:MSiSCSIInitiator_TargetLoginOptions");
ManagementObject mo_TargetLoginOptions =
mc_TargetLoginOptions.CreateInstance();
int[] pwd ={0};
int[] uname ={0};
mo_TargetLoginOptions["Password"] = pwd;
mo_TargetLoginOptions["Username"]= uname;

int[] keyVal = {0};

//Get the object on which the method will be invoked
ManagementClass processClass = new
ManagementClass(@"root\wmi:MSiSCSIInitiator_TargetClass");

//Get an input parameters object for this method
ManagementBaseObject inParams = processClass.GetMethodParameters("Login");

//Fill in input parameter values
inParams["IsInformationalSession"] = false; //boolean
inParams["InitiatorPortNumber"] = 3260; //uint32
inParams["TargetPortal"] = mo_TargetPortal; //MSiSCSIInitiator_Portal
inParams["SecurityFlags"] = 0; //uint64
inParams["Mappings"] = mo_TargetMappings;
//MSiSCSIInitiator_TargetMappings []
inParams["LoginOptions"] = mo_TargetLoginOptions;
//MSiSCSIInitiator_TargetLoginOptions
inParams["Key"] = keyVal; //uint8 []
inParams["IsPersistent"] = true; //boolean

//Execute the method
ManagementBaseObject outParams = processClass.InvokeMethod ("Login",
inParams, null);
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Storage System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB