-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathComputeService.cs
More file actions
48 lines (40 loc) · 1.69 KB
/
Copy pathComputeService.cs
File metadata and controls
48 lines (40 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Threading;
using System.Threading.Tasks;
using OpenStack.Authentication;
using OpenStack.Compute.v2_6.Serialization;
namespace OpenStack.Compute.v2_6
{
/// <inheritdoc />
public class ComputeService
{
private readonly ComputeApi _computeApi;
/// <summary />
public ComputeService(IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl = false)
{
_computeApi = new ComputeApi(ServiceType.Compute, authenticationProvider, region, useInternalUrl);
}
#region Servers
/// <summary />
public virtual async Task<IPage<ServerReference>> ListServerReferencesAsync(ServerListOptions options = null, CancellationToken cancellationToken = default(CancellationToken))
{
return await _computeApi.ListServerSummariesAsync<ServerCollection>(options, cancellationToken);
}
/// <summary />
public virtual Task<Console> GetConsoleAsync(Identifier serverId, ConsoleProtocol protocol, RemoteConsoleType type, CancellationToken cancellationToken = default(CancellationToken))
{
return _computeApi.GetConsoleAsync<Console>(serverId, protocol, type, cancellationToken);
}
#endregion
#region Keypairs
/// <summary />
public virtual Task<KeyPair> CreateKeyPairAsync(string name, KeyPairType? type = null, CancellationToken cancellationToken = default(CancellationToken))
{
var keyPair = new KeyPairDefinition(name)
{
Type = type
};
return _computeApi.CreateKeyPairAsync<KeyPair>(keyPair, cancellationToken);
}
#endregion
}
}