Minor changes... About to port from other Repo

Port from New-CLI repo with MVS working.

Changed naming from Openstack to OpenStack across the board to match API..

Trying to comit

Change-Id: I575d847e38c903e1ae308b55d0f0768bd33fa7e1
This commit is contained in:
paybackman
2014-05-02 12:30:21 -05:00
parent 961f31ef64
commit 3a9dd43380
104 changed files with 3381 additions and 12404 deletions

View File

@@ -0,0 +1,38 @@
//* ============================================================================
//Copyright 2014 Hewlett Packard
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//============================================================================ */
using System;
using System.Management.Automation;
namespace HP.Client.Powershell.Cmdlets
{
[Cmdlet("Hello", "HP", SupportsShouldProcess = true)]
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
public class HelloHPCmdlet : PSCmdlet
{
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
protected override void ProcessRecord()
{
Console.WriteLine("Hello World, from HP");
}
}
}

View File

@@ -0,0 +1,20 @@
@{
ModuleToProcess = 'HP.OpenStack.Client.Powershell.dll'
GUID="{847a28a4-6407-4aa6-8070-a4a51396db70}"
Author="Travis Plummer"
CompanyName="Hewlett-Packard Corporation"
Copyright="© Hewlett-Packard. All rights reserved."
ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FileList=''
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
}

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HP.Openstack.Client.Powershell</RootNamespace>
<AssemblyName>HP.Openstack.Client.Powershell</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\HP\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Cmdlets\HelloHPCmdlet.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utility\HPRegistrationManager.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Deployment\HP.psd1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\openstack-sdk-dotnet\Openstack\Openstack\Openstack.csproj">
<Project>{b2c92371-b62b-45a2-adeb-edebefa3a75c}</Project>
<Name>Openstack</Name>
</ProjectReference>
<ProjectReference Include="..\Openstack.Client.Powershell\Openstack.Client.Powershell.csproj">
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
<Name>Openstack.Client.Powershell</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<PropertyGroup>
<PostBuildEvent>copy .\Deployment\HP.psd1 C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\HP</PostBuildEvent>
</PropertyGroup>
<!-- 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>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("HP.OpenStack.Client.Powershell")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HP.OpenStack.Client.Powershell")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3989338b-6fb6-4dc9-9982-52771596edc6")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using OpenStack.Client.Powershell.Utility;
using OpenStack.Identity;
namespace HP.OpenStack.Client.Powershell.Utility
{
public class HPRegistrationManager : RegistrationManager
{
public override RegistrationResponse Register(ServiceProvider serviceProvider)
{
this.ValidateCredentialElements(ref serviceProvider);
string authenticationEndpoint = serviceProvider.CredentialElements.Where(ce => ce.Key == "AuthenticationServiceURI").Single().Value;
string userName = serviceProvider.CredentialElements.Where(ce => ce.Key == "Username").Single().Value;
string password = serviceProvider.CredentialElements.Where(ce => ce.Key == "Password").Single().Value;
string tenantId = serviceProvider.CredentialElements.Where(ce => ce.Key == "DefaultTenantId").Single().Value;
IOpenStackCredential credential = new OpenStackCredential(new Uri (authenticationEndpoint), userName, password, tenantId);
return new RegistrationResponse(credential, serviceProvider);
}
private SecureString GetSecureString(string password)
{
SecureString securePassword = new SecureString();
password.ToCharArray().ToList().ForEach(securePassword.AppendChar);
return SecureStringHelper.ConvertToSecureString(password);
}
}
}

View File

@@ -1,5 +1,5 @@
@{
ModuleToProcess = 'Openstack.Client.Powershell.dll'
ModuleToProcess = 'HP.Openstack.Client.Powershell.dll'
GUID="{847a28a4-6407-4aa6-8070-a4a51396db70}"
Author="Travis Plummer"
CompanyName="Hewlett-Packard Corporation"
@@ -7,8 +7,8 @@ Copyright="© Hewlett-Packard. All rights reserved."
ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FormatsToProcess="OpenstackShell.format.ps1xml"
FileList='CLI.config'
FormatsToProcess=""
FileList=''
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
}

176
License.txt Normal file
View File

@@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

98
OpenStack-CLI.sln Normal file
View File

