コード例 #1
0
        public async Task GetAllInSubscription()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                ExtendedLocationType = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastoreResource datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            datastore1 = null;
            await foreach (var datastore in DefaultSubscription.GetVMwareDatastoresAsync())
            {
                if (datastore.Data.Name == datastoreName)
                {
                    datastore1 = datastore;
                }
            }
            Assert.NotNull(datastore1);
        }
コード例 #2
0
        public async Task Exists()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                ExtendedLocationType = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastoreResource datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            // check for exists datastore
            bool exists = await _datastoreCollection.ExistsAsync(datastoreName);

            Assert.IsTrue(exists);
        }
コード例 #3
0
        public async Task GetAll()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

            var _extendedLocation = new ExtendedLocation()
            {
                Name = CustomLocationId,
                ExtendedLocationType = EXTENDED_LOCATION_TYPE
            };
            var datastoreBody = new VMwareDatastoreData(DefaultLocation);

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastoreResource datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, datastoreBody)).Value;

            Assert.IsNotNull(datastore1);
            Assert.AreEqual(datastore1.Id.Name, datastoreName);
            int count = 0;

            await foreach (var cluster in _datastoreCollection.GetAllAsync())
            {
                count++;
            }
            Assert.GreaterOrEqual(count, 1);
        }