Example #1
0
        private void AttachVolume(Volume volume)
        {
            if (volume.AvailabilityZone == AvailabilityZone.None)
            {
                volume.AvailabilityZone = this.Subnet.AvailabilityZone;
            }
            string deviceId = string.Empty;

            switch (volume.AttachmentType)
            {
            case VolumeAttachmentType.Extension:
                deviceId = this.GetAvailableDevice();
                break;

            case VolumeAttachmentType.Root:
                deviceId = this.RootDeviceId;
                break;

            default:
                throw new NotSupportedException(volume.AttachmentType.ToString());
            }
            VolumeAttachment attachment = new VolumeAttachment(deviceId, this, volume);

            this.Template.Resources.Add(attachment.LogicalId, attachment);
        }
        public void volumeAttachmentIndexComplicated()
        {
            netClient.Core.APIClient.Instance.InitWebClient();
            netClient.Core.APIClient.Instance.Authenticate(apiRefreshToken);
            List <VolumeAttachment> volAttachments = VolumeAttachment.index(cloudID);

            netClient.Core.APIClient.Instance.InitWebClient();
        }
        public void volumeAttachmentIndexSimple()
        {
            netClient.Core.APIClient.Instance.InitWebClient();
            netClient.Core.APIClient.Instance.Authenticate(apiRefreshToken);
            List <VolumeAttachment> volAttachments = VolumeAttachment.index(cloudID);

            Assert.IsNotNull(volAttachments);
            netClient.Core.APIClient.Instance.InitWebClient();
        }
        public void volumeAttachFullEndToEnd()
        {
            netClient.Core.APIClient.Instance.InitWebClient();
            netClient.Core.APIClient.Instance.Authenticate(apiRefreshToken);

            string currentState = Server.show(serverID).state;
            int    waitLoops    = 0;

            if (currentState != "inactive")
            {
                try
                {
                    Server.terminate(serverID);
                }
                catch
                {
                }
            }

            while (currentState != "inactive" && (waitLoops <= maxWaitLoops || maxWaitLoops < 0))
            {
                Thread.Sleep(waitInterval);
                currentState = Server.show(serverID).state;
                waitLoops++;
            }
            if (waitLoops >= maxWaitLoops && maxWaitLoops >= 0)
            {
                Assert.Fail("Cannot start test because server is not in an available state.  Test has not started");
            }

            bool result = Server.launch(serverID);

            Assert.IsTrue(result);

            currentState = Server.show(serverID).state;

            while (currentState != "operational")
            {
                Thread.Sleep(waitInterval);
                currentState = Server.show(serverID).state;
            }

            string newVolumeID = Volume.create(cloudID, "testVolume " + Guid.NewGuid().ToString(), string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "100", volumeTypeID);

            string volStatus = Volume.show(cloudID, newVolumeID).status;

            while (volStatus != "available")
            {
                Thread.Sleep(waitInterval);
                volStatus = Volume.show(cloudID, newVolumeID).status;
            }

            Volume newVolume = Volume.show(cloudID, newVolumeID);
            //test volume created

            string volAttachID     = VolumeAttachment.create(cloudID, "/dev/xvh", Server.show(serverID).currentInstance.ID, newVolumeID);
            string volAttachStatus = VolumeAttachment.show(cloudID, volAttachID).state;

            while (volAttachStatus != "attached")
            {
                Thread.Sleep(waitInterval);
                volStatus = VolumeAttachment.show(cloudID, volAttachID).state;
            }

            VolumeAttachment newVolumeAttachment = VolumeAttachment.show(cloudID, volAttachID);
            //test volume attachment stats

            bool volumeDetachStatus = VolumeAttachment.destroy(cloudID, volAttachID);

            Assert.IsTrue(volumeDetachStatus);
            bool volumeDestroyStatus = Volume.destroy(cloudID, newVolumeID);

            Assert.IsTrue(volumeDestroyStatus);
            bool serverTerminateCall = Server.terminate(serverID);

            Assert.IsTrue(serverTerminateCall);
        }