Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
carolynvs committed Sep 3, 2015
2 parents f64e7b6 + 5a4b9fe commit 9ad6ce5
Show file tree
Hide file tree
Showing 15 changed files with 182 additions and 68 deletions.
5 changes: 5 additions & 0 deletions GitVersionConfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assembly-versioning-scheme: Major
branches:
develop:
tag: alpha
mode: ContinuousDeployment
2 changes: 1 addition & 1 deletion build/Rackspace.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<tags>openstack rackspace rackconnect</tags>
<dependencies>
<group targetFramework="4.5">
<dependency id="openstack.net" version="[1.5.0,2.0)" />
<dependency id="openstack.net" version="[1.5.0.1,2.0)" />
</group>
</dependencies>
</metadata>
Expand Down
22 changes: 18 additions & 4 deletions build/build.proj
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask TaskName="GitVersionTask.GetVersion" AssemblyFile="..\packages\GitVersionTask\GitVersionTask.dll"/>

<PropertyGroup>
<Configuration>Debug</Configuration>
<Version>0.1.0</Version>

<Version>$(bamboo_GitVersion_NuGetVersion)</Version>
<NuGet>$(LocalAppData)\NuGet\NuGet.exe</NuGet>
<Paket>..\.paket\paket.exe</Paket>
<MSBuild>&quot;$(MSBuildToolsPath)\MSBuild.exe&quot;</MSBuild>
Expand All @@ -24,7 +25,13 @@
<CallTarget Targets="Package" />
</Target>

<Target Name="Build" DependsOnTargets="RestorePackages">
<Target Name="GitVersion" DependsOnTargets="RestorePackages" Condition=" '$(Version)' == '' ">
<GitVersionTask.GetVersion SolutionDirectory="..">
<Output TaskParameter="NuGetVersion" PropertyName="Version" />
</GitVersionTask.GetVersion>
</Target>

<Target Name="Build" DependsOnTargets="RestorePackages;GitVersion">
<Exec Command="$(MSBuild) ..\Rackspace.sln /p:Configuration=$(Configuration) /nologo /v:minimal" />
</Target>

Expand All @@ -37,6 +44,7 @@
</Target>

<Target Name="RestorePackages" DependsOnTargets="DownloadPaket">
<Delete Files="..\paket.lock" />
<Exec Command="$(Paket) install"/>
</Target>

Expand Down Expand Up @@ -72,7 +80,7 @@
<Exec Command="$(NuGet) pack Rackspace.nuspec -OutputDirectory ..\artifacts\packages -Prop Configuration=$(Configuration) -Version $(Version) -Symbols"/>
</Target>

<Target Name="Publish" DependsOnTargets="DownloadNuGet">
<Target Name="PublishNuGet" DependsOnTargets="DownloadNuGet;GitVersion">
<Exec Command="@powershell -NoProfile -ExecutionPolicy unrestricted -File check-nuget-version-exists.ps1 $(Version)" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldPublishToNuGet" />
</Exec>
Expand All @@ -83,4 +91,10 @@
<Exec Command="$(NuGet) push ..\artifacts\packages\Rackspace.$(Version).nupkg %25BAMBOO_NUGET_PASSWORD%25"
Condition=" '$(ShouldPublishToNuGet)' == 'True' " />
</Target>

<Target Name="PublishMyGet" DependsOnTargets="DownloadNuGet;GitVersion">
<!-- We don't need to check for existing versions because MyGet lets you overwrite -->
<!-- The environment variable BAMBOO_MYGET_PASSWORD comes from the nuget.password variable defined on the rackspace.net plan in Bamboo -->
<Exec Command="$(NuGet) push ..\artifacts\packages\Rackspace.$(Version).nupkg %25BAMBOO_MYGET_PASSWORD%25 -Source https://www.myget.org/F/rackspace/api/v2"/>
</Target>
</Project>
8 changes: 7 additions & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
source https://www.myget.org/F/openstacknetsdk/api/v2
source https://nuget.org/api/v2

nuget openstack.net !>= 1.5.0 prerelease
nuget openstack.net !>= 1.5.0.1 prerelease

nuget GitVersionTask 3.1.1
nuget moq !>= 4.2
nuget EWSoftware.SHFB 2015.7.25
nuget EWSoftware.SHFB.NETFramework 4.6.0
nuget xunit !~> 2.0.0
nuget xunit.runner.console !~> 2.0.0
nuget xunit.runner.visualstudio !~> 2.0.1

