public Instance CreateInstance(string instanceName, string imageId, string keypairName, string flavorId, Func<decimal, bool> progressCallback)
 {
     Instance instance = CreateInstance(instanceName, imageId, keypairName, flavorId, _identity);
     bool instanceFinished = false;
     var progress = 0;
     var progressStep = 5;
     InstanceManager instanceManager = new InstanceManager(_identity);
     if (instanceName != null)
     {
         Instance currentInstance = instanceManager.GetInstance(new Instance() { Name = instanceName });
         while (!instanceFinished)
         {
             currentInstance = instanceManager.GetInstance(currentInstance.Id);
             if (currentInstance.status == InstanceStatus.ACTIVE)
             {
                 instanceFinished = true;
                 progress = 100;
             }
             if (currentInstance.status == InstanceStatus.ERROR)
             {
                 throw new Exception("Instance failed to create!");
             }
             if (progress != 100)
             {
                 if (!instanceFinished && progress + progressStep < 98)
                     progress += progressStep;
             }
             progressCallback(progress);
             Thread.Sleep(10000);
         }
     }
     return instance;
 }
 public void CreateSnapshot()
 {
     Identity identity = new Identity()
     {
         AuthEndpoint = "http://192.168.1.149:5000/v2.0",
         Password = "******",
         TenantName = "admin",
         Username = "******",
     };
     InstanceManager instanceManager = new InstanceManager(identity);
     var firstInstaceId = instanceManager.ListInstances(identity)[0].Id;
     var snapshotName = instanceManager.CreateSnapshot(firstInstaceId, (x) => { return true; });
     ImageManager imageManager = new ImageManager(identity);
     OpenstackImage image = imageManager.GetImage(new OpenstackImage() { Name = snapshotName });
     Assert.AreNotSame(image, null);
 }
 public void DeleteSnapshot()
 {
     Identity identity = new Identity()
     {
         AuthEndpoint = "http://192.168.1.149:5000/v2.0",
         Password = "******",
         TenantName = "admin",
         Username = "******",
     };
     InstanceManager instanceManager = new InstanceManager(identity);
     var firstInstaceId = "a9a8ba2c-fc26-4ecc-8419-ca9b7cf326a2";
     var snapshotName = instanceManager.CreateSnapshot(firstInstaceId, (x) => { return true; });
     ImageManager imageManager = new ImageManager(identity);
     OpenstackImage image = imageManager.GetImage(new OpenstackImage() { Name = snapshotName });
     Assert.AreNotSame(image, null);
     imageManager.Delete(image.Id);
     image = imageManager.GetImage(new OpenstackImage() { Name = snapshotName });
     Assert.AreEqual(image, null);
 }
 public void DownloadSnapshot()
 {
     Identity identity = new Identity()
     {
         AuthEndpoint = "http://192.168.1.118:5000/v2.0",
         Password = "******",
         TenantName = "admin",
         Username = "******",
     };
     InstanceManager instanceManager = new InstanceManager(identity);
     var firstInstaceId = "f71e50ab-cf33-4491-b6f4-8887b29b2c22";
     var snapshotName = instanceManager.CreateSnapshot(firstInstaceId, (x) => { return true; });
     ImageManager imageManager = new ImageManager(identity);
     OpenstackImage image = imageManager.GetImage(new OpenstackImage() { Name = snapshotName });
     Assert.AreNotSame(image, null);
     image = imageManager.GetImage(image.Id);
     imageManager.DownloadImage(image.Id, @"E:\\AtlasVHDS\\" + image.Name + "." + image.DiskFormat);
     imageManager.Delete(image.Id);
     image = imageManager.GetImage(new OpenstackImage() { Name = snapshotName });
     Assert.AreEqual(image, null);
 }
        public void ListInstances()
        {
            Identity identity = new Identity()
            {
                AuthEndpoint = "http://192.168.1.149:5000/v2.0",
                Password = "******",
                TenantName = "admin",
                Username = "******",

            };

            InstanceManager instanceManager = new InstanceManager(identity);
            IList<Instance> instances = instanceManager.ListInstances();

            Assert.IsTrue(instances.Count != 0);
        }