VMwareDatastore IOperationSource <VMwareDatastore> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = VMwareDatastoreData.DeserializeVMwareDatastoreData(document.RootElement);

            return(new VMwareDatastore(_armClient, data));
        }
Exemplo n.º 2
0
        public async Task Exists()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

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

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

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

            Assert.AreEqual(datastore1.Id.Name, datastoreName);
        }
Exemplo n.º 3
0
        public async Task GetAllInSubscription()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

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

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastore datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(true, 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);
        }
Exemplo n.º 4
0
        public async Task GetAll()
        {
            var datastoreName        = Recording.GenerateAssetName("testdatastore");
            var _datastoreCollection = await GetVMwareDatastoreCollectionAsync();

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

            datastoreBody.MoRefId          = "datastore-11";
            datastoreBody.VCenterId        = VcenterId;
            datastoreBody.ExtendedLocation = _extendedLocation;
            // create datastore
            VMwareDatastore datastore1 = (await _datastoreCollection.CreateOrUpdateAsync(true, 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);
        }
Exemplo n.º 5
0
        internal static DatastoresList DeserializeDatastoresList(JsonElement element)
        {
            Optional <string> nextLink = default;
            IReadOnlyList <VMwareDatastoreData> value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    List <VMwareDatastoreData> array = new List <VMwareDatastoreData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(VMwareDatastoreData.DeserializeVMwareDatastoreData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new DatastoresList(nextLink.Value, value));
        }
Exemplo n.º 6
0
        public async Task CreateDelete()
        {
            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);
        }