Example #1
0
        public IVimDatastore[] GetDatastoresAndProperties(ManagedObjectAndProperties[] managedObjectsAndProperties)
        {
            List <Datastore> datastoreList = new List <Datastore>();

            foreach (ManagedObjectAndProperties objectsAndProperty in managedObjectsAndProperties)
            {
                if (!(objectsAndProperty.ManagedObject.type != "Datastore") && objectsAndProperty.Properties != null)
                {
                    Datastore datastore = new Datastore(this.VcService, objectsAndProperty.ManagedObject);
                    datastore.GetCommonProperties(objectsAndProperty.Properties);
                    if (!string.IsNullOrEmpty(datastore.DsProperties.RemoteId))
                    {
                        datastoreList.Add(datastore);
                    }
                }
            }
            return((IVimDatastore[])datastoreList.ToArray());
        }
Example #2
0
        public void GetCommonProperties(Dictionary <string, object> properties)
        {
            for (int index = 0; index < 3; ++index)
            {
                if (properties == null)
                {
                    Datastore.tracer.TraceInformation("Datastore properties were null.");
                }
                else if (properties.Count != Datastore.VCProperties.Length)
                {
                    IEnumerable <string> strings = ((IEnumerable <string>)Datastore.VCProperties).Where <string>((Func <string, bool>)(p => !properties.ContainsKey(p)));
                    if (strings != null)
                    {
                        Datastore.tracer.TraceInformation("Did not get all the expected properties for datastore {0}. We are missing: {1}", (object)(properties.ContainsKey("summary.name") ? (string)properties["summary.name"] : "unknown"), (object)string.Join(", ", strings));
                        if (strings.Count <string>() == 1 && strings.Contains <string>("summary.uncommitted"))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
                Thread.Sleep(1000);
                Datastore.tracer.TraceInformation("Getting datastore properties.");
                properties = this.GetProperties(Datastore.VCProperties);
            }
            if (properties.ContainsKey("summary.name"))
            {
                this._dsProperties.Name = (string)properties["summary.name"];
            }
            if (properties.ContainsKey("host"))
            {
                DatastoreHostMount[] property = (DatastoreHostMount[])properties["host"];
                if (property.Length != 0)
                {
                    this._dsProperties.Url = property[0].mountInfo.path;
                }
            }
            if (properties.ContainsKey("summary.capacity"))
            {
                this._dsProperties.Capacity = (long)properties["summary.capacity"];
            }
            if (properties.ContainsKey("summary.freeSpace"))
            {
                this._dsProperties.FreeSpace = (long)properties["summary.freeSpace"];
            }
            long num = 0;

            if (properties.ContainsKey("summary.uncommitted"))
            {
                num = (long)properties["summary.uncommitted"];
            }
            this._dsProperties.ProvisionedSpace = this._dsProperties.Capacity - this._dsProperties.FreeSpace + num;
            if (properties.ContainsKey("summary.type"))
            {
                this._dsProperties.Type = (string)properties["summary.type"];
            }
            if (properties.ContainsKey("info"))
            {
                DatastoreInfo property1 = properties["info"] as DatastoreInfo;
                if (property1 != null)
                {
                    this._dsProperties.MaxFileSize = property1.maxFileSize;
                }
                VmfsDatastoreInfo property2 = properties["info"] as VmfsDatastoreInfo;
                if (property2 != null && property2.vmfs != null)
                {
                    this._dsProperties.Version = property2.vmfs.version;
                }
            }
            this._dsProperties.RemoteId = Datastore.GetRemoteId(this._dsProperties.Url);
            this.Name = this._dsProperties.Name;
        }