@@ -0,0 +1,98 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Openstack.Client.Powershell", "Openstack.Client.Powershell\Openstack.Client.Powershell.csproj", "{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D4A8C690-E5E7-428B-A57C-884680BC3AF5}"
ProjectSection(SolutionItems) = preProject
.nuget\NuGet.Config = .nuget\NuGet.Config
.nuget\NuGet.exe = .nuget\NuGet.exe
.nuget\NuGet.targets = .nuget\NuGet.targets
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Openstack", "..\openstack-sdk-dotnet\Openstack\Openstack\Openstack.csproj", "{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HP.Openstack.Client.Powershell", "HP.Openstack.Client.Powershell\HP.Openstack.Client.Powershell.csproj", "{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rackspace.Openstack.Client.Powershell", "Rackspace.Client.Powershell\Rackspace.Openstack.Client.Powershell.csproj", "{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
TransformTool Build|Any CPU = TransformTool Build|Any CPU
TransformTool Build|Mixed Platforms = TransformTool Build|Mixed Platforms
TransformTool Build|x86 = TransformTool Build|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|x86.ActiveCfg = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Any CPU.Build.0 = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|x86.ActiveCfg = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Any CPU.ActiveCfg = TransformTool Build|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Any CPU.Build.0 = TransformTool Build|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Mixed Platforms.ActiveCfg = TransformTool Build|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Mixed Platforms.Build.0 = TransformTool Build|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|x86.ActiveCfg = TransformTool Build|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Debug|x86.ActiveCfg = Debug|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Release|Any CPU.Build.0 = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.Release|x86.ActiveCfg = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.TransformTool Build|Any CPU.ActiveCfg = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.TransformTool Build|Any CPU.Build.0 = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.TransformTool Build|Mixed Platforms.ActiveCfg = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.TransformTool Build|Mixed Platforms.Build.0 = Release|Any CPU
{B2C92371-B62B-45A2-ADEB-EDEBEFA3A75C}.TransformTool Build|x86.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|x86.ActiveCfg = Debug|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Release|Any CPU.Build.0 = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Release|x86.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.TransformTool Build|Any CPU.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.TransformTool Build|Any CPU.Build.0 = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.TransformTool Build|Mixed Platforms.ActiveCfg = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.TransformTool Build|Mixed Platforms.Build.0 = Release|Any CPU
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.TransformTool Build|x86.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Debug|x86.ActiveCfg = Debug|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Release|Any CPU.Build.0 = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.Release|x86.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.TransformTool Build|Any CPU.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.TransformTool Build|Any CPU.Build.0 = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.TransformTool Build|Mixed Platforms.ActiveCfg = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.TransformTool Build|Mixed Platforms.Build.0 = Release|Any CPU
{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}.TransformTool Build|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -1,46 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Openstack.Client.Powershell.Deployment", "Openstack.Client.Powershell.Deployment.vdproj", "{15B40627-0EBD-4D70-A69C-F248EBD1BD36}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Openstack.Client.Powershell", "..\Openstack.Client.Powershell\Openstack.Client.Powershell.csproj", "{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Openstack.Common", "..\..\OpenStack-API\Openstack.Common\Openstack.Common.csproj", "{F6AF0191-F236-4C26-8C93-30D5F4D8000F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Openstack.Objects", "..\..\OpenStack-API\Openstack.Objects\Openstack.Objects.csproj", "{BDCDCBF5-3467-461E-8307-E1E4E19F6532}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
TransformTool Build|Any CPU = TransformTool Build|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15B40627-0EBD-4D70-A69C-F248EBD1BD36}.Debug|Any CPU.ActiveCfg = Debug
{15B40627-0EBD-4D70-A69C-F248EBD1BD36}.Release|Any CPU.ActiveCfg = Release
{15B40627-0EBD-4D70-A69C-F248EBD1BD36}.Release|Any CPU.Build.0 = Release
{15B40627-0EBD-4D70-A69C-F248EBD1BD36}.TransformTool Build|Any CPU.ActiveCfg = Release
{15B40627-0EBD-4D70-A69C-F248EBD1BD36}.TransformTool Build|Any CPU.Build.0 = Release
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.Release|Any CPU.Build.0 = Release|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Any CPU.ActiveCfg = TransformTool Build|Any CPU
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Any CPU.Build.0 = TransformTool Build|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.Release|Any CPU.Build.0 = Release|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.TransformTool Build|Any CPU.ActiveCfg = Release|Any CPU
{F6AF0191-F236-4C26-8C93-30D5F4D8000F}.TransformTool Build|Any CPU.Build.0 = Release|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.Release|Any CPU.Build.0 = Release|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.TransformTool Build|Any CPU.ActiveCfg = Release|Any CPU
{BDCDCBF5-3467-461E-8307-E1E4E19F6532}.TransformTool Build|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -16,46 +16,43 @@ limitations under the License.
using System;
using System.Management.Automation;
using System.Management.Automation.Provider;
using Openstack;
using OpenStack;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Text;
using System.Runtime.Serialization.Json;
using Openstack.Client.Powershell.Providers.Storage;
using OpenStack.Client.Powershell.Providers.Storage;
using System.Reflection;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Threading;
using Openstack.Client.Powershell.Utility;
using Openstack.Storage;
using OpenStack.Client.Powershell.Utility;
using OpenStack.Storage;
using System.Security;
using System.Linq;
using Openstack.Identity;
using OpenStack.Identity;
namespace Openstack.Client.Powershell.Providers.Common
namespace OpenStack.Client.Powershell.Providers.Common
{
public class BaseNavigationCmdletProvider : NavigationCmdletProvider
{
OpenstackClient _client; // = new OpenstackClient(credential, CancellationToken.None);
{
OpenStackClient _client;
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
protected OpenstackClient Client
protected OpenStackClient Client
{
get
{
return (OpenstackClient)this.SessionState.PSVariable.Get("Client").Value;
{
return (OpenStackClient)this.SessionState.PSVariable.Get("CoreClient").Value;
}
set
{
this.SessionState.PSVariable.Set(new PSVariable("Client", value));
this.SessionState.PSVariable.Set(new PSVariable("CoreClient", value));
}
}
//=========================================================================================
@@ -115,7 +112,7 @@ namespace Openstack.Client.Powershell.Providers.Common
}
catch (Exception)
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
}
}
}
@@ -139,27 +136,27 @@ namespace Openstack.Client.Powershell.Providers.Common
/// </summary>
//==================================================================================================
protected void InitializeSession()
{
CredentialManager manager = new CredentialManager(false);
IOpenstackCredential credential = manager.GetCredentials(false);
{
ConfigurationManager configManager = new ConfigurationManager();
ExtensionManager loader = new ExtensionManager(this.SessionState, this.Context);
configManager.Load();
ServiceProvider provider = configManager.GetDefaultServiceProvider();
// Connect to the Service Provider..
var client = new OpenstackClient(credential, CancellationToken.None);
var connectTask = client.Connect();
connectTask.Wait();
// Setup the environment based on what came back from Auth..
if (provider.Name == String.Empty && provider.IsDefault == true)
{
// Technically Core is already loaded (you're in it :) but this signs in for you to the ServiceProvider selected..
// This is just used in the case where it's the Users first time loading the CLI..
Context context = new Context();
context.ServiceCatalog = credential.ServiceCatalog;
context.Settings = Settings.Default;
context.ProductName = "Openstack-WinCLI";
context.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
loader.LoadCore(provider);
}
else
{
// Load any extensions that were supplied by the ServiceProvider...
this.SessionState.PSVariable.Set(new PSVariable("Context", context));
this.SessionState.PSVariable.Set(new PSVariable("Client", client));
this.SetZoneColor();
loader.LoadExtension(provider);
}
this.SetZoneColor();
}
#region Implementation of DriveCmdletProvider
//==================================================================================================
@@ -221,8 +218,7 @@ namespace Openstack.Client.Powershell.Providers.Common
{
return true;
}
#endregion
#endregion
//==================================================================================================
/// <summary>
/// This test should not verify the existance of the item at the path.

View File

@@ -16,24 +16,24 @@
//using System;
//using System.Text;
//using System.Management.Automation;
//using Openstack.Objects.DataAccess;
//using OpenStack.Objects.DataAccess;
//using System.IO;
//using Openstack.Common.Properties;
//using OpenStack.Common.Properties;
//using System.Xml;
//using System.Xml.Serialization;
//using Openstack.Client.Powershell.Providers.Storage;
//using Openstack.Objects.Domain;
//using Openstack.Objects.Utility;
//using Openstack.Client.Powershell.Providers.Common;
//using OpenStack.Client.Powershell.Providers.Storage;
//using OpenStack.Objects.Domain;
//using OpenStack.Objects.Utility;
//using OpenStack.Client.Powershell.Providers.Common;
//using System.Linq;
//using System.Collections.ObjectModel;
//using System.Management.Automation.Host;
//namespace Openstack.Client.Powershell.Cmdlets.Common
//namespace OpenStack.Client.Powershell.Cmdlets.Common
//{
// public class BasePSCmdlet : PSCmdlet
// {
// private Openstack.Objects.DataAccess.ResponseFormat _responseFormat = ResponseFormat.none;
// private OpenStack.Objects.DataAccess.ResponseFormat _responseFormat = ResponseFormat.none;
// private BaseRepositoryFactory _repositoryFactory;
// #region Properties
@@ -142,7 +142,7 @@
// }
// catch (Exception)
// {
// return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
// return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
// }
// }
// }
@@ -238,7 +238,7 @@
// if (isAuthorized == false && foundattribute == false) return;
// if (!isAuthorized)
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.Openstack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.OpenStack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
// }
////==================================================================================================
///// <summary>

View File

@@ -1,268 +1,263 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
///* ============================================================================
//Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Management.Automation;
using Openstack.Common.Properties;
using System.Collections.ObjectModel;
using Openstack.Client.Powershell.Providers.Storage;
using System.Collections.Generic;
using Openstack.Objects.Domain;
using Openstack.Objects.DataAccess;
using Openstack.Objects.Domain.Admin;
using Openstack.Objects.DataAccess.Security;
using Openstack.Objects.Utility;
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//============================================================================ */
//using System;
//using System.Management.Automation;
//using System.Collections.ObjectModel;
//using OpenStack.Client.Powershell.Providers.Storage;
//using System.Collections.Generic;
//using OpenStack;
namespace Openstack.Client.Powershell.Cmdlets.Common
{
public class BaseAuthenticationCmdlet : BasePSCmdlet
{
private string _key;
private string _value;
private SwitchParameter _reset = false;
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
protected void InitializeSession(AuthenticationRequest request, Settings settings = null)
{
Context context = new Context();
//namespace OpenStack.Client.Powershell.Cmdlets.Common
//{
// public class BaseAuthenticationCmdlet : BasePSCmdlet
// {
// private string _key;
// private string _value;
// private SwitchParameter _reset = false;
////==================================================================================================
///// <summary>
/////
///// </summary>
////==================================================================================================
// protected void InitializeSession(AuthenticationRequest request, Settings settings = null)
// {
// Context context = new Context();
if (request != null)
{
KeystoneAuthProvider authProvider = new KeystoneAuthProvider();
AuthenticationResponse response = authProvider.Authenticate(request);
// if (request != null)
// {
// KeystoneAuthProvider authProvider = new KeystoneAuthProvider();
// AuthenticationResponse response = authProvider.Authenticate(request);
context.ServiceCatalog = response.ServiceCatalog;
if (settings == null)
context.Settings = Settings.Default;
else
context.Settings = settings;
context.AccessToken = response.Token;
// context.ServiceCatalog = response.ServiceCatalog;
// if (settings == null)
// context.Settings = Settings.Default;
// else
// context.Settings = settings;
// context.AccessToken = response.Token;
this.SessionState.PSVariable.Set(new PSVariable("Context", context));
this.SessionState.PSVariable.Set(new PSVariable("BaseRepositoryFactory", new BaseRepositoryFactory(context)));
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
protected void InitializeSession(Settings settings)
{
AuthenticationRequest request = new AuthenticationRequest(new Credentials(settings.Username, settings.Password), settings.DefaultTenantId);
this.InitializeSession(request, settings);
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo, string configFilePath)
{
List<StorageContainer> storageContainers = null;
OSDriveParameters parameters = new OSDriveParameters();
// this.SessionState.PSVariable.Set(new PSVariable("Context", context));
// this.SessionState.PSVariable.Set(new PSVariable("BaseRepositoryFactory", new BaseRepositoryFactory(context)));
// }
// }
////==================================================================================================
///// <summary>
/////
///// </summary>
////==================================================================================================
// protected void InitializeSession(Settings settings)
// {
// AuthenticationRequest request = new AuthenticationRequest(new Credentials(settings.Username, settings.Password), settings.DefaultTenantId);
// this.InitializeSession(request, settings);
// }
////==================================================================================================
///// <summary>
/////
///// </summary>
///// <returns></returns>
////==================================================================================================
// private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo, string configFilePath)
// {
// List<StorageContainer> storageContainers = null;
// OSDriveParameters parameters = new OSDriveParameters();
if (this.Settings != null)
{
parameters.Settings = this.Settings;
}
else
{
parameters.Settings = settings;
}
// if (this.Settings != null)
// {
// parameters.Settings = this.Settings;
// }
// else
// {
// parameters.Settings = settings;
// }
try
{
IContainerRepository storageContainerRepository = this.RepositoryFactory.CreateContainerRepository();
storageContainers = storageContainerRepository.GetStorageContainers(configFilePath);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
// try
// {
// IContainerRepository storageContainerRepository = this.RepositoryFactory.CreateContainerRepository();
// storageContainers = storageContainerRepository.GetStorageContainers(configFilePath);
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex);
// }
Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
// // For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
try
{
if (storageContainers.Count > 0)
{
foreach (StorageContainer storageContainer in storageContainers)
{
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
OSDriveInfo kvsDriveInfo = new OSDriveInfo(driveInfo, parameters, this.Context);
try
{
drives.Add(kvsDriveInfo);
}
catch (Exception) { }
}
}
else
{
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
return new Collection<PSDriveInfo>
{
new OSDriveInfo(driveInfo, parameters, this.Context)
};
}
}
catch (Exception)
{
// try
// {
// if (storageContainers.Count > 0)
// {
// foreach (StorageContainer storageContainer in storageContainers)
// {
// PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
// OSDriveInfo kvsDriveInfo = new OSDriveInfo(driveInfo, parameters, this.Context);
// try
// {
// drives.Add(kvsDriveInfo);
// }
// catch (Exception) { }
// }
// }
// else
// {
// PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
// return new Collection<PSDriveInfo>
// {
// new OSDriveInfo(driveInfo, parameters, this.Context)
// };
// }
// }
// catch (Exception)
// {
}
// }
return drives;
}
//=======================================================================================================
/// <summary>
/// Removes all currently registered drives..
/// </summary>
//=======================================================================================================
private void RemoveDrives()
{
// Remove the old Users drives first..
Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
foreach (PSDriveInfo deadDrive in deadDrives)
{
this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
}
}
// return drives;
// }
////=======================================================================================================
///// <summary>
///// removes only the currently registered shared drives..
///// Removes all currently registered drives..
///// </summary>
////=======================================================================================================
// private void RemoveSharedDrives()
// private void RemoveDrives()
// {
// // Remove the old Users drives first..
// Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
// foreach (OSDriveInfo deadDrive in deadDrives)
// foreach (PSDriveInfo deadDrive in deadDrives)
// {
// if (deadDrive.SharePath != null)
// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
// }
// }
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteContainers(string configFilePath)
{
List<string> invalidDriveNames = new List<string>();
OSDriveParameters parameters = new OSDriveParameters();
// }
//////=======================================================================================================
/////// <summary>
/////// removes only the currently registered shared drives..
/////// </summary>
//////=======================================================================================================
//// private void RemoveSharedDrives()
//// {
//// Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
//// foreach (OSDriveInfo deadDrive in deadDrives)
//// {
//// if (deadDrive.SharePath != null)
//// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
//// }
//// }
////=======================================================================================================
///// <summary>
/////
///// </summary>
////=======================================================================================================
// protected void WriteContainers(string configFilePath)
// {
// List<string> invalidDriveNames = new List<string>();
// OSDriveParameters parameters = new OSDriveParameters();
// Write out the commands header information first..
// // Write out the commands header information first..
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject("Object Storage Service available. Remapping to the following drives.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
// WriteObject("");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("===================================================================");
// Console.ForegroundColor = ConsoleColor.Yellow;
// WriteObject("Object Storage Service available. Remapping to the following drives.");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("===================================================================");
// Console.ForegroundColor = ConsoleColor.Green;
// WriteObject(" ");
HPOSNavigationProvider provider = new HPOSNavigationProvider();
Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Settings, this.SessionState.Provider.GetOne("OS-Storage"), configFilePath);
// HPOSNavigationProvider provider = new HPOSNavigationProvider();
// Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Settings, this.SessionState.Provider.GetOne("OS-Storage"), configFilePath);
if (drives != null)
{
this.RemoveDrives();
// if (drives != null)
// {
// this.RemoveDrives();
foreach (PSDriveInfo drive in drives)
{
if (drive.Name != string.Empty)
{
WriteObject("Storage Container : [" + drive.Name + "] now available.");
}
// foreach (PSDriveInfo drive in drives)
// {
// if (drive.Name != string.Empty)
// {
// WriteObject("Storage Container : [" + drive.Name + "] now available.");
// }
try
{
this.SessionState.Drive.New(drive, "local");
}
catch (PSArgumentException ex)
{
if (drive.Name != string.Empty)
invalidDriveNames.Add(drive.Name);
}
catch (Exception) { }
// try
// {
// this.SessionState.Drive.New(drive, "local");
// }
// catch (PSArgumentException ex)
// {
// if (drive.Name != string.Empty)
// invalidDriveNames.Add(drive.Name);
// }
// catch (Exception) { }
}
WriteObject("");
}
else
{
// No storageContainers exist for the new credentials so make some up...
// }
// WriteObject("");
// }
// else
// {
// // No storageContainers exist for the new credentials so make some up...
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
this.SessionState.Drive.New(new OSDriveInfo(driveInfo, parameters, this.Context), "local");
}
// PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
// this.SessionState.Drive.New(new OSDriveInfo(driveInfo, parameters, this.Context), "local");
// }
if (invalidDriveNames.Count > 0)
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Red;
WriteObject("Error : A subset of your Containers could not be bound to this");
WriteObject("session due to naming conflicts with the naming standards required");
WriteObject("for Powershell drives. These containers are listed below.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
// if (invalidDriveNames.Count > 0)
// {
// WriteObject("");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Red;
// WriteObject("Error : A subset of your Containers could not be bound to this");
// WriteObject("session due to naming conflicts with the naming standards required");
// WriteObject("for Powershell drives. These containers are listed below.");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Green;
// WriteObject(" ");
foreach (string name in invalidDriveNames)
{
WriteObject(name);
WriteObject(" ");
}
WriteObject(" ");
}
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteServices()
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject("Binding to new Account. New service catalog is as follows.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
// foreach (string name in invalidDriveNames)
// {
// WriteObject(name);
// WriteObject(" ");
// }
// WriteObject(" ");
// }
// }
////=======================================================================================================
///// <summary>
/////
///// </summary>
////=======================================================================================================
// protected void WriteServices()
// {
// WriteObject("");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Yellow;
// WriteObject("Binding to new Account. New service catalog is as follows.");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Green;
// WriteObject(" ");
foreach (Service service in this.Context.ServiceCatalog)
{
WriteObject(service);
}
WriteObject("");
}
}
}
// foreach (Service service in this.Context.ServiceCatalog)
// {
// WriteObject(service);
// }
// WriteObject("");
// }
// }
//}

View File

@@ -16,18 +16,18 @@ limitations under the License.
using System;
using System.Text;
using System.Management.Automation;
using Openstack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Utility;
using System.IO;
using Openstack.Common;
using OpenStack.Common;
using System.Xml;
using System.Xml.Serialization;
using Openstack.Client.Powershell.Providers.Storage;
using Openstack.Client.Powershell.Providers.Common;
using OpenStack.Client.Powershell.Providers.Storage;
using OpenStack.Client.Powershell.Providers.Common;
using System.Linq;
using System.Collections.ObjectModel;
using System.Management.Automation.Host;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
public class BasePSCmdlet : PSCmdlet
{
@@ -83,15 +83,15 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
///
/// </summary>
//==================================================================================================
protected IOpenstackClient Client
protected IOpenStackClient CoreClient
{
get
{
return (IOpenstackClient)this.SessionState.PSVariable.GetValue("Client", null);
return (IOpenStackClient)this.SessionState.PSVariable.GetValue("CoreClient", null);
}
set
{
this.SessionState.PSVariable.Set(new PSVariable("Client", value));
this.SessionState.PSVariable.Set(new PSVariable("CoreClient", value));
}
}
//==================================================================================================
@@ -120,7 +120,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
{
get
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
}
}
#endregion
@@ -198,7 +198,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
//if (isAuthorized == false && foundattribute == false) return;
//if (!isAuthorized)
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.Openstack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.OpenStack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
}
#endregion
#region Methods

View File

@@ -16,12 +16,12 @@ limitations under the License.
using System;
using System.Management.Automation;
using System.Collections;
using Openstack.Client.Powershell.Cmdlets.Common;
using OpenStack.Client.Powershell.Cmdlets.Common;
using System.IO;
using System.Xml;
using Openstack.Objects.Domain.Admin;
using OpenStack.Identity;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.Get, "Catalog", SupportsShouldProcess = true)]
public class GetCatalogCmdlet : BasePSCmdlet
@@ -79,15 +79,15 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
/// </summary>
/// <param name="endpoint"></param>
//=======================================================================================================
private void PrintEndpoint(Endpoint endpoint)
private void PrintEndpoint(OpenStackServiceEndpoint endpoint)
{
Console.WriteLine("Region : " + endpoint.Region);
Console.WriteLine("Public URL : " + endpoint.PublicURL);
Console.WriteLine("Internal URL : " + endpoint.InternalURL);
Console.WriteLine("Admin URL : " + endpoint.AdminURL);
Console.WriteLine("Version : " + endpoint.Version.Id);
Console.WriteLine("Version Info : " + endpoint.Version.InfoURL);
Console.WriteLine("Version List : " + endpoint.Version.ListURL);
Console.WriteLine("Public URL : " + endpoint.PublicUri.ToString());
//Console.WriteLine("Internal URL : " + endpoint..InternalURL);
//Console.WriteLine("Admin URL : " + endpoint.AdminURL);
Console.WriteLine("Version : " + endpoint.Version);
//Console.WriteLine("Version Info : " + endpoint.Version.InfoURL);
//Console.WriteLine("Version List : " + endpoint.Version.ListURL);
Console.WriteLine();
}
//=======================================================================================================
@@ -96,7 +96,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
/// </summary>
/// <param name="service"></param>
//=======================================================================================================
private void PrintServiceVerbose(Service service)
private void PrintServiceVerbose(OpenStackServiceDefinition service)
{
Console.WriteLine("");
this.WriteSection ("Service : " + service.Name);
@@ -114,7 +114,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.Green;
foreach (Endpoint endpoint in service.Endpoints)
foreach (OpenStackServiceEndpoint endpoint in service.Endpoints)
{
this.PrintEndpoint(endpoint);
}
@@ -130,7 +130,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
this.WriteSection("You have access to the following Services ");
WriteObject("");
foreach (Service service in this.Context.ServiceCatalog)
foreach (OpenStackServiceDefinition service in this.Context.ServiceCatalog)
{
if (!_verbose)
WriteObject(service);

View File

@@ -16,11 +16,11 @@ limitations under the License.
using System;
using System.Management.Automation;
using System.Collections;
using Openstack.Client.Powershell.Cmdlets.Common;
using OpenStack.Client.Powershell.Cmdlets.Common;
using System.IO;
using System.Xml;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.Get, "Config", SupportsShouldProcess = true)]
public class GetConfigCmdlet : BasePSCmdlet
@@ -57,7 +57,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
this.WriteObject("Configuration File located at " + configFilePath);
WriteObject("");
foreach (DictionaryEntry setting in this.Settings)
foreach (DictionaryEntry setting in this.Context.Settings)
{
if (((string)setting.Key) == "SecretKey" || ((string)setting.Key)== "AccessKey")
{

View File

@@ -15,25 +15,26 @@
//============================================================================ */
using System;
using System.Management.Automation;
using Openstack.Client.Powershell.Providers.Common;
using OpenStack.Client.Powershell.Providers.Common;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using Openstack;
using OpenStack;
using System.Xml.Linq;
using System.Collections.Generic;
using Openstack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Utility;
using System.Linq;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.Get, "SP", SupportsShouldProcess = true)]
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
public class GetServiceProvidersCmdlet : BasePSCmdlet
{
#region Parameters
#endregion
#region Methods
//=========================================================================================
/// <summary>
///
@@ -41,22 +42,9 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
//=========================================================================================
protected override void ProcessRecord()
{
List<ServiceProvider> serviceProviders = new List<ServiceProvider>();
XDocument doc = XDocument.Load(this.ConfigFilePath);
IEnumerable<XElement> serviceProviderNodes = doc.Descendants("ServiceProvider");
foreach (XElement element in serviceProviderNodes)
{
ServiceProvider provider = new ServiceProvider();
provider.AuthenticationServiceURI = element.Elements().Where(e => e.Attribute("key").Value == "AuthenticationServiceURI").Attributes("value").Single().Value;
provider.DefaultTenantId = element.Elements().Where(e => e.Attribute("key").Value == "DefaultTenantId").Attributes("value").Single().Value;
provider.Username = element.Elements().Where(e => e.Attribute("key").Value == "Username").Attributes("value").Single().Value;
provider.IsDefault = Convert.ToBoolean(element.Attribute("isDefault").Value);
provider.Name = element.Attribute("name").Value;
serviceProviders.Add(provider);
}
this.WriteObject(serviceProviders);
ConfigurationManager manager = new ConfigurationManager();
manager.Load();
this.WriteObject(manager.GetServiceProviders());
}
#endregion
}

View File

@@ -15,11 +15,11 @@ limitations under the License.
============================================================================ */
using System;
using System.Management.Automation;
using Openstack.Client.Powershell.Cmdlets.Common;
using OpenStack.Client.Powershell.Cmdlets.Common;
using System.Reflection;
using Openstack.Client.Powershell.Providers.Common;
using OpenStack.Client.Powershell.Providers.Common;
namespace Openstack.Client.Powershell.Cmdlets.GroupManagement
namespace OpenStack.Client.Powershell.Cmdlets.GroupManagement
{
[Cmdlet(VerbsCommon.Get, "Version", SupportsShouldProcess = true)]
public class GetVersionCmdlet : BasePSCmdlet

View File

@@ -17,12 +17,12 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Openstack.Client.Powershell.Cmdlets.Common;
using OpenStack.Client.Powershell.Cmdlets.Common;
using System.Management.Automation;
using System.Xml.Linq;
using System.Xml.XPath;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet("Get", "Zone", SupportsShouldProcess = true)]
public class GetZoneCmdlet : BasePSCmdlet

View File

@@ -17,18 +17,17 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Openstack.Client.Powershell.Cmdlets.Common;
using OpenStack.Client.Powershell.Cmdlets.Common;
using System.Management.Automation;
using System.Xml.Linq;
using System.Xml.XPath;
using Openstack.Objects.Domain.Admin;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet("Get", "Zones", SupportsShouldProcess = true)]
public class GetZonesCmdlet : BasePSCmdlet
{
private SwitchParameter _verbose = false;
private SwitchParameter _verbose = true;
//=========================================================================================
/// <summary>
@@ -60,7 +59,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
Console.WriteLine("");
Console.WriteLine("The following Services are available from this Availability Zone");
Console.WriteLine("----------------------------------------------------------------");
this.WriteObject(this.Context.ServiceCatalog.GetAZServices(element.Attribute("name").Value));
this.WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(element.Attribute("name").Value));
Console.WriteLine("");
}
Console.WriteLine("");
@@ -72,24 +71,24 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
//=========================================================================================
private void ShowNonVerboseOutput(IEnumerable<XElement> zoneKeyNode)
{
Console.WriteLine("");
Console.WriteLine("Current Availability Zones include ");
Console.WriteLine("");
foreach (XElement element in zoneKeyNode)
{
Zone zone = new Zone();
zone.Name = element.Attribute("name").Value;
zone.ShellForegroundColor = element.Attribute("shellForegroundColor").Value;
zone.Id = element.Attribute("id").Value;
//Console.WriteLine("");
//Console.WriteLine("Current Availability Zones include ");
//Console.WriteLine("");
//foreach (XElement element in zoneKeyNode)
//{
// Zone zone = new Zone();
// zone.Name = element.Attribute("name").Value;
// zone.ShellForegroundColor = element.Attribute("shellForegroundColor").Value;
// zone.Id = element.Attribute("id").Value;
if (element.Attribute("isDefault").Value == "True")
zone.IsDefault = true;
else
zone.IsDefault = false;
// if (element.Attribute("isDefault").Value == "True")
// zone.IsDefault = true;
// else
// zone.IsDefault = false;
this.WriteObject(zone);
}
Console.WriteLine("");
// this.WriteObject(zone);
//}
//Console.WriteLine("");
}
//=========================================================================================
/// <summary>

View File

@@ -16,13 +16,13 @@
using System.Management.Automation;
using System.Xml.Linq;
using System.Collections.Generic;
using Openstack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Utility;
using System.Xml.XPath;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.New, "SP", SupportsShouldProcess = true)]
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
public class NewServiceProvidersCmdlet : BasePSCmdlet
{

View File

@@ -17,21 +17,25 @@ using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Xml.Linq;
using Openstack.Common.Properties;
using Openstack.Objects.Domain;
using System.Linq;
using OpenStack;
using System.Xml.XPath;
using Openstack.Objects.DataAccess;
using Openstack.Objects.Utility;
using Openstack.Client.Powershell.Providers.Common;
using OpenStack.Client.Powershell.Providers.Common;
using OpenStack.Client.Powershell.Utility;
using OpenStack.Identity;
using OpenStack.Client.Powershell.Providers.Storage;
using OpenStack.Storage;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
namespace Openstack.Client.Powershell.Cmdlets.Common
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.Set, "Config", SupportsShouldProcess = true)]
public class SetConfigCmdlet : BaseAuthenticationCmdlet
public class SetConfigCmdlet : BasePSCmdlet
{
private string _key;
private string _value;
private string _configFilePath = null;
private string _configFilePath = @"C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Rackspace.Client.Powershell\Deployment\Rackspace.config";
private SwitchParameter _reset = false;
private string _oldAccessKey;
@@ -41,20 +45,20 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
///
/// </summary>
//=========================================================================================
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc3", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
[Alias("resetcfg")]
[ValidateNotNullOrEmpty]
public SwitchParameter Reset
{
get { return _reset; }
set { _reset = value; }
}
//[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc3", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
//[Alias("resetcfg")]
//[ValidateNotNullOrEmpty]
//public SwitchParameter Reset
//{
// get { return _reset; }
// set { _reset = value; }
//}
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "sc4", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc4", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
[Alias("s")]
[ValidateNotNullOrEmpty]
public string ConfigFilePathKey
@@ -67,48 +71,241 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
///
/// </summary>
//=========================================================================================
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "sc", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
[Alias("k")]
[ValidateNotNullOrEmpty]
public string Key
{
get { return _key; }
set { _key = value; }
}
//[Parameter(Position = 1, Mandatory = true, ParameterSetName = "sc", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
//[Alias("k")]
//[ValidateNotNullOrEmpty]
//public string Key
//{
// get { return _key; }
// set { _key = value; }
//}
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
[Parameter(Position = 2, Mandatory = true, ParameterSetName = "sc", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
[Alias("v")]
[ValidateNotNullOrEmpty]
public string Value
{
get { return _value; }
set { _value = value; }
}
//[Parameter(Position = 2, Mandatory = true, ParameterSetName = "sc", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
//[Alias("v")]
//[ValidateNotNullOrEmpty]
//public string Value
//{
// get { return _value; }
// set { _value = value; }
//}
#endregion
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteServices()
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject("Binding to new Account. New service catalog is as follows.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
foreach (OpenStackServiceDefinition service in this.Context.ServiceCatalog)
{
WriteObject(service);
}
WriteObject("");
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=================================================zx======================================================
private void LoadConfigFile()
{
this.InitializeSession(Settings.Default);
{
ConfigurationManager configManager = new ConfigurationManager();
configManager.Load(this.ConfigFilePathKey);
ServiceProvider provider = configManager.GetDefaultServiceProvider();
ExtensionManager loader = new ExtensionManager(this.SessionState, this.Context);
loader.LoadCore(provider);
loader.LoadExtension(provider);
// Show the User the new ServiceCatalog that we just received..
this.WriteServices();
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
if (this.Context.ServiceCatalog.DoesServiceExist("OS-Storage"))
if (this.Context.ServiceCatalog.Exists("Object Storage"))
{
this.WriteContainers(_configFilePath);
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo) //, string configFilePath)
{
List<StorageContainer> storageContainers = null;
OSDriveParameters parameters = new OSDriveParameters();
if (this.Context.Settings != null)
{
parameters.Settings = this.Context.Settings;
}
else
{
parameters.Settings = settings;
}
try
{
Task<IEnumerable<StorageContainer>> getContainersTask = this.CoreClient.CreateServiceClient<IStorageServiceClient>().ListStorageContainers();
getContainersTask.Wait();
storageContainers = getContainersTask.Result.ToList<StorageContainer>();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
try
{
string publicStoreUrl = this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
if (storageContainers.Count > 0)
{
foreach (StorageContainer storageContainer in storageContainers)
{
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
OpenStackPSDriveInfo kvsDriveInfo = new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl);
try
{
drives.Add(kvsDriveInfo);
}
catch (Exception) { }
}
}
else
{
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
return new Collection<PSDriveInfo>
{
new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl)
};
}
}
catch (Exception ex)
{
int g = 7;
}
return drives;
}
//=======================================================================================================
/// <summary>
/// Removes all currently registered drives..
/// </summary>
//=======================================================================================================
private void RemoveDrives()
{
// Remove the old Users drives first..
Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("Object Storage");
foreach (PSDriveInfo deadDrive in deadDrives)
{
this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
}
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteContainers(string configFilePath)
{
List<string> invalidDriveNames = new List<string>();
OSDriveParameters parameters = new OSDriveParameters();
// Write out the commands header information first..
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject("Object Storage Service available. Remapping to the following drives.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
HPOSNavigationProvider provider = new HPOSNavigationProvider();
Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Context.Settings, this.SessionState.Provider.GetOne("Object Storage"));
if (drives != null)
{
this.RemoveDrives();
foreach (PSDriveInfo drive in drives)
{
if (drive.Name != string.Empty)
{
WriteObject("Storage Container : [" + drive.Name + "] now available.");
}
try
{
this.SessionState.Drive.New(drive, "local");
}
catch (PSArgumentException ex)
{
if (drive.Name != string.Empty)
invalidDriveNames.Add(drive.Name);
}
catch (Exception) { }
}
WriteObject("");
}
else
{
// No storageContainers exist for the new credentials so make some up...
//PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
//this.SessionState.Drive.New(new OSDriveInfo(driveInfo, parameters, this.Context), "local");
}
if (invalidDriveNames.Count > 0)
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Red;
WriteObject("Error : A subset of your Containers could not be bound to this");
WriteObject("session due to naming conflicts with the naming standards required");
WriteObject("for Powershell drives. These containers are listed below.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
foreach (string name in invalidDriveNames)
{
WriteObject(name);
WriteObject(" ");
}
WriteObject(" ");
}
}
//======================================================================================================================
/// <summary>
///
@@ -138,41 +335,41 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
///
/// </summary>
//=======================================================================================================
private void LoadConfigFile(string configFilePath)
{
this.Settings = Settings.LoadConfig(configFilePath);
this.Context.Settings = this.Settings;
this.Context = this.Context;
//private void LoadConfigFile(string configFilePath)
//{
// this.Settings = Settings.LoadConfig(configFilePath);
// this.Context.Settings = this.Settings;
// this.Context = this.Context;
// We need to ensure that the Users new identity doesn't alter the list bof available storageContainers. If so, just deal with it..
// // We need to ensure that the Users new identity doesn't alter the list bof available storageContainers. If so, just deal with it..
if (_oldAccessKey != this.Settings.Username)
{
this.InitializeSession(this.Settings);
// if (_oldAccessKey != this.Settings.Username)
// {
// this.InitializeSession(this.Settings);
// Show the User the new ServiceCatalog that we just received..
// // Show the User the new ServiceCatalog that we just received..
this.WriteServices();
// this.WriteServices();
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
// // If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
if (this.Context.ServiceCatalog.DoesServiceExist("OS-Storage"))
{
this.WriteContainers(_configFilePath);
}
// if (this.Context.ServiceCatalog.DoesServiceExist("OS-Storage"))
// {
// this.WriteContainers(_configFilePath);
// }
if (this.Drive.Name == "OpenStack")
{
this.SessionState.InvokeCommand.InvokeScript(@"cd\");
((CommonDriveInfo)this.Drive).CurrentContainer.Load();
}
// if (this.Drive.Name == "OpenStack")
// {
// this.SessionState.InvokeCommand.InvokeScript(@"cd\");
// ((CommonDriveInfo)this.Drive).CurrentContainer.Load();
// }
this.SessionState.PSVariable.Set(new PSVariable("ConfigPath", configFilePath));
// this.SessionState.PSVariable.Set(new PSVariable("ConfigPath", configFilePath));
//Context tempContext = (Context)this.SessionState.PSVariable.GetValue("Context", null);
//this.UpdateCache(tempContext);
}
}
// //Context tempContext = (Context)this.SessionState.PSVariable.GetValue("Context", null);
// //this.UpdateCache(tempContext);
// }
//}
//=======================================================================================================
/// <summary>
///
@@ -180,18 +377,21 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
//=======================================================================================================
protected override void ProcessRecord()
{
if (_reset)
{
_configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
this.LoadConfigFile();
}
else
{
if (_configFilePath != null)
this.LoadConfigFile(_configFilePath);
else
this.Settings[_key] = _value;
}
this.LoadConfigFile();
//if (_reset)
//{
// _configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
// this.LoadConfigFile();
//}
//else
//{
// if (_configFilePath != null)
// this.LoadConfigFile(_configFilePath);
// else
// this.Settings[_key] = _value;
//}
}
}
}

View File

@@ -0,0 +1,316 @@
//* ============================================================================
//Copyright 2014 Hewlett Packard
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//============================================================================ */
using System.Management.Automation;
using OpenStack.Client.Powershell.Utility;
using System.Linq;
using OpenStack.Identity;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using OpenStack.Client.Powershell.Providers.Storage;
using OpenStack.Storage;
using System.Threading.Tasks;
using System;
namespace OpenStack.Client.Powershell.Cmdlets.Common
{
[Cmdlet(VerbsCommon.Set, "SP", SupportsShouldProcess = true)]
public class SetServiceProviderCmdlet : BasePSCmdlet
{
private string _name;
private SwitchParameter _setDefault = false;
#region Properties
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
[Parameter(ParameterSetName = "SetSP", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
[Alias("d")]
[ValidateNotNullOrEmpty]
public SwitchParameter SetDefault
{
get { return _setDefault; }
set { _setDefault = value; }
}
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
[Parameter(Position = 0, ParameterSetName = "SetSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
[Alias("n")]
public string Name
{
get { return _name; }
set { _name = value; }
}
#endregion
#region Methods
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
protected override void ProcessRecord()
{
ConfigurationManager manager = new ConfigurationManager();
manager.Load();
ServiceProvider provider = manager.GetServiceProvider(this.Name);
provider.IsDefault = this.SetDefault;
this.WriteObject("");
this.WriteObject(" - Connecting to OpenStack Provider " + this.Name);
this.InitialzeServiceProvider(provider);
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private bool DoesRequireCredentials()
{
return true;
}
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
private void InitialzeServiceProvider(ServiceProvider provider)
{
if (this.SetDefault)
{
ConfigurationManager configManager = new ConfigurationManager();
configManager.Load();
configManager.SetDefaultServiceProvider(provider.Name);
}
this.WriteObject(" - Loading Service Provider extensions ");
ExtensionManager manager = new ExtensionManager(this.SessionState, this.Context);
manager.LoadExtension(provider);
this.ShowAccountState();
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
private void ShowAccountState()
{
// Show the User the new ServiceCatalog that we just received..
this.WriteObject(" - Success!");
this.WriteObject("");
this.WriteServices();
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
if (this.Context.ServiceCatalog.Exists("Object Storage"))
{
this.WriteContainers();
}
}
//=======================================================================================================
/// <summary>
/// Removes all currently registered drives..
/// </summary>
//=======================================================================================================
private void RemoveDrives()
{
// Remove the old Users drives first..
Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("Object Storage");
foreach (PSDriveInfo deadDrive in deadDrives)
{
this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
}
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteServices()
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject(" Binding to new Account. New service catalog is as follows.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
foreach (OpenStackServiceDefinition service in this.Context.ServiceCatalog)
{
WriteObject(service);
}
WriteObject("");
}
//=======================================================================================================
/// <summary>
///
/// </summary>
//=======================================================================================================
protected void WriteContainers()
{
List<string> invalidDriveNames = new List<string>();
OSDriveParameters parameters = new OSDriveParameters();
// Write out the commands header information first..
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
WriteObject(" Object Storage Service available. Remapping to the following drives.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("===================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
HPOSNavigationProvider provider = new HPOSNavigationProvider();
Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Context.Settings, this.SessionState.Provider.GetOne("Object Storage"));
if (drives != null)
{
this.RemoveDrives();
foreach (PSDriveInfo drive in drives)
{
if (drive.Name != string.Empty)
{
WriteObject(" Storage Container : [" + drive.Name + "] now available.");
}
try
{
this.SessionState.Drive.New(drive, "local");
}
catch (PSArgumentException ex)
{
if (drive.Name != string.Empty)
invalidDriveNames.Add(drive.Name);
}
catch (Exception) { }
}
WriteObject("");
}
else
{
// No storageContainers exist for the new credentials so make some up...
//PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
//this.SessionState.Drive.New(new OSDriveInfo(driveInfo, parameters, this.Context), "local");
}
if (invalidDriveNames.Count > 0)
{
WriteObject("");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Red;
WriteObject(" Error : A subset of your Containers could not be bound to this");
WriteObject(" session due to naming conflicts with the naming standards required");
WriteObject(" for Powershell drives. These containers are listed below.");
Console.ForegroundColor = ConsoleColor.DarkGray;
WriteObject("=================================================================");
Console.ForegroundColor = ConsoleColor.Green;
WriteObject(" ");
foreach (string name in invalidDriveNames)
{
WriteObject(name);
WriteObject(" ");
}
WriteObject(" ");
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo) //, string configFilePath)
{
IEnumerable<StorageContainer> storageContainers = null;
OSDriveParameters parameters = new OSDriveParameters();
if (this.Context.Settings != null)
{
parameters.Settings = this.Context.Settings;
}
else
{
parameters.Settings = settings;
}
try
{
Task <StorageAccount> getStorageAccountTask = this.CoreClient.CreateServiceClient<IStorageServiceClient>().GetStorageAccount();
getStorageAccountTask.Wait();
StorageAccount result = getStorageAccountTask.Result;
storageContainers = result.Containers;
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
try
{
string publicStoreUrl = this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
if (storageContainers.Count() > 0)
{
foreach (StorageContainer storageContainer in storageContainers)
{
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
OpenStackPSDriveInfo kvsDriveInfo = new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl);
try
{
drives.Add(kvsDriveInfo);
}
catch (Exception) { }
}
}
else
{
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
return new Collection<PSDriveInfo>
{
new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl)
};
}
}
catch (Exception ex)
{
int g = 7;
}
return drives;
}
#endregion
}
}

View File

@@ -14,18 +14,18 @@
//limitations under the License.
//============================================================================ */
//using System.Management.Automation;
//using Openstack.Objects;
//using Openstack.Objects.Domain;
//using Openstack.Client.Powershell.Providers.Storage;
//using OpenStack.Objects;
//using OpenStack.Objects.Domain;
//using OpenStack.Client.Powershell.Providers.Storage;
//using System;
//using Openstack.Objects.DataAccess.Storage;
//using Openstack.Client.Powershell.Providers.Common;
//using OpenStack.Objects.DataAccess.Storage;
//using OpenStack.Client.Powershell.Providers.Common;
//using System.IO;
//namespace Openstack.Client.Powershell.Cmdlets.Common
//namespace OpenStack.Client.Powershell.Cmdlets.Common
//{
// [Cmdlet(VerbsCommon.Copy, "Item", SupportsShouldProcess = true)]
// [RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
// [RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
// public class CopyItemCmdlet : BasePSCmdlet
// {
// public const string cDelimiter = "/";
@@ -223,7 +223,7 @@
// IStorageObjectRepository repository = this.RepositoryFactory.CreateStorageObjectRepository();
// if (sourcePath.PathType == Openstack.Common.PathType.Local && targetPath.PathType == Openstack.Common.PathType.Remote)
// if (sourcePath.PathType == OpenStack.Common.PathType.Local && targetPath.PathType == OpenStack.Common.PathType.Remote)
// {
// long lastSegment = repository.GetLastSegmentId(targetPath);
// if (lastSegment != 0)

View File

@@ -15,16 +15,16 @@
//============================================================================ */
//using System;
//using System.Management.Automation;
//using Openstack.Client.Powershell.Providers.Common;
//using OpenStack.Client.Powershell.Providers.Common;
//using System.Security.Cryptography;
//using System.Text;
//using System.Web;
//using Openstack.Objects.Domain;
//using OpenStack.Objects.Domain;
//namespace Openstack.Client.Powershell.Cmdlets.Common
//namespace OpenStack.Client.Powershell.Cmdlets.Common
//{
// [Cmdlet(VerbsCommon.Get, "URI", SupportsShouldProcess = true)]
// [RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
// [RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
// public class GetURICmdlet : BasePSCmdlet
// {
// private string _sourcePath;

View File

@@ -15,19 +15,19 @@
//============================================================================ */
//using System;
//using System.Management.Automation;
//using Openstack.Objects.DataAccess;
//using Openstack.Objects.Domain;
//using Openstack.Client.Powershell.Providers.Storage;
//using Openstack.Common;
//using OpenStack.Objects.DataAccess;
//using OpenStack.Objects.Domain;
//using OpenStack.Client.Powershell.Providers.Storage;
//using OpenStack.Common;
//using System.Management.Automation.Host;
//using System.Collections.ObjectModel;
//using System.Diagnostics.Contracts;
//using Openstack.Client.Powershell.Providers.Common;
//using OpenStack.Client.Powershell.Providers.Common;
//namespace Openstack.Client.Powershell.Cmdlets.Common
//namespace OpenStack.Client.Powershell.Cmdlets.Common
//{
// [Cmdlet(VerbsCommon.Remove, "Item", SupportsShouldProcess = true)]
// [RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
// [RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
// public class RemoveItemCmdlet : BasePSCmdlet
// {
// public const string cDelimiter = "/";

View File

@@ -17,7 +17,7 @@ Echo ''
$a.ForegroundColor = "gray"
Echo '========================================================================================'
$a.ForegroundColor = "yellow"
Echo 'Welcome to the OpenStack Powershell Environment.333'
Echo 'Welcome to the OpenStack Powershell Environment.'
$a.ForegroundColor = "gray"
Echo '========================================================================================'
Echo ''
@@ -29,13 +29,42 @@ echo ' ==> Registering Providers...'
# $(TargetDir) macro in the Post-Build Script.
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
#cd C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release
cd C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Openstack.Client.Powershell\bin\Release
import-module .\CLIManifest.psd1 -DisableNameChecking
#Save the current value in the $p variable.
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
#Add the new path to the $p variable. Begin with a semi-colon separator.
$p += ";C:\Users\tplummer\Documents\WindowsPowerShell\Modules\OpenStack\"
#Add the paths in $p to the PSModulePath value.
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
#cd C:\Users\tplummer\Source\Repos\OpenStack-CLI\OpenStack.Client.Powershell\bin\Release
#cd C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\OpenStack.Client.Powershell\bin\Release
#import-module .\CLIManifest.psd1 -DisableNameChecking
import-module OpenStack-Core -DisableNameChecking
cd Builds:
cd 1-3-4-5
#set-sp Rackspace
#cd OpenStack:
#cd Networks

View File

@@ -46,7 +46,7 @@
echo ' ==> Registering Providers...'
$tempvar = get-programfilesdir
$tempvar = $tempvar + "\Openstack\OpenStack-Powershell"
$tempvar = $tempvar + "\OpenStack\OpenStack-Powershell"
cd $tempvar
import-module .\CLIManifest.psd1 -DisableNameChecking

View File

@@ -847,7 +847,7 @@
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>
Resets the current session settings to those defined within the default config file (CLI.config)
Resets the current session settings to those defined within the default config file (OpenStack.config)
</maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
@@ -898,7 +898,7 @@
</command:details>
<maml:description>
<maml:para>
When you issue this command the URI is also pasted to the Windows clipboard for your convenience. If you want to disable this behavior simply set the CLI.config option entitled PasteGetURIResultsToClipboard to false.
When you issue this command the URI is also pasted to the Windows clipboard for your convenience. If you want to disable this behavior simply set the OpenStack.config option entitled PasteGetURIResultsToClipboard to false.
</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<Testing>
<add key="TestServerName" value="TestServer" />
<add key="TestNetworkName" value="TestNetwork" />
<add key="TestPortName" value="TestPort" />
<add key="TestRouterName" value="TestRouter" />
<add key="TestSecurityGroupName" value="TestSecurityGroup" />
<add key="TestSnapshotName" value="TestSnapshot" />
<add key="TestStorageContainerName" value="TestContainer" />
<add key="TestSubnetName" value="TestSubnet" />
<add key="TestVolumeName" value="TestVolume" />
<add key="TestFilePath" value="e:\Projects\Testing\Anothertest.txt" />
<add key="TestStorageContainerSecondaryName" value="b10" />
<add key="LocalTestDirectory" value="e:\Projects\Testing\" />
<add key="TestImageId" value="5a1408cb-25f2-43a6-b1d9-931f5e47c871" />
<add key="TestFlavorId" value="100" />
</Testing>
<StorageManagement>
<add key="largeFileSize" value="314572800" />
<add key="defSegmentNumber" value="16" />
<add key="MaxSegmentCopyRetries" value="3" />
<add key="UseCleanLargeFileCopies" value="false" />
<add key="delimiter" value="/" />
<add key="max-keys" value="10000" />
<add key="HttpTimeoutInterval" value="9200000" />
<add key="PasteGetURIResultsToClipboard" value="true" />
<add key="ReleaseNotesURI" value="https://region-a.geo-1.objects.hpcloudsvc.com/v1/AUTH_2485a207-71a4-4429-9e24-f7bf49e207fc/Builds/ReleaseManifest.xml" />
<add key="NewReleaseFolder" value="e:\" />
<SharedContainers></SharedContainers>
</StorageManagement>
<IdentityServices>
<ServiceProvider name="HP" isDefault = "true">
<add key="AuthenticationServiceURI" value="" displayName="Authentication Service URI" helpText ="" isMandatory="True"/>
<add key="Username" value="" displayName="User name" helpText ="" isMandatory="True"/>
<add key="Password" value="" displayName="Password" helpText ="" isMandatory="True" />
<add key="DefaultTenantId" value="" displayName="Default Tenant Id" helpText ="" isMandatory="True"/>
</ServiceProvider>
<ServiceProvider name="Rackspace" isDefault = "false">
<add key="ConfigFilePath" value="C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Rackspace.Client.Powershell\Deployment\Rackspace.config" />
</ServiceProvider>
</IdentityServices>
<ComputeServices>
<add key="LogReadAttemptsMax" value="20" />
<add key="LogReadAttemptIntervalInMilliSeconds" value="40000" />
<add key="EnableCredentialTracking" value="true" />
<add key="SSHClientPath" value="C:\Users\tplummer\Desktop\Utilities\Putty.exe" />
</ComputeServices>
<AvailabilityZones>
<AvailabilityZone id="1" isDefault="True" name="region-a.geo-1" shellForegroundColor="Green" />
<AvailabilityZone id="2" isDefault="False" name="region-b.geo-1" shellForegroundColor="Green" />
</AvailabilityZones>
</appSettings>
</configuration>

View File

@@ -3,8 +3,8 @@
<SelectionSet>
<Name>ObjectStorageTypes</Name>
<Types>
<TypeName>Openstack.Storage.StorageObject</TypeName>
<TypeName>Openstack.Storage.StorageContainer</TypeName>
<TypeName>OpenStack.Storage.StorageObject</TypeName>
<TypeName>OpenStack.Storage.StorageContainer</TypeName>
</Types>
</SelectionSet>
</SelectionSets>-->
@@ -14,7 +14,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Admin.Zone</TypeName>
<TypeName>OpenStack.Objects.Domain.Admin.Zone</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -65,7 +65,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.BlockStorage.Snapshot</TypeName>
<TypeName>OpenStack.Objects.Domain.BlockStorage.Snapshot</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -149,7 +149,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.BlockStorage.VolumeBackup</TypeName>
<TypeName>OpenStack.Objects.Domain.BlockStorage.VolumeBackup</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -247,7 +247,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.BlockStorage.Volume</TypeName>
<TypeName>OpenStack.Objects.Domain.BlockStorage.Volume</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -368,7 +368,7 @@
<View>
<Name>KeyPair</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Server.KeyPair</TypeName>
<TypeName>OpenStack.Objects.Domain.Server.KeyPair</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -421,7 +421,7 @@
<View>
<Name>Port</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Networking.Port</TypeName>
<TypeName>OpenStack.Objects.Domain.Networking.Port</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -526,7 +526,7 @@
<View>
<Name>Subnet</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Networking.Subnet</TypeName>
<TypeName>OpenStack.Objects.Domain.Networking.Subnet</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -603,7 +603,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Client.Powershell.Utility.ServiceProvider</TypeName>
<TypeName>OpenStack.Client.Powershell.Utility.ServiceProvider</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -653,7 +653,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Networking.FloatingIP</TypeName>
<TypeName>OpenStack.Objects.Domain.Networking.FloatingIP</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -743,7 +743,7 @@
<View>
<Name>StorageContainer</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.StorageContainer</TypeName>
<TypeName>OpenStack.Objects.Domain.StorageContainer</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -768,7 +768,7 @@
<View>
<Name>Network</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Networking.Network</TypeName>
<TypeName>OpenStack.Objects.Domain.Networking.Network</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -849,7 +849,7 @@
<View>
<Name>service</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Admin.Service</TypeName>
<TypeName>OpenStack.Objects.Domain.Admin.Service</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -889,7 +889,7 @@
<View>
<Name>process4</Name>
<ViewSelectedBy>
<TypeName>Openstack.Client.Powershell.Providers.ObjectStorage.StorageItemViewModel</TypeName>
<TypeName>OpenStack.Client.Powershell.Providers.ObjectStorage.StorageItemViewModel</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -939,7 +939,7 @@
<View>
<Name>process4</Name>
<ViewSelectedBy>
<TypeName>Openstack.Storage.StorageObject</TypeName>
<TypeName>OpenStack.Storage.StorageObject</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -988,7 +988,7 @@
<View>
<Name>process5</Name>
<ViewSelectedBy>
<TypeName>Openstack.Storage.StorageFolder</TypeName>
<TypeName>OpenStack.Storage.StorageFolder</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1037,7 +1037,7 @@
<View>
<Name>Router</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Networking.Router</TypeName>
<TypeName>OpenStack.Objects.Domain.Networking.Router</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1106,7 +1106,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Client.Powershell.Providers.Common.BaseUIContainer</TypeName>
<TypeName>OpenStack.Client.Powershell.Providers.Common.BaseUIContainer</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1162,7 +1162,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Administration.Domain.User</TypeName>
<TypeName>OpenStack.Administration.Domain.User</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1210,7 +1210,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName> Openstack.Objects.Domain.Compute.Account</TypeName>
<TypeName> OpenStack.Objects.Domain.Compute.Account</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1249,7 +1249,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Administration.Domain.Group</TypeName>
<TypeName>OpenStack.Administration.Domain.Group</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1297,7 +1297,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Compute.Server</TypeName>
<TypeName>OpenStack.Objects.Domain.Compute.Server</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1389,7 +1389,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Compute.Image</TypeName>
<TypeName>OpenStack.Objects.Domain.Compute.Image</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1512,7 +1512,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Security.SecurityGroup</TypeName>
<TypeName>OpenStack.Objects.Domain.Security.SecurityGroup</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1582,7 +1582,7 @@
<View>
<Name>process</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Compute.MetaDataElement</TypeName>
<TypeName>OpenStack.Objects.Domain.Compute.MetaDataElement</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>
@@ -1625,7 +1625,7 @@
<View>
<Name>flavor</Name>
<ViewSelectedBy>
<TypeName>Openstack.Objects.Domain.Compute.Flavor</TypeName>
<TypeName>OpenStack.Objects.Domain.Compute.Flavor</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>

View File

@@ -0,0 +1,21 @@
@{
ModuleToProcess = 'OpenStack.Client.Powershell.dll'
GUID="{847a28a4-6407-4aa6-8070-a4a51396db70}"
Author="Travis Plummer"
CompanyName="Hewlett-Packard Corporation"
Copyright="© Hewlett-Packard. All rights reserved."
ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FormatsToProcess="OpenStack.format.ps1xml"
FileList='OpenStack.config'
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
}

View File

@@ -1,21 +1,13 @@

=====================================================================================================================
ACTION REQUIRED : Change the DocPath Variable below to reflect your Personal Documents Folder..
=====================================================================================================================
set DocPath=C:\Users\Travis\Documents
echo set DocPath=C:\Users\Travis\Documents
md %DocPath%\WindowsPowershell\
md %DocPath%\OS\
md %DocPath%\OS\
echo md %DocPath%\WindowsPowershell\
echo md %DocPath%\OS\
echo md %DocPath%\OS\
echo copy ..\..\.\Deployment\DevProfile.ps1 %DocPath%\WindowsPowershell\Microsoft.PowerShell_profile.ps1
copy ..\..\.\Deployment\DevProfile.ps1 C:\Users\tplummer\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
copy ..\..\.\Deployment\CLI.config C:\Users\tplummer\Documents\OS\CLI.config
copy ..\..\.\Deployment\Openstack.Client.Powershell.dll-Help.xml %DocPath%\OS\Openstack.Client.Powershell.dll-Help.xml
copy ..\..\.\Deployment\OpenstackShell.format.ps1xml C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\OpenstackShell.format.ps1xml
echo copy ..\..\.\Deployment\DevProfile.ps1 C:\Users\tplummer\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
echo copy ..\..\.\Deployment\OpenStack.config C:\Users\tplummer\Documents\OS\OpenStack.config
echo copy ..\..\.\Deployment\OpenStack.Client.Powershell.dll-Help.xml %DocPath%\OS\OpenStack.Client.Powershell.dll-Help.xml
echo copy ..\..\.\Deployment\OpenstackShell.format.ps1xml C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\OpenStack.Client.Powershell\bin\Release\OpenstackShell.format.ps1xml
echo copy C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.dll C:\Users\tplummer\Source\Repos\OpenStack.HP.Extensions\Openstack.HP.Extensions\bin\Debug
echo %DocPath%\OS\OpenstackShell.format.ps1xml

View File

@@ -9,5 +9,5 @@ set DocPath=C:\Users\Travis\Documents
md %DocPath%\OS\
copy ..\..\.\Deployment\DevProfile.ps1 %DocPath%\WindowsPowershell\Microsoft.PowerShell_profile.ps1
copy ..\..\.\Deployment\CLI.config %DocPath%\OS\CLI.config
copy ..\..\.\Deployment\Openstack.Client.Powershell.dll-Help.xml %DocPath%\OS\Openstack.Client.Powershell.dll-Help.xml
copy ..\..\.\Deployment\OpenStack.config %DocPath%\OS\OpenStack.config
copy ..\..\.\Deployment\OpenStack.Client.Powershell.dll-Help.xml %DocPath%\OS\OpenStack.Client.Powershell.dll-Help.xml

View File

@@ -1,92 +0,0 @@
====================================================================================================================
/// <summary>
///
/// </summary>
/// <param name="storageContainer"></param>
/// <param name="path"></param>
/// <returns></returns>
//======================================================================================================================
public StorageObject GetStorageObject(string path)
{
try
{
path = path.Replace(@"\", "/");
RequestHeaders headers = StorageRequestSigner.CreateSignedHeaders(HttpMethod.GET, path);
string resourcePath = ["StorageManagementURI"] + "/" + path;
HttpClient client = new HttpClient();
client.DefaultHeaders = headers;
Uri uri = new Uri(resourcePath);
HttpResponseMessage msg = client.Get(uri);
if (msg.StatusCode == System.Net.HttpStatusCode.OK)
{
msg.Content.LoadIntoBufferAsync();
StorageObject storageObject = new StorageObject();
storageObject.Key = path;
storageObject.Load(msg.Content.ReadAsStream());
this.CopyCommonRequestHeaders(ref storageObject, msg.Headers);
return storageObject;
}
else
{
return null;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return null;
}
//======================================================================================================================
/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
//======================================================================================================================
public bool IsValidPath(string storageContainer, string path)
{
HttpClient client = new HttpClient();
Uri uri = new Uri(["StorageManagementURI"] + cDelimiter + storageContainer + cDelimiter + path + cDelimiter + "folder.txt");
string rootCheck = null;
if (path == cDelimiter) {
rootCheck = String.Empty;
}
else {
rootCheck = cFolderMarker;
}
if (this.GetStorageObject(storageContainer + cDelimiter + path + cDelimiter + rootCheck) != null)
{
return true;
}
else
{
return false;
}
}
//======================================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//======================================================================================================================
public StorageObjects GetStorageObjects (string storageContainer, string path)
{
HttpQueryString queryString = new HttpQueryString();
if (path == "")
{
queryString.Add("prefix", "" );
queryString.Add("delimiter", "/");
}
else
{
path = path.Replace(@"\", "/");
queryString.Add("prefix", path);
queryString.Add("delimiter", "/");
}

View File

@@ -1,47 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
DefaultTargets="Compile">
<ItemGroup>
<BuildArtifactsDir Include="Compile\" />
</ItemGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<BuildPlatform Condition=" '$(BuildPlatform)' == '' ">Any CPU</BuildPlatform>
</PropertyGroup>
<Target Name="Clean">
<RemoveDir Directories="@(BuildArtifactsDir)" />
</Target>
<Target Name="Init">
<MakeDir Directories="$(TargetDir)" />
</Target>
<Target Name="Compile" DependsOnTargets="Init">
<MSBuild Projects="@(SolutionFile)"
Targets="Rebuild"
Properties="OutDir=%(BuildArtifactsDir.FullPath);Configuration=$(Configuration);Platform=$(BuildPlatform)" />
<Exec Command="echo --------------------------------------" />
<Exec Command="echo Updating the local dev environment." />
<Exec Command="echo --------------------------------------" />
<Copy SourceFiles="$(ProjectDir)\Deployment\OpenstackShell.format.ps1xml" DestinationFiles="$(TargetDir)\OpenstackShell.format.ps1xml"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\CLIManifest.psd1" DestinationFiles="$(TargetDir)\CLIManifest.psd1"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\powershell.exe.config" DestinationFiles="$(TargetDir)\powershell.exe.config"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\Microsoft.PowerShell_profile.ps1" DestinationFiles="$(TargetDir)\Microsoft.PowerShell_profile.ps1"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\CLI.config" DestinationFiles="$(TargetDir)\CLI.config"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\Openstack.Client.Powershell.dll-Help.xml" DestinationFiles="$(TargetDir)\en-Us\Openstack.Client.Powershell.dll-Help.xml"/>
<Copy SourceFiles= "$(ProjectDir)\Deployment\CredentialList.xml" DestinationFiles="$(TargetDir)\CredentialList.xml"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\OpenstackShell.format.ps1xml" DestinationFiles="$(TargetDir)\en-US\OpenstackShell.format.ps1xml"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\OpenstackShell.format.ps1xml" DestinationFiles="$(TargetDir)\OpenstackShell.format.ps1xml"/>
<Copy SourceFiles="$(ProjectDir)\Deployment\Openstack.Client.Powershell.dll-Help.xml" DestinationFiles="$(TargetDir)\en-US\Openstack.Client.Powershell.dll-Help.xml"/>
<!--<Copy SourceFiles="C:\Projects\Openstack\CLI\RDPClient\bin\Debug\*.*" DestinationFiles="$(TargetDir)\..\..\Openstack\API\Openstack.Objects\obj\Debug"/>-->
<!--<Copy SourceFiles="C:\Projects\Openstack\CLI\RDPClient\bin\Debug\*.* " DestinationFiles="$(TargetDir)\en-Us"/>-->
<!-- ======================================================================================================================================================================== -->
<!-- TODO : Change the paths below to reflect your development environment..-->
<!-- ======================================================================================================================================================================== -->
<Copy SourceFiles = "$(TargetDir)\CLI.config" DestinationFiles = "C:\Users\tplummer\Documents\OS\CLI.config"/>
<Copy SourceFiles = "$(ProjectDir)\Deployment\DevProfile.ps1" DestinationFiles = "C:\Users\tplummer\Documents\WindowsPowershell\Microsoft.PowerShell_profile.ps1"/>
<Copy SourceFiles = "$(ProjectDir)\Deployment\CredentialList.xml" DestinationFiles = "C:\Users\tplummer\Documents\OS\CredentialList.xml="/>
</Target>
</Project>

View File

@@ -1,6 +0,0 @@

<security_group id="222" name="default" tenant_id="58196046451129">
</security_group>

View File

@@ -1,85 +0,0 @@
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group id="222" name="default" tenant_id="58196046451129">
<rules>
<rule id="325" parent_group_id="222">
<from_port>
22
</from_port>
<group/>
<ip_protocol>
tcp
</ip_protocol>
<to_port>
22
</to_port>
<ip_range>
<cidr>
0.0.0.0/0
</cidr>
</ip_range>
</rule>
<rule id="326" parent_group_id="222">
<from_port>
-1
</from_port>
<group/>
<ip_protocol>
icmp
</ip_protocol>
<to_port>
-1
</to_port>
<ip_range>
<cidr>
0.0.0.0/0
</cidr>
</ip_range>
</rule>
</rules>
<description>
default
</description>
</security_group>
<security_group id="112" name="defaul2t" tenant_id="58196046451129">
<rules>
<rule id="325" parent_group_id="222">
<from_port>
11
</from_port>
<group/>
<ip_protocol>
tcp
</ip_protocol>
<to_port>
33
</to_port>
<ip_range>
<cidr>
0.0.0.0/0
</cidr>
</ip_range>
</rule>
<rule id="326" parent_group_id="222">
<from_port>
-1
</from_port>
<group/>
<ip_protocol>
icmp
</ip_protocol>
<to_port>
-1
</to_port>
<ip_range>
<cidr>
0.0.0.0/0
</cidr>
</ip_range>
</rule>
</rules>
<description>
default
</description>
</security_group>
</security_groups>

View File

@@ -1,6 +0,0 @@
<security_groups xmlns="http://docs.openstack.org/compute/api/v1.1">
<security_group id="222" name="default" tenant_id="58196046451129">
</security_group>
</security_groups>

View File

@@ -1,49 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1"
xmlns:atom="http://www.w3.org/2005/Atom"
id="52415800-8b69-11e0-9b19-734f000004d2"
tenant_id="1234"
user_id="5678"
name="sample-server"
status="BUILD"
updated="2010-10-10T12:00:00Z"
created="2010-08-10T12:00:00Z"
progress="60"
hostId="e4d909c290d0fb1ca068ffaddf22cbd0"
accessIPv4="67.23.10.132"
accessIPv6="::babe:67.23.10.132">
<image id="52415800-8b69-11e0-9b19-734f6f006e54">
<atom:link
rel="self"
href="http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"/>
<atom:link
rel="bookmark"
href="http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"/>
</image>
<flavor id="52415800-8b69-11e0-9b19-734f216543fd">
<atom:link
rel="self"
href="http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"/>
<atom:link
rel="bookmark"
href="http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"/>
</flavor>
<metadata>
<meta key="Server Label">Web Head 1</meta>
<meta key="Image Version">2.1</meta>
</metadata>
<addresses>
<network id="public">
<ip version="4" addr="67.23.10.132"/>
<ip version="6" addr="::babe:67.23.10.132"/>
<ip version="4" addr="67.23.10.131"/>
<ip version="6" addr="::babe:4317:0A83"/>
</network>
<network id="private">
<ip version="4" addr="10.176.42.16"/>
<ip version="6" addr="::babe:10.176.42.16"/>
</network>
</addresses>
</server>

View File

@@ -1,50 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<server xmlns="http://docs.openstack.org/compute/api/v1.1"
xmlns:atom="http://www.w3.org/2005/Atom"
id="52415800-8b69-11e0-9b19-734f000004d2"
tenant_id="1234" user_id="5678"
name="sample-server" status="BUILD"
updated="2010-10-10T12:00:00Z" created="2010-08-10T12:00:00Z"
progress="60" hostId="e4d909c290d0fb1ca068ffaddf22cbd0"
accessIPv4="67.23.10.132"
accessIPv6="::babe:67.23.10.132">
<image id="52415800-8b69-11e0-9b19-734f6f006e54">
<atom:link
rel="self"
href="http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"/>
<atom:link
rel="bookmark"
href="http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"/>
</image>
<flavor id="52415800-8b69-11e0-9b19-734f216543fd">
<atom:link
rel="self"
href="http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"/>
<atom:link
rel="bookmark"
href="http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"/>
</flavor>
<metadata>
<meta key="Server Label">Web Head 1</meta>
<meta key="Image Version">2.1</meta>
</metadata>
<addresses>
<network id="public">
<ip version="4" addr="67.23.10.132"/>
<ip version="6" addr="::babe:67.23.10.132"/>
<ip version="4" addr="67.23.10.131"/>
<ip version="6" addr="::babe:4317:0A83"/>
</network>
<network id="private">
<ip version="4" addr="10.176.42.16"/>
<ip version="6" addr="::babe:10.176.42.16"/>
</network>
</addresses>
<atom:link
rel="self"
href="http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f000004d2"/>
<atom:link
rel="bookmark"
href="http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f000004d2"/>
</server>

View File

@@ -1,14 +0,0 @@
<servers xmlns="http://docs.openstack.org/compute/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom">
<server id="55555" name="Server 55555">
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/v1.1/58196046451129/servers/55555" rel="self"/>
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/58196046451129/servers/55555" rel="bookmark"/>
</server>
<server id="5115555" name="Server 55555">
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/v1.1/58196046451129/servers/55555" rel="self"/>
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/58196046451129/servers/55555" rel="bookmark"/>
</server>
<server id="5522555" name="Server 5445555">
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/v1.1/58196046451129/servers/55555" rel="self"/>
<atom:link href="https://az-1.region-a.geo-1.compute.Openstacksvc.com/58196046451129/servers/55555" rel="bookmark"/>
</server>
</servers>

View File

@@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="StorageQueueService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8010/StorageQueueService"
binding="basicHttpBinding" bindingConfiguration="StorageQueueService"
contract="ServiceReference1.IStorageQueue" name="StorageQueueService" />
</client>
</system.serviceModel>
</configuration>

View File

@@ -1,4 +1,4 @@
Openstack Powershell CLI - Getting Set up to Contribute
OpenStack Powershell CLI - Getting Set up to Contribute
I - Pre-requisits
@@ -6,7 +6,7 @@ I - Pre-requisits
A. Set the Required Execution Policy
To use the Openstack CLI Software for Windows PowerShell, you must make sure that your Powershell environment is capable of executing 3rd party modules.
To use the OpenStack CLI Software for Windows PowerShell, you must make sure that your Powershell environment is capable of executing 3rd party modules.
Note: If you are performing a re-installation of the software package, you can skip this step. This step is applicable only for a fresh installation.
Open a PowerShell window as the administrator and issue the command set-executionpolicy -ExecutionPolicy Unrestricted:
@@ -31,27 +31,27 @@ I - Pre-requisits
C. - Supplying your Credentials
Our next step is to make sure that we supply the proper credentials when logging on to the system. If you ran the CLI after your initial
install, you'll have noticed that you were prompted for this information. The result is stored in the CLI.config file located within the Users Personal Data Folder
install, you'll have noticed that you were prompted for this information. The result is stored in the OpenStack.config file located within the Users Personal Data Folder
under the OS directory. With each Build we must update that file with the version in our solution. This is so that when new config file changes are introduced, you
have the CLI picking them up at runtime from the expected location (instead of residing in just your project directory). Complete these steps to supply this information.
1. Navigate to the Openstack.Client.Powershell project and look into the Deployment folder.
2. Within that folder you will see a file called CLI.config.example
1. Navigate to the OpenStack.Client.Powershell project and look into the Deployment folder.
2. Within that folder you will see a file called OpenStack.config.example
3. Copy the example file into the same folder but remove the .example on the filename.
4. Open up the CLI.config file that you just created.
4. Open up the OpenStack.config file that you just created.
5. Find the config section entitled "IdentityServices".
6. Within this section supply values for Username, Password, and Default Tenenat Id. All of this can be found within your account information on you providers portal.
Each time that we build, this CLI.config file will be moved to the correct runtime location via Post-Build Scripts outlined in the next section.
Each time that we build, this OpenStack.config file will be moved to the correct runtime location via Post-Build Scripts outlined in the next section.
D. - Edit Post Build Scripts
Within the Openstack.Client.Powershell projects Post-Build Event you'll notice that we call a PostBuild.bat file. This
Within the OpenStack.Client.Powershell projects Post-Build Event you'll notice that we call a PostBuild.bat file. This
batch file will move important run-time files required by the CLI to their proper locations if you decide to edit them.
Without this, all changes to important files (like CLI.config) would go unnoticed because they would sit in our project
Without this, all changes to important files (like OpenStack.config) would go unnoticed because they would sit in our project
folders on disk (rather than the location the CLI expects). To create tis batch file, follow these steps.
1. Navigate to the Openstack.Client.Powershell project and look into the Deployment folder.
1. Navigate to the OpenStack.Client.Powershell project and look into the Deployment folder.
2. Within that folder you will see a file called PostBuild.example
3. Open up that file and copy the contents to the clipboard.
4. Within that same folder create a file called PostBuild.bat
@@ -66,7 +66,7 @@ Powershell loads. Here we can set up the look of the environment, issue some def
and loading Powershell Modules. The Powershell module is where all of our CLI code resides and must get loaded by this script.
The only problem here is that the path to that module is specific to your machine. To address this follow these steps
1. Open up the DevProfile.ps1.example file within the Solutions [Openstack.Client.Powershell]\Deployment folder.
1. Open up the DevProfile.ps1.example file within the Solutions [OpenStack.Client.Powershell]\Deployment folder.
2. Copy the contents of this file into a new text file called DevProfile.ps1
3. Search this document for "ACTION REQUIRED" and follow the instructions given.
@@ -122,5 +122,5 @@ III. Testing
-> Folder2 (contains files)
-> Folder3 (contains NO files)
Note : Go to the Testing section in the CLI.Config file. Make sure that LocalTestDirectory
Note : Go to the Testing section in the OpenStack.config file. Make sure that LocalTestDirectory
element points to the root of the test folder hierarchy (Folder1 in the example above).

View File

@@ -21,7 +21,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core\</OutputPath>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
@@ -62,12 +62,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\AWSSDK.2.0.11.0\lib\net45\AWSSDK.dll</HintPath>
</Reference>
<Reference Include="BouncyCastle.Crypto, Version=1.7.4137.9688, Culture=neutral, PublicKeyToken=a4292a325f69b123, processorArchitecture=MSIL">
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\BouncyCastle.1.7.0\lib\Net40-Client\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.5.7\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
@@ -95,9 +92,19 @@
<ItemGroup>
<Compile Include="BaseNavigationCmdletProvider.cs" />
<Compile Include="Cmdlets\BasePSCmdlet.cs" />
<Compile Include="Cmdlets\Common\BaseAuthenticationCmdlet.cs" />
<Compile Include="Cmdlets\Common\BasePSCmdlet.cs" />
<Compile Include="Cmdlets\Common\GetCatalogCmdlet.cs" />
<Compile Include="Cmdlets\Common\GetConfigCmdlet.cs" />
<Compile Include="Cmdlets\Common\GetVersionCmdlet.cs" />
<Compile Include="Cmdlets\Common\GetZoneCmdlet.cs" />
<Compile Include="Cmdlets\Common\GetZonesCmdlet.cs" />
<Compile Include="Cmdlets\Common\SetConfigCmdlet.cs" />
<Compile Include="Utility\AccountCapabilities.cs" />
<Compile Include="Utility\CredentialElement.cs" />
<Compile Include="Cmdlets\Common\GetServiceProvidersCmdlet.cs" />
<Compile Include="Cmdlets\Common\NewServiceProvider.cs" />
<Compile Include="Cmdlets\Common\NewServiceProviderCmdlet.cs" />
<Compile Include="Cmdlets\Common\SetServiceProviderCmdlet.cs" />
<Compile Include="Cmdlets\ObjectStorage\Objects\CopyItemCmdlet.cs" />
<Compile Include="Cmdlets\ObjectStorage\Objects\GetURICmdlet.cs" />
<Compile Include="Cmdlets\ObjectStorage\Objects\RemoveItemCmdlet.cs" />
@@ -109,25 +116,31 @@
<Compile Include="Providers\ObjectStorage\HPOSNavigationProvider.cs" />
<Compile Include="Utility\Context.cs" />
<Compile Include="Utility\Enums.cs" />
<Compile Include="Utility\ExtensionManager.cs" />
<Compile Include="Utility\OpenstackCoreRegistrationManager.cs" />
<Compile Include="Utility\RegistrationManager.cs" />
<Compile Include="Utility\RegistrationResponse.cs" />
<Compile Include="Utility\SecureStringHelper.cs" />
<Compile Include="Utility\ServiceProvider.cs" />
<Compile Include="Utility\ConfigurationManager.cs" />
<Compile Include="Utility\Settings.cs" />
<Compile Include="Utility\StoragePath.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Deployment\CLI.config">
<None Include="Deployment\Openstack.config">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Deployment\DevProfile.ps1" />
<None Include="Deployment\PostBuild.bat" />
<None Include="Deployment\ScratchPad\app.config" />
<None Include="Deployment\CLI.config.example">
<None Include="Deployment\Openstack.config.example">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Deployment\DevProfile.ps1.example" />
<None Include="Deployment\OpenstackShell.format.ps1xml">
<None Include="Deployment\Openstack.format.ps1xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
@@ -175,7 +188,9 @@
<Content Include="Deployment\CredentialList.xml">
<SubType>Designer</SubType>
</Content>
<Content Include="Deployment\Openstack.Client.Powershell.dll-Help.xml" />
<Content Include="Deployment\Openstack.Client.Powershell.dll-Help.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Deployment\readme.txt" />
<Content Include="Deployment\ReleaseManifest.xml" />
<Content Include="Deployment\ScratchPad\SecurityGroupData\SecurityGroupTest.xml" />
@@ -187,7 +202,7 @@
<Content Include="Deployment\ScratchPad\ServerData\Server1.xml" />
<Content Include="Deployment\ScratchPad\ServerData\Servers.xml" />
<Content Include="License.txt" />
<None Include="Deployment\CLIManifest.psd1">
<None Include="Deployment\Openstack.psd1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Deployment\ReleaseNotes.xml">
@@ -199,10 +214,6 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\openstack-sdk-dotnet\Openstack\Openstack.Common\Openstack.Common.csproj">
<Project>{c53d669c-cdf1-4157-aec1-bd167f655b2b}</Project>
<Name>Openstack.Common</Name>
</ProjectReference>
<ProjectReference Include="..\..\openstack-sdk-dotnet\Openstack\Openstack\Openstack.csproj">
<Project>{b2c92371-b62b-45a2-adeb-edebefa3a75c}</Project>
<Name>Openstack</Name>
@@ -220,11 +231,17 @@
Echo Executing Post-Build Scripts
Echo =====================
copy ..\..\.\Deployment\CLIManifest.psd1 $(ProjectDir)\bin\release\CLIManifest.psd1
copy ..\..\.\Deployment\OpenstackShell.format.ps1xml $(ProjectDir)\bin\release\OpenstackShell.format.ps1xml
copy ..\..\.\Deployment\Openstack.Client.Powershell.dll-help.xml $(ProjectDir)\bin\release\Openstack.Client.Powershell.dll-help.xml
call $(ProjectDir)Deployment\PostBuild.bat</PostBuildEvent>
copy C:\Users\tplummer\Source\Repos\openstack-cli-powershell\Openstack.Client.Powershell\Deployment\*.* C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core
copy C:\Users\tplummer\Source\Repos\openstack-cli-powershell\Openstack.Client.Powershell\Deployment\DevProfile.ps1 C:\Users\tplummer\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1
copy C:\Users\tplummer\Source\Repos\openstack-cli-powershell\Openstack.Client.Powershell\Deployment\Openstack.config C:\Users\tplummer\Documents\OS\Openstack.config
</PostBuildEvent>
</PropertyGroup>
<!--<Import Project="$(ProjectDir)\Deployment\PostBuild.targets" Condition="Exists('$(ProjectDir)\Deployment\PostBuild.targets')" />-->
<!---->

View File

@@ -20,11 +20,11 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Openstack.Client.Powershell")]
[assembly: AssemblyTitle("OpenStack.Client.Powershell")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("OpenStack")]
[assembly: AssemblyProduct("Openstack.Client.Powershell")]
[assembly: AssemblyProduct("OpenStack.Client.Powershell")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

View File

@@ -0,0 +1,85 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System.Collections;
using System.Collections.Generic;
using System.Management.Automation;
using Openstack.Objects.DataAccess;
using Openstack.Common.DataAccess;
using Openstack.Client.Powershell.Providers.Common;
namespace Openstack.Client.Powershell.Providers.Common
{
public class CommonDriveInfo : PSDriveInfo
{
private CommonDriveParameters _parameters = null;
private BaseUIContainer _currentContainer = null;
#region Ctors
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="driveInfo"></param>
//==================================================================================================
public CommonDriveInfo(PSDriveInfo driveInfo, CommonDriveParameters parameters) : base (driveInfo)
{
_parameters = parameters;
}
#endregion
#region Methods
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
public Hashtable GetParameters()
{
return null;
}
#endregion
#region Properties
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
public BaseUIContainer CurrentTenant
{
get { return _currentContainer; }
set
{
_currentContainer = value;
this.CurrentLocation = _currentContainer.Path;
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
public BaseUIContainer CurrentContainer
{
get { return _currentContainer; }
set
{
_currentContainer = value;
this.CurrentLocation = _currentContainer.Path;
}
}
#endregion
}
}

View File

@@ -16,17 +16,17 @@ limitations under the License.
using System.Collections.Generic;
using System.Management.Automation;
using System.Collections;
using Openstack;
using OpenStack;
using System.Diagnostics.Contracts;
using Openstack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Utility;
using System;
using System.IO;
using System.Linq;
using Openstack.Storage;
using Openstack.Identity;
using OpenStack.Storage;
using OpenStack.Identity;
namespace Openstack.Client.Powershell.Providers.Storage
namespace OpenStack.Client.Powershell.Providers.Storage
{
public class OpenStackPSDriveInfo : PSDriveInfo
{
@@ -138,7 +138,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
{
foreach (PSDriveInfo drive in this.Provider.Drives)
{
if (drive.Provider.Name == "OS-Storage" && drive.Name.Contains(name))
if (drive.Provider.Name == "Object Storage" && drive.Name.Contains(name))
return true;
}
return false;
@@ -228,6 +228,23 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// <summary>
///
/// </summary>
//==================================================================================================
private string StorageServiceURL
{
get
{
return this._context.ServiceCatalog.GetPublicEndpoint("object-store", null).ToString();
//if (this.Drive.SharePath == null)
// return this.Context.ServiceCatalog.GetPublicEndpoint("object-store", null).ToString(); //.GetService("object-store").Url;
//else
// return this.Drive.SharePath;
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
//==================================================================================================
@@ -250,6 +267,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
// If the path supplied already contains a storageContainer name, strip it out and pass it in as the volume name..
path = path.Replace(firstElement, string.Empty);
return new StoragePath(this.StorageServiceUrl);
}
@@ -345,7 +363,11 @@ namespace Openstack.Client.Powershell.Providers.Storage
{
get
{
return _storageServiceUrl;
if (this.SharePath == null)
return this._context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
//return this._context.ServiceCatalog.GetPublicEndpoint("Object Storage", null).ToString();
else
return this.SharePath;
}
}
//==================================================================================================

View File

@@ -13,9 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using Openstack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Utility;
namespace Openstack.Client.Powershell.Providers.Storage
namespace OpenStack.Client.Powershell.Providers.Storage
{
public class OSDriveParameters
{

View File

@@ -19,16 +19,17 @@ using System.Linq;
using System.Management.Automation;
using System.Management.Automation.Provider;
using System.Collections.ObjectModel;
using Openstack.Storage;
using Openstack.Client.Powershell.Utility;
using Openstack.Client.Powershell.Providers.Common;
using OpenStack.Storage;
using OpenStack.Client.Powershell.Utility;
using OpenStack.Client.Powershell.Providers.Common;
using System.Management.Automation.Runspaces;
using Openstack;
using OpenStack;
using System.Threading.Tasks;
using System.Threading;
using Openstack.Client.Powershell.Providers.ObjectStorage;
using OpenStack.Client.Powershell.Providers.ObjectStorage;
namespace Openstack.Client.Powershell.Providers.Storage
namespace OpenStack.Client.Powershell.Providers.Storage
{
[CmdletProvider("Object Storage", ProviderCapabilities.ExpandWildcards)]
public class HPOSNavigationProvider : BaseNavigationCmdletProvider
@@ -49,7 +50,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
{
get
{
IOpenstackClient client = (IOpenstackClient)this.SessionState.PSVariable.GetValue("Client", null);
IOpenStackClient client = (IOpenStackClient)this.SessionState.PSVariable.GetValue("CoreClient", null);
return client.CreateServiceClient<IStorageServiceClient>();
}
@@ -70,6 +71,22 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// <summary>
///
/// </summary>
//==================================================================================================
private string StorageServiceURL
{
get
{
if (this.Drive == null || this.Drive.SharePath == null)
return this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
//return this.Context.ServiceCatalog.GetPublicEndpoint("object-store", null).ToString(); //.GetService("object-store").Url;
else
return this.Drive.SharePath;
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
public System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo)
@@ -104,13 +121,13 @@ namespace Openstack.Client.Powershell.Providers.Storage
// For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
try
{
{
if (storageContainers.Count() > 0)
{
foreach (StorageContainer storageContainer in storageContainers)
{
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
parameters.Settings = this.Settings;
parameters.Settings = this.Settings;
OpenStackPSDriveInfo kvsDriveInfo = new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL);
//kvsDriveInfo.SharePath = storageContainer.SharePath;
drives.Add(kvsDriveInfo);
@@ -155,9 +172,9 @@ namespace Openstack.Client.Powershell.Providers.Storage
{
WriteDebug("No Storage Containers found, initializing defaults.");
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.ProviderInfo, "/", "Root folder for your Container", null);
return new Collection<PSDriveInfo>
{
{
new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL)
};
}
@@ -169,6 +186,8 @@ namespace Openstack.Client.Powershell.Providers.Storage
//==================================================================================================
protected override System.Collections.ObjectModel.Collection<PSDriveInfo> InitializeDefaultDrives()
{
Thread.Sleep(10000);
this.InitializeSession();
if (this.Context.ServiceCatalog.Exists(this.ProviderInfo.Name))
@@ -257,9 +276,9 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// <param name="path"></param>
/// <returns></returns>
//==================================================================================================
private IEnumerable<StorageItemModelView> GetStorageObjects(string path)
private IEnumerable<StorageItemViewModel> GetStorageObjects(string path)
{
List<StorageItemModelView> modelViewItems = new List<StorageItemModelView>();
List<StorageItemViewModel> modelViewItems = new List<StorageItemViewModel>();
Task<StorageFolder> listStorageObjectTask;
string folderName = null;
@@ -267,7 +286,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
path = path + @"\";
StoragePath storagePath = this.CreateStoragePath(path);
IStorageServiceClient client = this.Client.CreateServiceClient<IStorageServiceClient>();
var client = this.Client.CreateServiceClient<IStorageServiceClient>();
if (path == "\\") {
folderName = "/";
@@ -280,7 +299,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
listStorageObjectTask.Wait();
foreach (StorageItem item in listStorageObjectTask.Result.Objects.Union<StorageItem>(listStorageObjectTask.Result.Folders))
{
StorageItemModelView modelView = new StorageItemModelView(item);
StorageItemViewModel modelView = new StorageItemViewModel(item);
modelViewItems.Add(modelView);
}
return modelViewItems;
@@ -290,7 +309,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
///
/// </summary>
//==================================================================================================
private void WriteData(IEnumerable<StorageItemModelView> storageItemViewModel, string path, WildcardPattern pattern = null)
private void WriteData(IEnumerable<StorageItemViewModel> storageItemViewModel, string path, WildcardPattern pattern = null)
{
FolderStatistics statistics = new FolderStatistics();
bool doesExist = false;
@@ -305,7 +324,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
//List<StorageItem> folders = storageObjects.Where(so => so.Name.EndsWith(@"\")).ToList<StorageItem>();
List<StorageItemModelView> folders = storageItemViewModel.Where(so => so.Type == "Folder").ToList<StorageItemModelView>();
List<StorageItemViewModel> folders = storageItemViewModel.Where(so => so.Type == "Folder").ToList<StorageItemViewModel>();
// List<StorageObject> folders = storageObjects.Where(so => so.StorageObjectType == StorageObjectType.Folder).ToList<StorageObject>();
@@ -334,7 +353,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// Writes out the files represented as StorageObjects for the supplied path.
/// </summary>
//==================================================================================================
private FolderStatistics WriteFiles(IEnumerable<StorageItemModelView> storageObjects, string path)
private FolderStatistics WriteFiles(IEnumerable<StorageItemViewModel> storageObjects, string path)
{
FolderStatistics statistics = new FolderStatistics();
@@ -358,13 +377,13 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// Writes out a list of supplied Folders and returns stats on them as well.
/// </summary>
//==================================================================================================
private void WriteFolders(List<StorageItemModelView> folders, ref FolderStatistics statistics)
private void WriteFolders(List<StorageItemViewModel> folders, ref FolderStatistics statistics)
{
if (folders != null)
{
// Write out each folder we find in the current directory..
foreach (StorageItemModelView obj in folders)
foreach (StorageItemViewModel obj in folders)
{
string fixedString = obj.Name.TrimEnd('/');
string[] folderNames = fixedString.Split('/');
@@ -542,7 +561,7 @@ namespace Openstack.Client.Powershell.Providers.Storage
if (this.CheckDefaultDrive(true)) return;
this.WriteHeader();
this.WriteData(this.GetStorageObjects(path).ToList<StorageItemModelView>(), path);
this.WriteData(this.GetStorageObjects(path).ToList<StorageItemViewModel>(), path);
}
//==================================================================================================
/// <summary>
@@ -663,11 +682,11 @@ namespace Openstack.Client.Powershell.Providers.Storage
if (this.CheckDefaultDrive(true)) return;
this.WriteHeader();
IEnumerable<StorageItemModelView> storageObjects = this.GetStorageObjects(path);
IEnumerable<StorageItemViewModel> storageObjects = this.GetStorageObjects(path);
this.WriteData(storageObjects.ToList<StorageItemModelView>(), path);
this.WriteData(storageObjects.ToList<StorageItemViewModel>(), path);
}
//==================================================================================================
/// <summary>
@@ -697,22 +716,6 @@ namespace Openstack.Client.Powershell.Providers.Storage
/// <summary>
///
/// </summary>
//==================================================================================================
private string StorageServiceURL
{
get
{
return this.StorageClient.GetPublicEndpoint().AbsoluteUri;
//if (this.Drive.SharePath == null)
// return this.Context.ServiceCatalog.GetService("object-store").Url;
//else
// return this.Drive.SharePath;
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
private OpenStackPSDriveInfo Drive
{

View File

@@ -3,9 +3,9 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Openstack.Storage;
using OpenStack.Storage;
namespace Openstack.Client.Powershell.Providers.ObjectStorage
namespace OpenStack.Client.Powershell.Providers.ObjectStorage
{
public class StorageItemViewModel
{

View File

@@ -0,0 +1,225 @@
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Management.Automation;
//using System.Text;
//using System.Threading.Tasks;
//using OpenStack.Client.Powershell.Providers.Storage;
//using OpenStack.Identity;
//using OpenStack.Storage;
//namespace OpenStack.Client.Powershell.Utility
//{
// public class AccountCapabilities
// {
// private SessionState _session;
// private Context _context;
// #region Properties
// public Context Context
// {
// get { return _context; }
// set { _context = value; }
// }
// public SessionState Session
// {
// get { return _session; }
// set { _session = value; }
// }
// public AccountCapabilities(SessionState session, Context context)
// {
// _session = session;
// _context = context;
// }
// //=======================================================================================================
// /// <summary>
// ///
// /// </summary>
// //=======================================================================================================
// public void WriteServices()
// {
// this.Session.InvokeCommand.InvokeScript("Hey");
// //WriteObject("");
// //Console.ForegroundColor = ConsoleColor.DarkGray;
// //WriteObject("=================================================================");
// //Console.ForegroundColor = ConsoleColor.Yellow;
// //WriteObject("Binding to new Account. New service catalog is as follows.");
// //Console.ForegroundColor = ConsoleColor.DarkGray;
// //WriteObject("=================================================================");
// //Console.ForegroundColor = ConsoleColor.Green;
// //WriteObject(" ");
// //foreach (OpenstackServiceDefinition service in this.Context.ServiceCatalog)
// //{
// // WriteObject(service);
// //}
// //WriteObject("");
// }
// //==================================================================================================
// /// <summary>
// ///
// /// </summary>
// /// <returns></returns>
// //==================================================================================================
// private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo) //, string configFilePath)
// {
// List<StorageContainer> storageContainers = null;
// OSDriveParameters parameters = new OSDriveParameters();
// if (this.Context.Settings != null)
// {
// parameters.Settings = this.Context.Settings;
// }
// else
// {
// parameters.Settings = settings;
// }
// try
// {
// Task<IEnumerable<StorageContainer>> getContainersTask = this.CoreClient.CreateServiceClient<IStorageServiceClient>().ListStorageContainers();
// getContainersTask.Wait();
// storageContainers = getContainersTask.Result.ToList<StorageContainer>();
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex);
// }
// Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
// // For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
// try
// {
// string publicStoreUrl = this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
// if (storageContainers.Count > 0)
// {
// foreach (StorageContainer storageContainer in storageContainers)
// {
// PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
// OpenStackPSDriveInfo kvsDriveInfo = new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl);
// try
// {
// drives.Add(kvsDriveInfo);
// }
// catch (Exception) { }
// }
// }
// else
// {
// PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
// return new Collection<PSDriveInfo>
// {
// new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl)
// };
// }
// }
// catch (Exception ex)
// {
// int g = 7;
// }
// return drives;
// }
// //=======================================================================================================
// /// <summary>
// /// Removes all currently registered drives..
// /// </summary>
// //=======================================================================================================
// private void RemoveDrives()
// {
// // Remove the old Users drives first..
// Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("Object Storage");
// foreach (PSDriveInfo deadDrive in deadDrives)
// {
// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
// }
// }
// //=======================================================================================================
// /// <summary>
// ///
// /// </summary>
// //=======================================================================================================
// public void WriteContainers(string configFilePath)
// {
// List<string> invalidDriveNames = new List<string>();
// OSDriveParameters parameters = new OSDriveParameters();
// // Write out the commands header information first..
// WriteObject("");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("===================================================================");
// Console.ForegroundColor = ConsoleColor.Yellow;
// WriteObject("Object Storage Service available. Remapping to the following drives.");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("===================================================================");
// Console.ForegroundColor = ConsoleColor.Green;
// WriteObject(" ");
// HPOSNavigationProvider provider = new HPOSNavigationProvider();
// Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Context.Settings, this.SessionState.Provider.GetOne("Object Storage"));
// if (drives != null)
// {
// this.RemoveDrives();
// foreach (PSDriveInfo drive in drives)
// {
// if (drive.Name != string.Empty)
// {
// WriteObject("Storage Container : [" + drive.Name + "] now available.");
// }
// try
// {
// this.SessionState.Drive.New(drive, "local");
// }
// catch (PSArgumentException ex)
// {
// if (drive.Name != string.Empty)
// invalidDriveNames.Add(drive.Name);
// }
// catch (Exception) { }
// }
// WriteObject("");
// }
// else
// {
// // No storageContainers exist for the new credentials so make some up...
// //PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
// //this.SessionState.Drive.New(new OSDriveInfo(driveInfo, parameters, this.Context), "local");
// }
// if (invalidDriveNames.Count > 0)
// {
// WriteObject("");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Red;
// WriteObject("Error : A subset of your Containers could not be bound to this");
// WriteObject("session due to naming conflicts with the naming standards required");
// WriteObject("for Powershell drives. These containers are listed below.");
// Console.ForegroundColor = ConsoleColor.DarkGray;
// WriteObject("=================================================================");
// Console.ForegroundColor = ConsoleColor.Green;
// WriteObject(" ");
// foreach (string name in invalidDriveNames)
// {
// WriteObject(name);
// WriteObject(" ");
// }
// WriteObject(" ");
// }
// }
// }
//}
// #endregion

View File

@@ -0,0 +1,306 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.IO;
using System.Xml.XPath;
namespace OpenStack.Client.Powershell.Utility
{
public class ConfigurationManager
{
private bool _isLoaded = false;
private XDocument _document = new XDocument();
public XDocument Document
{
get { return _document; }
set { _document = value; }
}
public bool IsLoaded
{
get { return _isLoaded; }
set { _isLoaded = value; }
}
//====================================================================================
/// <summary>
///
/// </summary>
//====================================================================================
public ConfigurationManager()
{ }
//====================================================================================
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="value"></param>
//=========================================================================================
private XElement CreateAddElement(CredentialElement credentialElement)
{
XElement element = new XElement("add");
element.SetAttributeValue("key", credentialElement.Key);
element.SetAttributeValue("value", credentialElement.Value);
element.SetAttributeValue("displayName", credentialElement.DisplayName);
element.SetAttributeValue("isMandatory", credentialElement.IsMandatory);
return element;
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="provider"></param>
/// <returns></returns>
//==================================================================================================
private ServiceProvider ResolveServiceProviderCredentials(ServiceProvider provider)
{
if (!this.IsLoaded) throw new InvalidOperationException("Instance must be Loaded first..");
CredentialElement configFilePathCredentialElement = provider.CredentialElements.Where(ce => ce.Key == "ConfigFilePath").SingleOrDefault();
if (configFilePathCredentialElement != null)
{
// Need to get credentials from the linked in Config File..
ConfigurationManager manager = new ConfigurationManager();
manager.Load(configFilePathCredentialElement.Value);
provider.CredentialElements.Remove(provider.CredentialElements.Where(ce => ce.Key == "ConfigFilePath").Single());
return manager.GetServiceProvider(provider.Name);
}
else
{
return provider;
}
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <param name="moduleName"></param>
//=========================================================================================
public void SetDefaultServiceProvider(string providerName)
{
if (!this.IsLoaded) throw new InvalidOperationException("Instance must be Loaded first..");
XElement defaultProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("isDefault").Value == "true").Single();
defaultProvider.Attribute("isDefault").SetValue("false");
XElement serviceProviderNode = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == providerName).Single();
serviceProviderNode.Attribute("isDefault").SetValue("true");
this.Document.Save(this.GetFullConfigPath());
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//=========================================================================================
public ServiceProvider GetDefaultServiceProvider()
{
if (!this.IsLoaded) throw new InvalidOperationException("Instance must be Loaded first..");
XElement serviceProviderNode = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("isDefault").Value == "true").Single();
return this.GetServiceProvider(serviceProviderNode.Attribute("name").Value);
}
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
public void Load()
{
_document = new XDocument(); ;
_document = XDocument.Load(this.GetFullConfigPath());
_isLoaded = true;
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <param name="configFilePath"></param>
//=========================================================================================
public void Load(string configFilePath)
{
_document = new XDocument();
_document = XDocument.Load(configFilePath);
_isLoaded = true;
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//=========================================================================================
private string GetFullConfigPath()
{
if (File.Exists("OpenStack.config"))
{
return this.GetType().Assembly.Location;
}
else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config"))
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
}
else
{
throw new InvalidOperationException("Unable to locate OpenStack.config file.");
}
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
//=========================================================================================
public ServiceProvider GetServiceProvider(string name)
{
if (!this.IsLoaded) throw new InvalidOperationException("Instance must be Loaded first..");
XElement serviceProviderNode = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == name).Single();
var provider = new ServiceProvider();
provider.Name = serviceProviderNode.Attribute("name").Value;
provider.IsDefault = Convert.ToBoolean(serviceProviderNode.Attribute("isDefault").Value);
// The ServiceProvider in the Primary config file is pointing to a Vender specific config so reolve that first..
foreach (XElement xElement in serviceProviderNode.Elements())
{
CredentialElement element = new CredentialElement();
element.Key = xElement.Attribute("key").Value;
element.Value = xElement.Attribute("value").Value;
if (xElement.Attribute("key").Value == "AuthenticationServiceURI")
provider.AuthenticationServiceURI = xElement.Attribute("value").Value;
if (xElement.Attribute("key").Value == "isDefault")
provider.IsDefault = Convert.ToBoolean(xElement.Attribute("value").Value);
try
{
element.IsMandatory = Convert.ToBoolean(xElement.Attribute("isMandatory").Value);
element.DisplayName = xElement.Attribute("displayName").Value;
//element.HelpText = xElement.Attribute("helpText").Value;
}
catch (Exception) { }
if (element.Key == "ConfigFilePath")
{
provider.CredentialElements.Add(element);
ServiceProvider resolvedProvider = this.ResolveServiceProviderCredentials(provider);
resolvedProvider.ConfigFilePath = element.Value;
return resolvedProvider;
}
else
provider.CredentialElements.Add(element);
}
return provider;
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//=========================================================================================
public IEnumerable<ServiceProvider> GetServiceProviders()
{
List<ServiceProvider> serviceProviders = new List<ServiceProvider>();
foreach (XElement element in this.Document.Descendants("ServiceProvider"))
{
ServiceProvider newProvider = this.GetServiceProvider(element.Attribute("name").Value);
newProvider.IsDefault = Convert.ToBoolean(element.Attribute("isDefault").Value);
serviceProviders.Add(newProvider);
}
return serviceProviders;
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <param name="providerName"></param>
//=========================================================================================
public void RemoveInitialServiceProvider(ref XDocument _document)
{
try
{
XElement oldServiceProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == String.Empty).Single();
if (oldServiceProvider != null)
oldServiceProvider.Remove();
}
catch (InvalidOperationException ex) { }
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <param name="doc"></param>
/// <param name="isDefault"></param>
//=========================================================================================
private void RemoveDefaultServiceProvider(ref XDocument doc)
{
try
{
XElement serviceProviderNode = doc.Descendants("ServiceProvider").Where(sp => sp.Attribute("isDefault").Value == "True").Single();
serviceProviderNode.Attribute("isDefault").SetValue("false");
}
catch (Exception) { }
}
//=========================================================================================
/// <summary>
/// Flush and fill style..
/// </summary>
//=========================================================================================
public void WriteServiceProvider(ServiceProvider serviceProvider, bool removeInitialServiceProvider = false)
{
IEnumerable<XElement> serviceProviderNodes = this.Document.Descendants("ServiceProvider");
XElement spElement = new XElement("ServiceProvider",
new XAttribute("name", serviceProvider.Name),
new XAttribute("isDefault", serviceProvider.IsDefault));
// Get rid of the old ServiceProvider first ...
try
{
XElement oldServiceProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == serviceProvider.Name).Single();
if (oldServiceProvider != null)
oldServiceProvider.Remove();
}
catch (InvalidOperationException ex) { }
// If this new Provider is set = default, remove the default flag from the previous one..
if (serviceProvider.IsDefault) {
RemoveDefaultServiceProvider(ref _document);
}
// Create CredentialElement instances for all Key\Value (Add elements)..
foreach (CredentialElement element in serviceProvider.CredentialElements) {
spElement.Add(this.CreateAddElement(element));
}
if (removeInitialServiceProvider == true)
this.RemoveInitialServiceProvider(ref _document);
this.Document.XPathSelectElement("configuration/appSettings/IdentityServices").Add(spElement);
this.Document.Save(this.GetFullConfigPath());
}
}
}

View File

@@ -13,24 +13,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using Openstack.Common;
using Openstack;
using OpenStack.Common;
using OpenStack;
using System.Security;
using System.Reflection;
using Openstack.Identity;
using OpenStack.Identity;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public class Context
{
private IOpenstackServiceCatalog _serviceCatalog;
private IOpenStackServiceCatalog _serviceCatalog;
private Settings _settings;
//private Token _accessToken;
private string _productName = "OpenstackDotNetAPI";
private string _version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
private string _forecolor = "Green";
#region Ctors
//==================================================================================================
/// <summary>
@@ -98,7 +97,7 @@ namespace Openstack.Client.Powershell.Utility
///
/// </summary>
//==================================================================================================
public IOpenstackServiceCatalog ServiceCatalog
public IOpenStackServiceCatalog ServiceCatalog
{
get { return _serviceCatalog; }
set { _serviceCatalog = value; }

View File

@@ -0,0 +1,73 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OpenStack.Client.Powershell.Utility
{
public class CredentialElement
{
private string _key;
private string _value;
private string _displayName;
private string _helpText;
private bool _isMandatory = true;
public CredentialElement(string key)
{
_key = key;
}
public CredentialElement()
{
}
public bool IsMandatory
{
get { return _isMandatory; }
set { _isMandatory = value; }
}
public string HelpText
{
get { return _helpText; }
set { _helpText = value; }
}
public string DisplayName
{
get { return _displayName; }
set { _displayName = value; }
}
public string Value
{
get { return _value; }
set { _value = value; }
}
public string Key
{
get { return _key; }
set { _key = value; }
}
}
}

View File

@@ -17,21 +17,21 @@ using System;
using System.Xml.Linq;
using System.Xml.XPath;
using System.Security;
using Openstack.Identity;
using Openstack.Client.Powershell.Utility;
using OpenStack.Identity;
using OpenStack.Client.Powershell.Utility;
using System.Linq;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public class ServiceProviderInfo
{
public string Name;
public IOpenstackCredential Credential;
public string ServbiceProviderUrl;
public IOpenStackCredential Credential;
public string ServiceProviderUrl;
}
public class CredentialManager
@@ -58,33 +58,6 @@ namespace Openstack.Client.Powershell.Utility
if (accountIdNode == String.Empty || accessKeyNode == String.Empty || identityServiceURI == String.Empty || tenantId == String.Empty)
return true;
else return false;
//// First make sure the User info exist..
//System.Collections.Generic.IEnumerable<XAttribute> attributes = accountIdNode.Attributes();
//foreach (XAttribute attribute in attributes)
//{
// if (attribute.Name == "value" && attribute.Value == string.Empty)
// {
// return true;
// }
//}
//// Now check to ensure the auth key exist
//System.Collections.Generic.IEnumerable<XAttribute> attributes2 = accessKeyNode.Attributes();
//foreach (XAttribute attribute in attributes2)
//{
// if (attribute.Name == "value" && attribute.Value == string.Empty)
// {
// return true;
// }
//}
//return false;
}
//==================================================================================================
/// <summary>
@@ -204,6 +177,38 @@ namespace Openstack.Client.Powershell.Utility
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private ServiceProviderInfo PromptForCredentials(XElement element)
{
ServiceProviderInfo info = new ServiceProviderInfo();
Console.WriteLine("User Name : ");
string username = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Password : ");
string password = CredentialManager.ReadPassword();
Console.WriteLine("");
Console.WriteLine("Tenant Name : ");
string tenantName = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Service Provider Identity Service Url : ");
string identityServiceUrl = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("Finally supply a name for this Profile.");
string name = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("");
info.Credential = new OpenStackCredential(new Uri(identityServiceUrl), username, password, tenantName);
info.ServiceProviderUrl = identityServiceUrl;
info.Name = name;
return info;
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private ServiceProviderInfo PromptForCredentials()
{
@@ -225,8 +230,8 @@ namespace Openstack.Client.Powershell.Utility
string name = Console.ReadLine();
Console.WriteLine("");
Console.WriteLine("");
info.Credential = new OpenstackCredential(new Uri(identityServiceUrl), username, this.ConvertToSecureString(password), tenantName);
info.ServbiceProviderUrl = identityServiceUrl;
info.Credential = new OpenStackCredential(new Uri(identityServiceUrl), username, password, tenantName);
info.ServiceProviderUrl = identityServiceUrl;
info.Name = name;
return info;
@@ -244,7 +249,7 @@ namespace Openstack.Client.Powershell.Utility
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("We've noticed that you haven't supplied any credentials yet. To continue we need to get your Username, ");
Console.WriteLine("Password, and the Tenant Id provided to you during the sign up process. If you haven't signed up");
Console.WriteLine("for any services yet, just go to https://console.Openstack.com for details on how to get started today!");
Console.WriteLine("for any services yet, just go to https://console.OpenStack.com for details on how to get started today!");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("=======================================================================================================");
Console.ForegroundColor = ConsoleColor.Green;
@@ -262,7 +267,7 @@ namespace Openstack.Client.Powershell.Utility
Console.WriteLine("=======================================================================================================");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("The credentials that you have supplied could not be verified. Please try again. If you continue to have ");
Console.WriteLine("problems please feel free to contact our support staff at https://console.Openstack.com");
Console.WriteLine("problems please feel free to contact our support staff at https://console.OpenStack.com");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("=======================================================================================================");
Console.ForegroundColor = ConsoleColor.Green;
@@ -273,13 +278,15 @@ namespace Openstack.Client.Powershell.Utility
///
/// </summary>
//==================================================================================================
public IOpenstackCredential GetCredentials(bool badCredentialsSupplied = false)
public IOpenStackCredential GetCredentials(bool badCredentialsSupplied = false)
{
ServiceProviderInfo info;
IOpenstackCredential credential;
IOpenStackCredential credential;
string configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
string configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
XDocument doc = XDocument.Load(configFilePath);
XElement serviceProviderNode = doc.Descendants("ServiceProvider").Where(a => a.Attribute("isDefault").Value == "True").FirstOrDefault();
XElement username = serviceProviderNode.Elements().Where(u => u.Name == "add" && u.Attribute("key").Value == "Username").Single();
XElement password = serviceProviderNode.Elements().Where(u => u.Name == "add" && u.Attribute("key").Value == "Password").Single();
@@ -301,7 +308,7 @@ namespace Openstack.Client.Powershell.Utility
{
// The test client would be an example of where we need to supress the prompt for credentials. Here we just raise an exception instead..
throw new SecurityException("You must supply a valid Access Key and Secret Key in the CLI.config file to start unit testing.");
throw new SecurityException("You must supply a valid Access Key and Secret Key in the OpenStack.config file to start unit testing.");
}
while (!this.VerifyCredentials(username.Value, password.Value))
@@ -313,7 +320,7 @@ namespace Openstack.Client.Powershell.Utility
}
username.SetAttributeValue("value", credential.UserName);
password.SetAttributeValue("value", this.convertToUNSecureString(credential.Password));
password.SetAttributeValue("value", credential.Password);
tenantId.SetAttributeValue("value", credential.TenantId);
identityServiceUrl.SetAttributeValue("value", credential.AuthenticationEndpoint.AbsoluteUri);
name.SetValue(info.Name);
@@ -326,10 +333,11 @@ namespace Openstack.Client.Powershell.Utility
// We didn't need to prompt for credentials from the user so just send back what we found in the config file..
SecureString securePassword = new SecureString();
password.Attribute("value").Value.ToCharArray().ToList().ForEach(securePassword.AppendChar);
string h = this.convertToUNSecureString(securePassword);
IOpenstackCredential newCredential = new OpenstackCredential(new Uri(identityServiceUrl.Attribute("value").Value), username.Attribute("value").Value, securePassword, tenantId.Attribute("value").Value);
//SecureString securePassword = new SecureString();
//password.Attribute("value").Value.ToCharArray().ToList().ForEach(securePassword.AppendChar);
IOpenStackCredential newCredential = new OpenStackCredential(new Uri(identityServiceUrl.Attribute("value").Value), username.Attribute("value").Value, password.Attribute("value").Value, tenantId.Attribute("value").Value);
return newCredential;
}

View File

@@ -15,7 +15,7 @@ limitations under the License.
============================================================================ */
using System.Xml.Serialization;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public enum StorageOperationType

View File

@@ -0,0 +1,163 @@
//* ============================================================================
//Copyright 2014 Hewlett Packard
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//============================================================================ */
using System;
using System.Management.Automation;
using System.Reflection;
using System.Security.Policy;
using OpenStack.Client.Powershell.Utility;
using System.Linq;
using OpenStack.Identity;
using System.Threading;
namespace OpenStack.Client.Powershell.Utility
{
public class ExtensionManager
{
private SessionState _session;
private Context _context;
#region Properties
public Context Context
{
get { return _context; }
set { _context = value; }
}
public SessionState Session
{
get { return _session; }
set { _session = value; }
}
#endregion
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="session"></param>
/// <param name="context"></param>
//==================================================================================================
public ExtensionManager(SessionState session, Context context)
{
_session = session;
_context = context;
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="provider"></param>
/// <returns></returns>
//==================================================================================================
private Settings GetSettings(ServiceProvider provider)
{
if (provider.ConfigFilePath == null) {
Settings.Default.Reset();
return Settings.Default;
}
else {
return Settings.LoadConfig(provider.ConfigFilePath);
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="credential"></param>
/// <param name="context"></param>
/// <param name="client"></param>
//==================================================================================================
private void SetSessionState(IOpenStackCredential credential, IOpenStackClient client, ServiceProvider provider)
{
// Setup the environment based on what came back from Auth..
Context context = new Context();
context.ServiceCatalog = credential.ServiceCatalog;
context.Settings = this.GetSettings(provider);
context.ProductName = "OpenStack-WinCLI";
context.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
this.Session.PSVariable.Set(new PSVariable("Context", context));
this.Session.PSVariable.Set(new PSVariable("CoreClient", client));
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
public void LoadCore(ServiceProvider provider)
{
OpenstackCoreRegistrationManager manager = new OpenstackCoreRegistrationManager();
RegistrationResponse response = manager.Register(provider);
// Connect to the Service Provider..
var client = OpenStackClientFactory.CreateClient<OpenStackClient>(response.Credentials, CancellationToken.None, null);
var connectTask = client.Connect();
connectTask.Wait();
this.SetSessionState(response.Credentials, client, provider);
ConfigurationManager configManager = new ConfigurationManager();
configManager.WriteServiceProvider(response.Provider, true);
}
//==================================================================================================
/// <summary>
///
/// </summary>
//==================================================================================================
public void LoadExtension(ServiceProvider targetProvider)
{
string moduleName = targetProvider.Name;
AppDomain currentDomain = AppDomain.CurrentDomain;
Evidence asEvidence = currentDomain.Evidence;
ConfigurationManager configManager = new ConfigurationManager();
configManager.Load();
// Load the specified module. We take a before and after snapshot of assemblies loaded in the current AppDomain.
// The targetList represents only what's been added...
Assembly[] originalList = currentDomain.GetAssemblies();
this.Session.InvokeCommand.InvokeScript("Import-Module " + moduleName + " -DisableNameChecking");
Assembly[] modifiedList = currentDomain.GetAssemblies();
var targetList = modifiedList.Except(originalList);
foreach (Assembly assembly in targetList)
{
// Grab a Type instance for the first occurrence of a subtyped RegistrationManager. Create a new instance from that System.Type so that we can
// let them supply the IOpenStackCredential instance...
Type registrationManagerType = assembly.GetTypes().Where(b => b.BaseType.UnderlyingSystemType.FullName == "OpenStack.Client.Powershell.Utility.RegistrationManager").First();
RegistrationManager manager = (RegistrationManager)Activator.CreateInstance(registrationManagerType, null);
RegistrationResponse response = manager.Register(configManager.GetServiceProvider(moduleName));
IOpenStackCredential credential = response.Credentials;
// Create our Extension Client and stash it....
var client = OpenStackClientFactory.CreateClient<OpenStackClient>(credential);
var connectTask = client.Connect();
connectTask.Wait();
// Save the credentials ..
configManager.WriteServiceProvider(response.Provider);
// Store Context and Client so that all PS-Providers and Cmdlets have access to it..
this.SetSessionState(credential, client, targetProvider);
}
}
}
}

View File

@@ -0,0 +1,51 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using OpenStack.Client.Powershell.Utility;
using OpenStack.Identity;
namespace OpenStack.Client.Powershell.Utility
{
public class OpenstackCoreRegistrationManager : RegistrationManager
{
public override RegistrationResponse Register(ServiceProvider serviceProvider)
{
this.ValidateCredentialElements(ref serviceProvider);
string authenticationEndpoint = serviceProvider.CredentialElements.Where(ce => ce.Key == "AuthenticationServiceURI").Single().Value;
string userName = serviceProvider.CredentialElements.Where(ce => ce.Key == "Username").Single().Value;
string password = serviceProvider.CredentialElements.Where(ce => ce.Key == "Password").Single().Value;
string tenantId = serviceProvider.CredentialElements.Where(ce => ce.Key == "DefaultTenantId").Single().Value;
IOpenStackCredential credential = new OpenStackCredential(new Uri (authenticationEndpoint), userName, password, tenantId);
return new RegistrationResponse(credential, serviceProvider);
}
private SecureString GetSecureString(string password)
{
SecureString securePassword = new SecureString();
password.ToCharArray().ToList().ForEach(securePassword.AppendChar);
return SecureStringHelper.ConvertToSecureString(password);
}
}
}

View File

@@ -0,0 +1,95 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenStack.Identity;
namespace OpenStack.Client.Powershell.Utility
{
public abstract class RegistrationManager
{
// public abstract ServiceProviderInfo CreateCredential(Dictionary<string, string> configValues);
public abstract RegistrationResponse Register(ServiceProvider serviceProvider);
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="elements"></param>
//==================================================================================================
protected void ValidateCredentialElements (ref ServiceProvider serviceProvider)
{
// If there are any CredentialElements with empty values, get them now from the User..
List<CredentialElement> elements = serviceProvider.CredentialElements;
if (elements.Where(e => e.Value == String.Empty).Any())
{
this.WriteGetCredentialsHeader();
for (int i = 0; i < elements.Count; i++)
{
if (elements[i].IsMandatory && elements[i].Value == String.Empty) {
elements[i].Value = this.PromptForCredentialElement(elements[i]);
}
}
}
// Also check that the ServiceProvider name was supplied..
if (serviceProvider.Name == String.Empty)
{
Console.WriteLine("");
Console.WriteLine("Service Provider Name :");
Console.WriteLine("");
serviceProvider.Name = Console.ReadLine();
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//==================================================================================================
private string PromptForCredentialElement(CredentialElement element)
{
Console.WriteLine("");
Console.WriteLine(element.DisplayName + " :");
Console.WriteLine("");
return Console.ReadLine();
}
//==================================================================================================
/// <summary>
/// Writes out header information to be used during the process that prompts for new credentials.
/// </summary>
//==================================================================================================
private void WriteGetCredentialsHeader()
{
Console.WriteLine("");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("=======================================================================================================");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("We've noticed that you haven't supplied any credentials yet. To continue we need to get your Username, ");
Console.WriteLine("Password, and the Tenant Id provided to you during the sign up process. If you haven't signed up");
Console.WriteLine("for any services yet, just go to https://console.OpenStack.com for details on how to get started today!");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("=======================================================================================================");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine(" ");
}
}
}

View File

@@ -0,0 +1,50 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenStack.Identity;
namespace OpenStack.Client.Powershell.Utility
{
public class RegistrationResponse
{
private IOpenStackCredential _credentials;
private ServiceProvider _provider;
public ServiceProvider Provider
{
get { return _provider; }
set { _provider = value; }
}
public RegistrationResponse()
{ }
public RegistrationResponse(IOpenStackCredential credential, ServiceProvider provider)
{
_credentials = credential;
_provider = provider;
}
public IOpenStackCredential Credentials
{
get { return _credentials; }
set { _credentials = value; }
}
}
}

View File

@@ -0,0 +1,68 @@
/* ============================================================================
Copyright 2014 Hewlett Packard
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
============================================================================ */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
namespace OpenStack.Client.Powershell.Utility
{
public static class SecureStringHelper
{
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="secstrPassword"></param>
/// <returns></returns>
//==================================================================================================
public static string convertToUNSecureString(SecureString secstrPassword)
{
IntPtr unmanagedString = IntPtr.Zero;
try
{
unmanagedString = Marshal.SecureStringToGlobalAllocUnicode(secstrPassword);
return Marshal.PtrToStringUni(unmanagedString);
}
finally
{
Marshal.ZeroFreeGlobalAllocUnicode(unmanagedString);
}
}
//==================================================================================================
/// <summary>
///
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
//==================================================================================================
public static SecureString ConvertToSecureString(string value)
{
// Instantiate the secure string.
SecureString securePwd = new SecureString();
var secureStr = new SecureString();
if (value.Length > 0)
{
foreach (var c in value.ToCharArray()) secureStr.AppendChar(c);
}
else return null;
return secureStr;
}
}
}

View File

@@ -19,44 +19,63 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public class ServiceProvider
public class ServiceProvider
{
private string _name;
private bool _isDefault = false;
private string _authenticationServiceURI;
private string _defaultTenantId;
private string _username;
private bool _isDirty = false;
private List<CredentialElement> _credentialElements = new List<CredentialElement>();
private string _configFilePath;
public string Username
public string ConfigFilePath
{
get { return _username; }
set { _username = value; }
get { return _configFilePath; }
set { _configFilePath = value; }
}
public List<CredentialElement> CredentialElements
{
get { return _credentialElements; }
set { _credentialElements = value; }
}
public bool IsDirty
{
get { return _isDirty; }
set { _isDirty = value; }
}
public string DefaultTenantId
{
get { return _defaultTenantId; }
set { _defaultTenantId = value; }
set
{
_defaultTenantId = value;
_isDirty = true;
}
}
public string AuthenticationServiceURI
{
get { return _authenticationServiceURI; }
set { _authenticationServiceURI = value; }
set { _authenticationServiceURI = value; _isDirty = true; }
}
public bool IsDefault
{
get { return _isDefault; }
set { _isDefault = value; }
set { _isDefault = value; _isDirty = true; }
}
public string Name
{
get { return _name; }
set { _name = value; }
set { _name = value; _isDirty = true; }
}
}
}

View File

@@ -21,12 +21,29 @@ using System.Xml.Linq;
using System.Collections;
using System.Configuration;
using System.IO;
using System.Xml.XPath;
using System;
using System.Management.Automation;
using System.Reflection;
using System.Security.Policy;
using OpenStack.Client.Powershell.Utility;
using System.Linq;
using OpenStack.Identity;
using System.Threading;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public sealed partial class Settings : Hashtable
{
private static Settings defaultInstance = new Settings();
private static string _configFilePath;
private XDocument _document;
public string ConfigFilePath
{
get { return _configFilePath; }
set { _configFilePath = value; }
}
#region Ctors
//==================================================================================================
@@ -656,20 +673,18 @@ namespace Openstack.Client.Powershell.Utility
//==================================================================================================
public void Reset()
{
System.Diagnostics.Debug.WriteLine("here");
if (File.Exists("CLI.config"))
if (File.Exists("OpenStack.config"))
{
this.Load("CLI.config");
this.Load("OpenStack.config");
}
else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config"))
else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config"))
{
string configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
string configFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
this.Load(configFilePath);
}
else
{
throw new InvalidOperationException("Unable to locate CLI.config file.");
throw new InvalidOperationException("Unable to locate OpenStack.config file.");
}
}
//==================================================================================================
@@ -696,6 +711,7 @@ namespace Openstack.Client.Powershell.Utility
{
Settings settings = new Settings(true);
XDocument document = XDocument.Load(configFilePath);
_configFilePath = configFilePath;
foreach (XElement element in document.Descendants("add"))
{
@@ -713,7 +729,7 @@ namespace Openstack.Client.Powershell.Utility
}
//==================================================================================================
/// <summary>
/// Fully Qualified path to a config file
/// Fully Qualified path to a config file
/// </summary>
/// <param name="settings"></param>
//==================================================================================================
@@ -722,12 +738,17 @@ namespace Openstack.Client.Powershell.Utility
try
{
XDocument document = XDocument.Load(configFilePath);
_configFilePath = configFilePath;
this.Clear();
foreach (XElement element in document.Descendants("add"))
{
string key = element.Attribute(XName.Get("key")).Value;
string value = element.Attribute(XName.Get("value")).Value;
this.Add(key, value);
try
{
this.Add(key, value);
}
catch (Exception) { }
}
}
catch (Exception ex)
@@ -736,6 +757,31 @@ namespace Openstack.Client.Powershell.Utility
throw ex;
}
}
//=========================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//=========================================================================================
private string GetConfigPath()
{
//if (_configFilePath != null)
// return _configFilePath;
if (File.Exists("OpenStack.config"))
{
return this.GetType().Assembly.Location;
}
else if (File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config"))
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
}
else
{
throw new InvalidOperationException("Unable to locate OpenStack.config file.");
}
}
#endregion
}
}

View File

@@ -18,14 +18,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.IO;
using Openstack;
using Openstack.Client.Powershell.Utility;
using OpenStack;
using OpenStack.Client.Powershell.Utility;
using System.Collections.ObjectModel;
using Openstack.Common;
using OpenStack.Common;
using System.Diagnostics.Contracts;
using System.Web;
namespace Openstack.Client.Powershell.Utility
namespace OpenStack.Client.Powershell.Utility
{
public class StoragePath
{

View File

@@ -2,14 +2,14 @@
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Openstack.Client.Powershell.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
<section name="OpenStack.Client.Powershell.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<userSettings>
<Openstack.Client.Powershell.Properties.Settings>
<OpenStack.Client.Powershell.Properties.Settings>
<setting name="FileQueueAppPath2" serializeAs="String">
<value>C:\Projects\OS\Openstack.Client.Powershell\Openstack.Client.AsyncQueue\Openstack.Client.AsyncQueue\bin\Debug\Openstack.Client.AsyncQueue.exe</value>
<value>C:\Projects\OS\OpenStack.Client.Powershell\OpenStack.Client.AsyncQueue\OpenStack.Client.AsyncQueue\bin\Debug\OpenStack.Client.AsyncQueue.exe</value>
</setting>
</Openstack.Client.Powershell.Properties.Settings>
</OpenStack.Client.Powershell.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View File

@@ -31,11 +31,17 @@
<SharedContainers></SharedContainers>
</StorageManagement>
<IdentityServices>
<ServiceProvider name="" isDefault="True">
<add key="AuthenticationServiceURI" value="" />
<add key="Username" value="" />
<add key="Password" value="" />
<add key="DefaultTenantId" value="" />
<ServiceProvider name="HP" isDefault="True">
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens" />
<add key="Username" value="Travis.Plummer@hp.com" />
<add key="Password" value="NoRemorseGlock27" />
<add key="DefaultTenantId" value="Travis.Plummer@hp.com" />
</ServiceProvider>
<ServiceProvider name="Rackspace" isDefault="False">
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens" />
<add key="Username" value="Travis.Plummer@hp.com" />
<add key="Password" value="NoRemorseGlock27" />
<add key="DefaultTenantId" value="Travis.Plummer@hp.com" />
</ServiceProvider>
</IdentityServices>
<ComputeServices>

View File

@@ -8,7 +8,7 @@ ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FormatsToProcess="OpenstackShell.format.ps1xml"
FileList='CLI.config'
FileList='Openstack.config'
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
}

View File

@@ -889,7 +889,7 @@
<View>
<Name>process4</Name>
<ViewSelectedBy>
<TypeName>Openstack.Client.Powershell.Providers.ObjectStorage.StorageItemModelView</TypeName>
<TypeName>Openstack.Client.Powershell.Providers.ObjectStorage.StorageItemViewModel</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>

View File

@@ -1,92 +0,0 @@
====================================================================================================================
/// <summary>
///
/// </summary>
/// <param name="storageContainer"></param>
/// <param name="path"></param>
/// <returns></returns>
//======================================================================================================================
public StorageObject GetStorageObject(string path)
{
try
{
path = path.Replace(@"\", "/");
RequestHeaders headers = StorageRequestSigner.CreateSignedHeaders(HttpMethod.GET, path);
string resourcePath = ["StorageManagementURI"] + "/" + path;
HttpClient client = new HttpClient();
client.DefaultHeaders = headers;
Uri uri = new Uri(resourcePath);
HttpResponseMessage msg = client.Get(uri);
if (msg.StatusCode == System.Net.HttpStatusCode.OK)
{
msg.Content.LoadIntoBufferAsync();
StorageObject storageObject = new StorageObject();
storageObject.Key = path;
storageObject.Load(msg.Content.ReadAsStream());
this.CopyCommonRequestHeaders(ref storageObject, msg.Headers);
return storageObject;
}
else
{
return null;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
return null;
}
//======================================================================================================================
/// <summary>
///
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
//======================================================================================================================
public bool IsValidPath(string storageContainer, string path)
{
HttpClient client = new HttpClient();
Uri uri = new Uri(["StorageManagementURI"] + cDelimiter + storageContainer + cDelimiter + path + cDelimiter + "folder.txt");
string rootCheck = null;
if (path == cDelimiter) {
rootCheck = String.Empty;
}
else {
rootCheck = cFolderMarker;
}
if (this.GetStorageObject(storageContainer + cDelimiter + path + cDelimiter + rootCheck) != null)
{
return true;
}
else
{
return false;
}
}
//======================================================================================================================
/// <summary>
///
/// </summary>
/// <returns></returns>
//======================================================================================================================
public StorageObjects GetStorageObjects (string storageContainer, string path)
{
HttpQueryString queryString = new HttpQueryString();
if (path == "")
{
queryString.Add("prefix", "" );
queryString.Add("delimiter", "/");
}
else
{
path = path.Replace(@"\", "/");
queryString.Add("prefix", path);
queryString.Add("delimiter", "/");
}

File diff suppressed because it is too large Load Diff

View File

@@ -847,7 +847,7 @@
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>
Resets the current session settings to those defined within the default config file (CLI.config)
Resets the current session settings to those defined within the default config file (Openstack.config)
</maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
@@ -898,7 +898,7 @@
</command:details>
<maml:description>
<maml:para>
When you issue this command the URI is also pasted to the Windows clipboard for your convenience. If you want to disable this behavior simply set the CLI.config option entitled PasteGetURIResultsToClipboard to false.
When you issue this command the URI is also pasted to the Windows clipboard for your convenience. If you want to disable this behavior simply set the Openstack.config option entitled PasteGetURIResultsToClipboard to false.
</maml:para>
</maml:description>
<!-- Cmdlet syntax section-->

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Openstack.Client.Powershell.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<userSettings>
<Openstack.Client.Powershell.Properties.Settings>
<setting name="FileQueueAppPath2" serializeAs="String">
<value>C:\Projects\OS\Openstack.Client.Powershell\Openstack.Client.AsyncQueue\Openstack.Client.AsyncQueue\bin\Debug\Openstack.Client.AsyncQueue.exe</value>
</setting>
</Openstack.Client.Powershell.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>

View File

@@ -8,7 +8,7 @@ ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FormatsToProcess="OpenstackShell.format.ps1xml"
FileList='CLI.config'
FileList='Openstack.config'
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
}

View File

@@ -889,7 +889,7 @@
<View>
<Name>process4</Name>
<ViewSelectedBy>
<TypeName>Openstack.Client.Powershell.Providers.ObjectStorage.StorageItemModelView</TypeName>
<TypeName>Openstack.Client.Powershell.Providers.ObjectStorage.StorageItemViewModel</TypeName>
</ViewSelectedBy>
<TableControl>
<TableHeaders>

126
README.md Normal file
View File

@@ -0,0 +1,126 @@
Openstack Powershell CLI - Getting Set up to Contribute
I - Pre-requisits
Before we get started we need to make sure that our Development environment reflects what a machine looks like when we install the CLI. The following steps should get the job done.
A. Set the Required Execution Policy
To use the Openstack CLI Software for Windows PowerShell, you must make sure that your Powershell environment is capable of executing 3rd party modules.
Note: If you are performing a re-installation of the software package, you can skip this step. This step is applicable only for a fresh installation.
Open a PowerShell window as the administrator and issue the command set-executionpolicy -ExecutionPolicy Unrestricted:
-------------------------------------------------------------------------------------------------------------------
PS C:\Projects\Outgoing\OS> set-executionpolicy -ExecutionPolicy Unrestricted
Execution policy change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy
might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to
change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y
PS C:\Projects\Outgoing\OS>
-------------------------------------------------------------------------------------------------------------------
Close the Powershell window and reopen as administrator for the policy changes to take effect.
B. A Quick Setting in Visual Studio
After Cloning the repo and loading the solution within Visual Studio, ensure that the "Enable Nuget Package Restore" option has been turned
on at the Solution level. This will retreive all of the neccessary external dependencies for the Solution to build properly.
C. - Supplying your Credentials
Our next step is to make sure that we supply the proper credentials when logging on to the system. If you ran the CLI after your initial
install, you'll have noticed that you were prompted for this information. The result is stored in the CLI.config file located within the Users Personal Data Folder
under the OS directory. With each Build we must update that file with the version in our solution. This is so that when new config file changes are introduced, you
have the CLI picking them up at runtime from the expected location (instead of residing in just your project directory). Complete these steps to supply this information.
1. Navigate to the Openstack.Client.Powershell project and look into the Deployment folder.
2. Within that folder you will see a file called CLI.config.example
3. Copy the example file into the same folder but remove the .example on the filename.
4. Open up the CLI.config file that you just created.
5. Find the config section entitled "IdentityServices".
6. Within this section supply values for Username, Password, and Default Tenenat Id. All of this can be found within your account information on you providers portal.
Each time that we build, this CLI.config file will be moved to the correct runtime location via Post-Build Scripts outlined in the next section.
D. - Edit Post Build Scripts
Within the Openstack.Client.Powershell projects Post-Build Event you'll notice that we call a PostBuild.bat file. This
batch file will move important run-time files required by the CLI to their proper locations if you decide to edit them.
Without this, all changes to important files (like CLI.config) would go unnoticed because they would sit in our project
folders on disk (rather than the location the CLI expects). To create tis batch file, follow these steps.
1. Navigate to the Openstack.Client.Powershell project and look into the Deployment folder.
2. Within that folder you will see a file called PostBuild.example
3. Open up that file and copy the contents to the clipboard.
4. Within that same folder create a file called PostBuild.bat
5. Paste the script on the clipboard into that file.
6. Notice the Action Required section of the file. Modify the path you see there to reflect your development machine.
7. Save your Project and do a test build (Rebuild All). The Output Window will show any Echo results from the script and show any script errors that may break the build.
E. - Modifying you Developer Profile
When the Powershell runtime starts it looks for a file called Microsoft.PowerShell_profile.ps1. This script gets executed right after
Powershell loads. Here we can set up the look of the environment, issue some default commands (useful for testing!)
and loading Powershell Modules. The Powershell module is where all of our CLI code resides and must get loaded by this script.
The only problem here is that the path to that module is specific to your machine. To address this follow these steps
1. Open up the DevProfile.ps1.example file within the Solutions [Openstack.Client.Powershell]\Deployment folder.
2. Copy the contents of this file into a new text file called DevProfile.ps1
3. Search this document for "ACTION REQUIRED" and follow the instructions given.
II - Debugging
Debugging the CLI is a bit more challenging than with say a normal executable. In this case the entry point or main process is the Powershell runtime itself.
This requires us to load our work into that environment and attach the VS debugger to the Powershell host at runtime. Follow these steps to get the debugger running.
1. Set your breakpoint.
2. Compile the Solution.
3. Load Powershell. With everything in place this should automatically Import the module you just compiled.
3. From within VS select Debug\Attach To Process
4. Attach to the Powershell.exe process.
5. Issue a command in the CLI that triggers your breakpoint.
A. Debugging Provider Code
When Powershell modules get Imported, any providers found in that Module will be executed first. This leaves us with a problem in that
any code that we need to debug in the provider during startup needs to be paused until we have time to actually set a break point properly.
To do this complete the following actions.
1. Set you breakpoint in the providers InitializeDefaultDrives() method. This is the first stage in the Providers Life-Cycle.
2. Open the DevProfile.ps1 file.
3. Comment out the Import-Module statement (Copy it to the clipboard for your convience).
2. Compile the Solution.
3. Load Powershell.
3. From within VS select Debug\Attach To Process
4. Attach to the Powershell.exe process.
5. From the command line paste the Import-Module statement into the CLI. This will trigger the breakpoint that you set in step 1.
B. Getting to the Action - A Quick Tip
Sometimes we're trying to debug something in the CLI and we need to get to a certain location quickly. For example if you are testing the
list view for Servers and your sick of typing this after you restart each time
cd\
cd Servers
ls
cd 1
ls
Just remember that this can be placed in your Devprofile.ps1 file and Powershell will issue those commands for you. This makes debugging a specific
section of the CLI much easier..
III. Testing
Object Storage Integration Test Notes
These unit test require a particular directory structure to be present on your machine to complete the test cases where we copy files and or folders to the server.
Make sure that you have something like the following on your machine.
Folder1 (contains files)
-> Folder2 (contains files)
-> Folder3 (contains NO files)
Note : Go to the Testing section in the CLI.Config file. Make sure that LocalTestDirectory
element points to the root of the test folder hierarchy (Folder1 in the example above).

View File

@@ -0,0 +1,58 @@
//* ============================================================================
//Copyright 2014 Hewlett Packard
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//============================================================================ */
using System;
using System.Management.Automation;
using OpenStack.Client.Powershell.Cmdlets.Common;
using OpenStack.Storage;
namespace Rackspace.Client.Powershell.Cmdlets
{
[Cmdlet("Hello", "RS", SupportsShouldProcess = true)]
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
public class HelloRackspaceCmdlet : BasePSCmdlet
{
//=========================================================================================
/// <summary>
///
/// </summary>
//=========================================================================================
protected override void ProcessRecord()
{
Console.WriteLine("Hello World, from Rackspace!");
if (this.CoreClient != null)
{
var client = this.CoreClient.CreateServiceClient<IStorageServiceClient>();
var connectTask = client.GetStorageAccount();
connectTask.Wait();
StorageAccount account = connectTask.Result;
int h = 8;
Console.WriteLine(this.Context.Settings.LocalTestDirectory);
}
}
}
}

View File

@@ -13,7 +13,7 @@
<add key="TestVolumeName" value="TestVolume" />
<add key="TestFilePath" value="e:\Projects\Testing\Anothertest.txt" />
<add key="TestStorageContainerSecondaryName" value="b10" />
<add key="LocalTestDirectory" value="e:\Projects\Testing\" />
<add key="LocalTestDirectory" value="Your moma" />
<add key="TestImageId" value="5a1408cb-25f2-43a6-b1d9-931f5e47c871" />
<add key="TestFlavorId" value="100" />
</Testing>
@@ -31,11 +31,11 @@
<SharedContainers></SharedContainers>
</StorageManagement>
<IdentityServices>
<ServiceProvider name="HP3" isDefault="True">
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens" />
<add key="Username" value="travis.plummer@hp.com" />
<add key="Password" value="NoRemorseGlock27" />
<add key="DefaultTenantId" value="travis.plummer@hp.com" />
<ServiceProvider name="Rackspace" isDefault="true">
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens" displayName="Authentication Service URI" isMandatory="true" />
<add key="Username" value="" displayName="User name" isMandatory="true" />
<add key="Password" value="" displayName="Password" isMandatory="true" />
<add key="DefaultTenantId" value="" displayName="Default Tenant Id" isMandatory="true" />
</ServiceProvider>
</IdentityServices>
<ComputeServices>

View File

@@ -0,0 +1,19 @@
@{
ModuleToProcess = 'Rackspace.OpenStack.Client.Powershell.dll'
GUID="{847a28a4-6407-4aa6-8070-a4a51396db70}"
Author="Sam"
CompanyName="Rackspace Corporation"
Copyright="© Rackspace. All rights reserved."
ModuleVersion="1.0.0.0"
PowerShellVersion="2.0"
CLRVersion="4.0.30319"
FileList=''
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
}

Some files were not shown because too many files have changed in this diff Show More