VMware vCloud

 View Only
  • 1.  List And Delete Media Within vDC

    Posted Jan 02, 2014 08:19 AM

    I am looking for a way to list media within a vDC to determine if it needs to be deleted before the vDC is removed. Also, I would like to delete any files found.

    Can anyone help me?



  • 2.  RE: List And Delete Media Within vDC

    Posted Jan 02, 2014 09:45 AM

    I have made progress. I figured out a method to delete media found in a vDC. It works, however I am getting an "Access is forbidden" message as the method loops through each media file. The file actually gets deleted, but exits out of the method because of the thrown error. Any help is appreciated. Code is below:

            internal static void FindMediaInvDC(string vDCName)

            {

                try

                {

                    Vdc vdc = FindVdc("MyOrg", vDCName);

                    List<ReferenceType> media = vdc.GetMediaRefs();

                   

                    foreach (ResourceReferenceType mediaFile in media)

                    {

                        Console.WriteLine("Name: " + mediaFile.name + " - " + "HREF " + mediaFile.href);                  

                        Media.DeleteMedia(objConn.client, mediaFile);

                    }

                }

                catch (Exception ex)

                {

                    throw new VCloudException(ex.Message);

                }

            }