Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 179681

Not able to fetch Storage Profiles

$
0
0

Hi All,

 

I am trying to fetch the storage profiles but when tried to do so i get an exception of Data Not Found. Can someone please tell me where my code is wrong. Here is my code:

 

        private static vCloudClient client = null;

        private static VcloudAdmin admin = null;

        private static AdminOrganization SearchAdminOrg(string orgName)

        {

            try

            {

                ReferenceType orgRef = admin.GetAdminOrgRefsByName()[orgName];

                return AdminOrganization.GetAdminOrgByReference(client, orgRef);

            }

            catch (Exception ex)

            {

                throw new VCloudException(ex.Message);

            }

        }

       

        private static bool ValidateServerCertificate(object sender, X509Certificate

        certificate, X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)

        {

            return true;

        }

 

 

        /// <summary>

        /// Defined a fake certificate policy for accepting the certificate temporarily

        /// </summary>

        public static void FakeCertificatePolicy()

        {

            ServicePointManager.ServerCertificateValidationCallback += new System.Net.

            Security.RemoteCertificateValidationCallback(ValidateServerCertificate);

        }

   

    protected void Button1_click(object sender, EventArgs e)

    {

            try

            {

                FakeCertificatePolicy();

                // here we can set the level               

                Logger.SourceLevel(Levels.All);

                Console.WriteLine("Vcloud Login");

 

 

                client = new vCloudClient("https://10.109.0.121", com.vmware.vcloud.sdk.constants.Version.V5_1);

                string username = "admin@BITS";

                string password = "VMware123";

                client.Login(username,password);

 

 

                Console.WriteLine(" Login Success\n");

 

 

                Console.WriteLine("Get Vcloud Admin");

                admin = client.GetVcloudAdmin();

                Console.WriteLine(" " + admin.Resource.href + "\n");

 

 

                Console.WriteLine("Get Admin Organization");

                AdminOrganization adminOrg = SearchAdminOrg("BITS");

                ReferenceType VdcRef = adminOrg.GetAdminVdcRefByName("BITSvDC");

                Vdc vdc = Vdc.GetVdcByReference(client,VdcRef);

                List<ReferenceType> storageref = vdc.GetVdcStorageProfileRefs();

                string[] sto = new string[storageref.Count()];

                int i = 0;

                foreach (ReferenceType stor in storageref)

                {

                    if (storageref.Count() == i)

                    {

                        sto[i] = stor.name;

                        i++;

                        Console.WriteLine(sto[i]);

                    }

                }

                DropDownList1.DataSource = null;

                DropDownList1.DataSource = sto;

                DropDownList1.DataBind();

            }

            catch(Exception em)

            {

                Logger.Log(TraceLevel.Critical, em.Message);

                throw new IOException(em.Message);

 

 

            }

        }


Viewing all articles
Browse latest Browse all 179681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>