# For the samples
source https://www.myget.org/F/rackspace/api/v2
nuget Rackspace prerelease
54 changes: 40 additions & 14 deletions samples/Rackspace.Samples/AssignPublicIPSamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
using System.Threading.Tasks;
using net.openstack.Core.Domain;
using net.openstack.Providers.Rackspace;
using Rackspace.CloudNetworks;
using Rackspace.CloudNetworks.v2;
using Rackspace.RackConnect.v3;

public class AssignPublicIPSamples : ISample
{
Expand All @@ -16,27 +15,54 @@ public async Task Run(string username, string apiKey, string region)
Username = username,
APIKey = apiKey
};
var rackConnectService = new RackConnectService(identity);
var serverService = new CloudServersProvider(identity);
var identityService = new CloudIdentityProvider(identity);
var result = identityService.Authenticate();

Console.WriteLine("Looking up a RackConnect network...");
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... ");

Console.WriteLine("Assigning a public ip address...");
rackConnectService.AssignPublicIPAsync(server.Id);
// 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...");
await networkService.DeletePortAsync(samplePort.Id);
await networkService.DeleteNetworkAsync(sampleNetwork.Id);
serverService.DeleteServer(requestedServer.Id);

Console.WriteLine("Deallocating the public IP address...");
await ip.DeleteAsync();
}

public void PrintTasks()
{
Console.WriteLine("This sample will perform the following tasks:");
Console.WriteLine("\t* Create a network");
Console.WriteLine("\t* Add a subnet to the network");
Console.WriteLine("\t* Attach a port to the network");
Console.WriteLine("\t* Delete the network");
Console.WriteLine("\t* Locate a hybrid/RackConnect network");
Console.WriteLine("\t* Create a cloud server on the network");
Console.WriteLine("\t* Allocate a public IP on the network");
Console.WriteLine("\t* Assign the public IP to the cloud server");
Console.WriteLine("\t* Remove the public IP from the cloud server");
Console.WriteLine("\t* Remove the cloud server");
}

}
7 changes: 5 additions & 2 deletions samples/Rackspace.Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ internal class Program
private static readonly Dictionary<int, ISample> _samples = new Dictionary<int, ISample>
{
{1, new CloudNetworkSamples()},
{1, new AssignPublicIPSamples()}
{2, new AssignPublicIPSamples()}
};

private static void Main()
Expand Down Expand Up @@ -37,7 +37,10 @@ private static void Main()
ISample sample = _samples[sampleId];

Console.WriteLine();
Console.WriteLine("Do you want to proceed? [y/N]: ");
sample.PrintTasks();
Console.WriteLine();

Console.Write("Do you want to proceed? [y/N]: ");
var shouldProceed = Console.ReadLine();
if (shouldProceed.ToLower() == "y")
sample.Run(username, apiKey, region).Wait();
Expand Down
37 changes: 28 additions & 9 deletions samples/Rackspace.Samples/Rackspace.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,33 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="openstacknet, Version=1.5.0.0, Culture=neutral, PublicKeyToken=a7b9d24dda86d33e, processorArchitecture=MSIL">
<HintPath>packages\openstack.net.1.5.0-beta-1\lib\net45\openstacknet.dll</HintPath>
<Reference Include="Flurl">
<HintPath>..\..\packages\Flurl.Signed\lib\portable-net40+sl50+win+wpa81+wp80+MonoAndroid10+MonoTouch10\Flurl.dll</HintPath>
</Reference>
<Reference Include="Flurl.Http">
<HintPath>..\..\packages\Flurl.Http.Signed\lib\net45\Flurl.Http.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Marvin.JsonPatch">
<HintPath>..\..\packages\Marvin.JsonPatch.Signed\lib\portable-net40+win+wpa81\Marvin.JsonPatch.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Rackspace, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Rackspace.0.1.0-beta1\lib\net45\Rackspace.dll</HintPath>
<Reference Include="openstacknet">
<HintPath>..\..\packages\openstack.net\lib\net45\openstacknet.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="SimpleRESTServices, Version=1.3.0.0, Culture=neutral, PublicKeyToken=8965cea5c205d3a3, processorArchitecture=MSIL">
<HintPath>packages\SimpleRESTServices.1.3.0.1\lib\net40\SimpleRESTServices.dll</HintPath>
<Reference Include="Rackspace">
<HintPath>..\..\packages\Rackspace\lib\net45\Rackspace.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -62,14 +78,17 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="paket.references" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>



</Project>
10 changes: 0 additions & 10 deletions samples/Rackspace.Samples/packages.config

This file was deleted.

