本文整理汇总了C#中CloudServersProvider类的典型用法代码示例。如果您正苦于以下问题:C# CloudServersProvider类的具体用法?C# CloudServersProvider怎么用?C# CloudServersProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudServersProvider类属于命名空间,在下文中一共展示了CloudServersProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateServerNodeAsync
private async Task<CloudServersServerNode> CreateServerNodeAsync(CloudServersProvider provider, Server server, FlavorDetails[] flavors, ServerImage[] images)
{
FlavorDetails flavor = flavors.FirstOrDefault(i => server.Flavor != null && string.Equals(server.Flavor.Id, i.Id, StringComparison.OrdinalIgnoreCase));
try
{
if (flavor == null && server.Flavor != null)
flavor = await Task.Run(() => provider.GetFlavor(server.Flavor.Id));
}
catch (ResponseException)
{
// ignore
flavor = null;
}
ServerImage image = images.FirstOrDefault(i => server.Image != null && string.Equals(server.Image.Id, i.Id, StringComparison.OrdinalIgnoreCase));
try
{
if (image == null && server.Image != null)
image = await Task.Run(() => provider.GetImage(server.Image.Id));
}
catch (ResponseException)
{
// ignore
image = null;
}
return new CloudServersServerNode(provider, server, flavor, image);
}
开发者ID:rackerlabs,项目名称:rax-vsix,代码行数:28,代码来源:CloudServersEndpointNode.cs
示例2: TestInitialize
public void TestInitialize()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
Server server = provider.GetDetails(_server.Id);
if (server.Status != ServerState.Active)
Assert.Inconclusive("Could not run test because the server is in the '{0}' state (expected '{1}').", server.Status, ServerState.Active);
}
开发者ID:nick-o,项目名称:openstack.net,代码行数:7,代码来源:UserServerTests.cs
示例3: ClassInitialize
public static void ClassInitialize(TestContext testContext)
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
string serverName = UserComputeTests.UnitTestServerPrefix + Path.GetRandomFileName();
Flavor flavor = UserComputeTests.ListAllFlavorsWithDetails(provider).OrderBy(i => i.RAMInMB).ThenBy(i => i.DiskSizeInGB).FirstOrDefault();
if (flavor == null)
Assert.Inconclusive("Couldn't find a flavor to use for the test server.");
SimpleServerImage[] images = UserComputeTests.ListAllImages(provider).ToArray();
SimpleServerImage image = images.FirstOrDefault(i => i.Name.IndexOf("CentOS 6.0", StringComparison.OrdinalIgnoreCase) >= 0);
if (image == null)
Assert.Inconclusive("Couldn't find the CentOS 6.0 image to use for the test server.");
Stopwatch timer = Stopwatch.StartNew();
Console.Write("Creating server for image {0}...", image.Name);
NewServer server = provider.CreateServer(serverName, image.Id, flavor.Id);
Assert.IsNotNull(server);
Assert.IsFalse(string.IsNullOrEmpty(server.Id));
_password = server.AdminPassword;
_server = provider.WaitForServerActive(server.Id);
Assert.IsNotNull(_server);
Assert.AreEqual(server.Id, _server.Id);
Assert.AreEqual(ServerState.Active, _server.Status);
Console.WriteLine("done. {0} seconds", timer.Elapsed.TotalSeconds);
}
开发者ID:nick-o,项目名称:openstack.net,代码行数:29,代码来源:UserServerTests.cs
示例4: Should_Create_A_New_Complex_Server_In_DFW
public void Should_Create_A_New_Complex_Server_In_DFW()
{
var provider = new CloudServersProvider(_testIdentity);
_testServer2 = provider.CreateServer("net-sdk-test-server2", "d531a2dd-7ae9-4407-bb5a-e5ea03303d98", "2", metadata: new Metadata{{"Key1", "Value1"}, {"Key2", "Value2"}}, attachToPublicNetwork: true, attachToServiceNetwork: true);
Assert.IsNotNull(_testServer2);
Assert.IsNotNull(_testServer2.Id);
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例5: Should_Create_A_New_Server_In_DFW
public void Should_Create_A_New_Server_In_DFW()
{
var provider = new CloudServersProvider(_testIdentity);
_testServer = provider.CreateServer("net-sdk-test-server", "d531a2dd-7ae9-4407-bb5a-e5ea03303d98", "2");
Assert.IsNotNull(_testServer);
Assert.IsNotNull(_testServer.Id);
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例6: Should_Create_A_New_Complex_Server_In_DFW
public void Should_Create_A_New_Complex_Server_In_DFW()
{
var provider = new CloudServersProvider(_testIdentity);
_newTestServer2 = provider.CreateServer("net-sdk-test-server2", _initImage.Id, _initFlavor.Id, metadata: new Metadata { { "Key1", "Value1" }, { "Key2", "Value2" } }, attachToPublicNetwork: true, attachToServiceNetwork: true);
Assert.IsNotNull(_newTestServer2);
Assert.IsNotNull(_newTestServer2.Id);
}
开发者ID:amitgandhinz,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例7: Should_Create_A_New_Server_In_DFW
public void Should_Create_A_New_Server_In_DFW()
{
var provider = new CloudServersProvider(_testIdentity);
_newTestServer = provider.CreateServer("net-sdk-test-server", _initImage.Id, _initFlavor.Id);
Assert.IsNotNull(_newTestServer);
Assert.IsNotNull(_newTestServer.Id);
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例8: Should_Wait_Until_Server_Becomes_Active_Or_A_Maximum_Of_10_Minutes
public void Should_Wait_Until_Server_Becomes_Active_Or_A_Maximum_Of_10_Minutes()
{
var provider = new CloudServersProvider(_testIdentity);
var serverDetails = provider.WaitForServerActive(_testServer.Id);
Assert.IsNotNull(serverDetails);
Assert.AreEqual("ACTIVE", serverDetails.Status);
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:9,代码来源:CloudServersTests.cs
示例9: Init
public static void Init(TestContext context)
{
_testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
var provider = new CloudServersProvider(_testIdentity);
_initImage = provider.ListImages(imageName: "CentOS 6.3").First();
_initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();
}
开发者ID:amitgandhinz,项目名称:openstack.net,代码行数:9,代码来源:CloudServersTests.cs
示例10: Main
public static void Main(string[] args)
{
if (args.Length < 2 || args.Length > 3)
{
Console.WriteLine("Usage: {0} username api_key [region (US|UK)]", Environment.CommandLine);
Environment.Exit(1);
}
RackspaceImpersonationIdentity auth = new RackspaceImpersonationIdentity();
auth.Username = args[0];
auth.APIKey = args[1];
if (args.Length == 3)
{
if (args[2] != "UK" && args[2] != "US")
{
Console.WriteLine("region must be either US or UK", Environment.CommandLine);
Environment.Exit(1);
}
switch (args[2])
{
case "UK": { auth.CloudInstance = CloudInstance.UK; }; break;
case "US": { auth.CloudInstance = CloudInstance.Default; }; break;
}
}
else
{
auth.CloudInstance = CloudInstance.Default;
}
try
{
IIdentityProvider identityProvider = new CloudIdentityProvider();
var userAccess = identityProvider.Authenticate(auth);
}
catch (ResponseException ex2)
{
Console.WriteLine("Authentication failed with the following message: {0}", ex2.Message);
Environment.Exit(1);
}
var cloudServers = new CloudServersProvider(auth);
var servers = cloudServers.ListServers();
foreach (Server serv in servers)
{
var date = System.DateTime.Now;
var success = serv.CreateSnapshot(serv.Name + "_" + date.Year + "-" + date.Month + "-" + date.Day);
if (success)
{
Console.WriteLine("Image for server {0} has been created successfully.", serv.Name);
}
else
{
Console.WriteLine("Image for server {0} could not be created.", serv.Name);
}
}
}
开发者ID:nick-o,项目名称:CloudServersSnapshot,代码行数:56,代码来源:Program.cs
示例11: ClassCleanup
public static void ClassCleanup()
{
IComputeProvider provider = new CloudServersProvider(Bootstrapper.Settings.TestIdentity);
Stopwatch timer = Stopwatch.StartNew();
Console.Write(" Deleting...");
bool deleted = provider.DeleteServer(_server.Id);
Assert.IsTrue(deleted);
provider.WaitForServerDeleted(_server.Id);
Console.Write("done. {0} seconds", timer.Elapsed.TotalSeconds);
}
开发者ID:nick-o,项目名称:openstack.net,代码行数:12,代码来源:UserServerTests.cs
示例12: CloudServersServerNode
public CloudServersServerNode(CloudServersProvider provider, Server server, FlavorDetails flavor, ServerImage image)
{
if (provider == null)
throw new ArgumentNullException("provider");
if (server == null)
throw new ArgumentNullException("server");
this._provider = provider;
this._server = server;
this._flavor = flavor;
this._image = image;
}
开发者ID:rackerlabs,项目名称:rax-vsix,代码行数:12,代码来源:CloudServersServerNode.cs
示例13: Init
public static void Init(TestContext context)
{
_testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
var provider = new CloudServersProvider(_testIdentity);
_initImage = provider.ListImages(imageName: "CentOS 6.3").First();
_initFlavor = provider.ListFlavors().OrderBy(f => f.Id).First();
var netProvider = new CloudNetworksProvider(_testIdentity);
var networks = netProvider.ListNetworks();
_testNetwork = networks.FirstOrDefault(n => !n.Label.Equals("public") && !n.Label.Equals("private"));
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:13,代码来源:CloudServersTests.cs
示例14: Run
public async Task Run(string username, string apiKey, string region)
{
// Configure authentication
var identity = new CloudIdentity
{
Username = username,
APIKey = apiKey
};
var identityService = new CloudIdentityProvider(identity);
var result = identityService.Authenticate();
var serverService = new CloudServersProvider(identity, region, null, null);
var rackConnectService = new RackConnectService(identityService, region);
// Create a cloud server on your hybrid network
Console.WriteLine($"Looking up your RackConnect network in {region}...");
var networks = await rackConnectService.ListNetworksAsync();
var network = networks.FirstOrDefault();
if (network == null)
throw new Exception($"You do not have a Hybrid Cloud / RackConnect network configured in the {region} which is required to run this sample.");
Console.WriteLine("Creating sample cloud server... ");
// Ubuntu 14.04 LTS (Trusty Tahr) (PVHVM)
const string ubuntuImageId = "09de0a66-3156-48b4-90a5-1cf25a905207";
// 512MB Standard Instance
const string standardFlavorId = "2";
var requestedServer = serverService.CreateServer("sample", ubuntuImageId, standardFlavorId,
networks: new string[] {network.Id});
serverService.WaitForServerActive(requestedServer.Id);
Console.WriteLine("Allocating a public IP address...");
var ip = await rackConnectService.CreatePublicIPAsync(
new PublicIPCreateDefinition {ShouldRetain = true});
await ip.WaitUntilActiveAsync();
Console.WriteLine($"Acquired {ip.PublicIPv4Address}!");
Console.WriteLine("Assigning the public IP to the sample cloud server...");
await ip.AssignAsync(requestedServer.Id);
await ip.WaitUntilActiveAsync();
Console.WriteLine("Deleting sample cloud server...");
serverService.DeleteServer(requestedServer.Id);
Console.WriteLine("Deallocating the public IP address...");
await ip.DeleteAsync();
}
开发者ID:rackspace,项目名称:rackspace-net-sdk,代码行数:46,代码来源:AssignPublicIPSamples.cs
示例15: Main
static void Main(string[] args)
{
var identity = new CloudIdentity
{
Username = Environment.GetEnvironmentVariable("OPENSTACKNET_USER"),
APIKey = Environment.GetEnvironmentVariable("OPENSTACKNET_APIKEY")
};
var authProvider = new CloudIdentityProvider(identity);
Console.WriteLine("--- Servers ---");
var serversProvider = new CloudServersProvider(identity);
var servers = serversProvider.ListServers();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Id\t\t\t\t\tName");
Console.ResetColor();
Console.WriteLine();
foreach (var server in servers)
{
Console.WriteLine("{0}\t{1}", server.Id, server.Name);
}
Console.WriteLine();
Console.WriteLine("--- CDN Services ---");
var cdnService = new ContentDeliveryNetworkService(authProvider, "DFW");
var cdns = cdnService.ListServices();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Id\t\t\t\t\tName");
Console.ResetColor();
Console.WriteLine();
foreach (var cdn in cdns)
{
Console.WriteLine("{0}\t{1}", cdn.Id, cdn.Name);
}
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadLine();
}
开发者ID:openstacknetsdk,项目名称:Demos,代码行数:41,代码来源:Program.cs
示例16: Main
static void Main(string[] args)
{
const string region = "RegionOne";
// Configure OpenStack.NET
OpenStackNet.Configure(options => options.DefaultTimeout=TimeSpan.FromSeconds(5));
// Authenticate
var identityUrl = new Uri("http://example.com");
var user = new CloudIdentityWithProject();
var identity = new OpenStackIdentityProvider(identityUrl, user);
identity.Authenticate();
// Use legacy and new providers
var legacyNetworking = new CloudNetworksProvider(null, identity);
legacyNetworking.ListNetworks();
var networks = new NetworkingService(identity, region);
networks.ListNetworks();
var legacyCompute = new CloudServersProvider(null, identity);
legacyCompute.ListServers();
var compute = new ComputeService(identity, region);
compute.ListServers();
}
开发者ID:ravikamachi,项目名称:openstack.net,代码行数:24,代码来源:Program.cs
示例17: Should_Return_Exactly_Two_Images_With_Details
public void Should_Return_Exactly_Two_Images_With_Details()
{
var provider = new CloudServersProvider(_testIdentity);
var images = provider.ListImagesWithDetails(limit: 2);
Assert.IsTrue(images.Count() == 2);
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:7,代码来源:CloudServersTests.cs
示例18: Should_Return_At_Least_One_Image_With_Details_When_Searching_By_Valid_Change_Since_Date
public void Should_Return_At_Least_One_Image_With_Details_When_Searching_By_Valid_Change_Since_Date()
{
var validImage = _allImages.First();
var provider = new CloudServersProvider(_testIdentity);
var images = provider.ListImagesWithDetails(changesSince: validImage.Updated.AddSeconds(-1));
Assert.IsTrue(images.Any());
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例19: Should_Return_At_Least_One_Image_With_Details_When_Searching_By_Valid_Status
public void Should_Return_At_Least_One_Image_With_Details_When_Searching_By_Valid_Status()
{
var validImage = _allImages.First();
var provider = new CloudServersProvider(_testIdentity);
var images = provider.ListImagesWithDetails(imageStatus: validImage.Status);
Assert.IsTrue(images.Any());
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
示例20: Should_Return_One_Image_With_Details_When_Searching_By_Valid_Id
public void Should_Return_One_Image_With_Details_When_Searching_By_Valid_Id()
{
var validImage = _allImages.First(i => i.Server != null);
var provider = new CloudServersProvider(_testIdentity);
var images = provider.ListImagesWithDetails(server: validImage.Server.Id);
Assert.IsTrue(images.Any());
}
开发者ID:surgicalcoder,项目名称:openstack.net,代码行数:8,代码来源:CloudServersTests.cs
注:本文中的CloudServersProvider类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论