Skip to content

Commit 344efdf

Browse files
committed
updated to bring back cloud service method on the virtual networking client to bring back a paas deployed or iaas deployed cluster
1 parent 9df4ef8 commit 344efdf

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

Elastacloud.AzureManagement.Fluent/Clients/Interfaces/IVirtualNetworkingClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,6 @@ interface IVirtualNetworkingClient
4444
/// Removes a subnet from the network configuration
4545
/// </summary>
4646
void RemoveSubnet(string networkName, string subnetName);
47+
CloudServiceNetworking GetCloudServiceSubnetCollection(string cloudServiceName);
4748
}
4849
}

Elastacloud.AzureManagement.Fluent/Clients/VirtualNetworkClient.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,17 @@ public void RemoveSubnet(string networkName, string subnetName)
154154
command.Execute();
155155
}
156156

157+
public CloudServiceNetworking GetCloudServiceSubnetCollection(string cloudServiceName)
158+
{
159+
var command = new GetVirtualNetworkAndSubnetsFromCloudServiceCommand(cloudServiceName)
160+
{
161+
SubscriptionId = SubscriptionId,
162+
Certificate = ManagementCertificate
163+
};
164+
command.Execute();
165+
return command.NetworkDetails;
166+
}
167+
157168
#region Network Details
158169
public class SubnetTag
159170
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/************************************************************************************************************
2+
* This software is distributed under a GNU Lesser License by Elastacloud Limited and it is free to *
3+
* modify and distribute providing the terms of the license are followed. From the root of the source the *
4+
* license can be found in /Resources/license.txt *
5+
* *
6+
* Web at: www.elastacloud.com *
7+
* Email: [email protected] *
8+
************************************************************************************************************/
9+
10+
using System.Collections.Generic;
11+
using System.IO;
12+
using System.Linq;
13+
using System.Net;
14+
using System.Xml.Linq;
15+
using Elastacloud.AzureManagement.Fluent.Commands.Parsers;
16+
using Elastacloud.AzureManagement.Fluent.Commands.Services;
17+
using Elastacloud.AzureManagement.Fluent.Helpers;
18+
using Elastacloud.AzureManagement.Fluent.Types.VirtualNetworks;
19+
20+
namespace Elastacloud.AzureManagement.Fluent.Commands.VirtualNetworks
21+
{
22+
/// <summary>
23+
/// Registers a virtual machine image for either Linux or Windowss
24+
/// </summary>
25+
public class GetVirtualNetworkAndSubnetsFromCloudServiceCommand : ServiceCommand
26+
{
27+
// https://management.core.windows.net/<subscription-id>/services/networking/<virtual-network-name>
28+
/// <summary>
29+
/// Lists all images that are registered in your subscriptions
30+
/// </summary>
31+
internal GetVirtualNetworkAndSubnetsFromCloudServiceCommand(string cloudService)
32+
{
33+
AdditionalHeaders["x-ms-version"] = "2012-03-01";
34+
OperationId = "hostedservices";
35+
ServiceType = "services";
36+
HttpCommand = cloudService + "/deploymentslots/Production";
37+
HttpVerb = HttpVerbGet;
38+
NetworkDetails = new CloudServiceNetworking();
39+
}
40+
41+
public CloudServiceNetworking NetworkDetails { get; private set; }
42+
43+
/// <summary>
44+
/// Initially used via a response callback for commands which expect a async response
45+
/// </summary>
46+
/// <param name="webResponse">the HttpWebResponse that will be sent back to the user from the request</param>
47+
protected override void ResponseCallback(HttpWebResponse webResponse)
48+
{
49+
XDocument document;
50+
51+
using (var reader = new StreamReader(webResponse.GetResponseStream()))
52+
{
53+
document = XDocument.Parse(reader.ReadToEnd());
54+
}
55+
var root = document.Descendants(Namespaces.NsWindowsAzure + "SubnetName");
56+
NetworkDetails.Subnets = root.Select(subnet => subnet.Value).Distinct().ToList();
57+
var networkNode = document.Descendants(Namespaces.NsWindowsAzure + "VirtualNetworkName").FirstOrDefault();
58+
NetworkDetails.VirtualNetworkName = networkNode == null ? null : networkNode.Value;
59+
60+
SitAndWait.Set();
61+
}
62+
63+
/// <summary>
64+
/// returns the name of the command
65+
/// </summary>
66+
public override string ToString()
67+
{
68+
return "GetVirtualNetworkAndSubnetsFromCloudServiceCommand";
69+
}
70+
}
71+
}

Elastacloud.AzureManagement.Fluent/Elastacloud.AzureManagement.Fluent.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
<Compile Include="Commands\Virtual Machines\RestartVirtualMachineCommand.cs" />
231231
<Compile Include="Commands\Virtual Machines\StartVirtualMachineCommand.cs" />
232232
<Compile Include="Commands\Virtual Machines\CreateWindowsVirtualMachineDeploymentCommand.cs" />
233+
<Compile Include="Commands\Virtual Networks\GetVirtualNetworkAndSubnetsFromCloudServiceCommand.cs" />
233234
<Compile Include="Commands\Virtual Networks\GetAvailableIpAddressesCommand.cs" />
234235
<Compile Include="Commands\Virtual Networks\SetVirtualNetworkConfigCommand.cs" />
235236
<Compile Include="Commands\Virtual Networks\GetVirtualNetworkConfigCommand.cs" />

Elastacloud.FluentManagement.FSTest/VirtualMachines.fsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ vnClient.RemoveSubnet("skynet", "cluster")
7070
let images = vmClient.GetCurrentUbuntuImage()
7171
let attack = vmClient.GetHostDetails("sparkattack")
7272
let attack1 = vmClient.GetHostDetails("isaacfliptest1")
73+
let csnetwork = vnClient.GetCloudServiceSubnetCollection("isaacfliptest7")
7374
attack.[0].Endpoints
7475
// take a look at the testing of the service bus namespace create
7576
let sbClient = ServiceBusClient(subscriptionId, (getFromBizsparkPlus subscriptionId))

0 commit comments

Comments
 (0)