1 change: 1 addition & 0 deletions samples/Rackspace.Samples/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rackspace
10 changes: 1 addition & 9 deletions src/Rackspace/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("333ac1cb-9b60-4135-b19c-4d9e7fc9762b")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
// Version information is supplied at build time by GitVersion

[assembly: InternalsVisibleTo("Rackspace.UnitTests")]
3 changes: 1 addition & 2 deletions src/Rackspace/RackConnect/v3/PublicIPCreateDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ private dynamic CloudServer
/// <summary>
/// Determines whether a Public IP is removed from your environment once the server to which it is attached is deleted.
/// </summary>
//[JsonProperty("retain")]
[JsonIgnore] // Wait until this is fixed in RackConnect service, right now it expects retain in the query parameters
[JsonProperty("retain")]
public bool? ShouldRetain { get; set; }
}
}
38 changes: 24 additions & 14 deletions src/Rackspace/RackConnect/v3/RackConnectService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ private void SetOwner(IServiceResource<RackConnectService> resource)
{
var ip = await new Url(endpoint)
.AppendPathSegment("public_ips")
.SetQueryParam("retain", definition.ShouldRetain)
.Authenticate(_authenticationProvider)
.PostJsonAsync(definition, cancellationToken)
.ReceiveJson<PublicIP>()
Expand All @@ -115,7 +114,7 @@ private void SetOwner(IServiceResource<RackConnectService> resource)
{
return await executeRequest();
}
catch (FlurlHttpException ex) when (CreateFailedDueToServerCreationRaceCondition(ex))
catch (FlurlHttpException ex) when (AssignIPFailedDueToServerCreationRaceCondition(ex))
{
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
return await executeRequest();
Expand All @@ -127,13 +126,13 @@ private void SetOwner(IServiceResource<RackConnectService> resource)
/// between when we created the server and when we requested the IP
/// i.e. The RackConnect API asked for the server details from the server API and got back a 404
/// </summary>
private static bool CreateFailedDueToServerCreationRaceCondition(FlurlHttpException ex)
private static bool AssignIPFailedDueToServerCreationRaceCondition(FlurlHttpException ex)
{
if (ex.Call.HttpStatus != HttpStatusCode.Conflict)
return false;

string errorMessage = ex.GetResponseString();
return Regex.IsMatch(errorMessage, "Cloud Server .* is unprocessable");
return Regex.IsMatch(errorMessage, "Cloud Server .* (unprocessable|exist).*");
}

/// <summary>
Expand Down Expand Up @@ -296,19 +295,30 @@ await endpoint
if (definition == null)
throw new ArgumentNullException("definition");

Url endpoint = await _urlBuilder.GetEndpoint(cancellationToken).ConfigureAwait(false);
string endpoint = await _urlBuilder.GetEndpoint(cancellationToken).ConfigureAwait(false);

var ip = await endpoint
.AppendPathSegments("public_ips", publicIPId)
.Authenticate(_authenticationProvider)
.AllowHttpStatus(HttpStatusCode.NotFound)
.PatchJsonAsync(definition, cancellationToken)
.ReceiveJson<PublicIP>()
.ConfigureAwait(false);
Func<Task<PublicIP>> executeRequest = async () =>
{
var ip = await endpoint
.AppendPathSegments("public_ips", publicIPId)
.Authenticate(_authenticationProvider)
.PatchJsonAsync(definition, cancellationToken)
.ReceiveJson<PublicIP>()
.ConfigureAwait(false);
SetOwner(ip);
SetOwner(ip);
return ip;
};

return ip;
try
{
return await executeRequest();
}
catch (FlurlHttpException ex) when (AssignIPFailedDueToServerCreationRaceCondition(ex))
{
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
return await executeRequest();
}
}
#endregion

Expand Down
9 changes: 9 additions & 0 deletions src/Rackspace/Rackspace.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<AssemblyName>Rackspace</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -105,6 +107,13 @@
<Compile Include="Testing\HttpTest.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\GitVersionTask\build\dotnet\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask\build\dotnet\GitVersionTask.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\GitVersionTask\build\dotnet\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\GitVersionTask\build\dotnet\GitVersionTask.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void Dispose()
_testData.Dispose();
}

[Fact(Skip = "Skip while a bug exists in RemovePublicIP functionality.")]
[Fact]
public async Task CreateUnassignedPublicIPTest()
{
Trace.Write("Provisioning a public ip address... ");
Expand Down
Loading

0 comments on commit 9ad6ce5

Please sign in to comment.