This change addresses the Code Review from the previous commit. Changes include the following
Stronger Validation for Openstack.config. Better handling of detecting and raising NullReferenceExceptions Removal of dead code in a few places Added ability for each ServiceProvider to supply a ServiceMap which translates his name for a CoreService to something we can work with. Optimized code for dealing with Runspaces. This change implements 2 separate use cases for Multi-Vendor support. a. Initial Bootstrapping b. Switch Providers Change-Id: Ided462e5050214321e1ead50cf0498707d59128f Partially-implements: blueprint implement-multiple-vendor-support
This commit is contained in:
parent
3a9dd43380
commit
53dc8b3bf9
.gitignore
HP.Openstack.Client.Powershell
OpenStack-CLI.slnOpenstack.Client.Powershell
Cmdlets
Common
BasePSCmdlet.csGetConfigCmdlet.csGetServiceProvidersCmdlet.csGetVersionCmdlet.csGetZoneCmdlet.csGetZonesCmdlet.csNewServiceProviderCmdlet.csSetConfigCmdlet.csSetServiceProviderCmdlet.csSetZoneCmdlet.cs
ObjectStorage/Objects
Deployment
Openstack.Client.Powershell.csprojProviders
Common
ObjectStorage
Utility
AccountCapabilities.csAvailabilityZone.csConfigurationManager.csContext.csExtensionManager.csOpenstackCoreRegistrationManager.csRegistrationManager.csServiceMap.csServiceProvider.csServiceProviderAttribute.cs
app.configbin/Release
Deployment
Aliases.txtCLI.config.exampleMicrosoft.PowerShell_profile.ps1Openstack.configOpenstack.psd1OpenstackShell.format.ps1xmlReleaseNotes.xml
Openstack.Client.Powershell.dll-help.xmlOpenstack.psd1OpenstackShell.format.ps1xmlobj/Debug
Openstack.Client.Powershell.csproj.FileListAbsolute.txtOpenstack.Client.Powershell.csprojResolveAssemblyReference.cacheOpenstack.Client.Powershell.dllOpenstack.Client.Powershell.g.resourcesOpenstack.Client.Powershell.pdbTemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.csTemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.csTemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
packages.configRackspace.Client.Powershell
164
.gitignore
vendored
Normal file
164
.gitignore
vendored
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
CLI.config
|
||||||
|
*.cache
|
||||||
|
FileListAbsolute.txt
|
||||||
|
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
x64/
|
||||||
|
build/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
|
||||||
|
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
|
||||||
|
!packages/*/build/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.log
|
||||||
|
*.scc
|
||||||
|
*.dll
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
*.ncrunch*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.Publish.xml
|
||||||
|
|
||||||
|
# NuGet Packages Directory
|
||||||
|
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||||
|
packages/
|
||||||
|
|
||||||
|
# Windows Azure Build Output
|
||||||
|
csx
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Windows Store app package directory
|
||||||
|
AppPackages/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
sql/
|
||||||
|
*.Cache
|
||||||
|
ClientBin/
|
||||||
|
[Ss]tyle[Cc]op.*
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
App_Data/*.mdf
|
||||||
|
App_Data/*.ldf
|
||||||
|
|
||||||
|
|
||||||
|
#LightSwitch generated files
|
||||||
|
GeneratedArtifacts/
|
||||||
|
_Pvt_Extensions/
|
||||||
|
ModelManifest.xml
|
||||||
|
|
||||||
|
# =========================
|
||||||
|
# Windows detritus
|
||||||
|
# =========================
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Mac desktop service store files
|
||||||
|
.DS_Store
|
@ -8,7 +8,7 @@ ModuleVersion="1.0.0.0"
|
|||||||
PowerShellVersion="2.0"
|
PowerShellVersion="2.0"
|
||||||
CLRVersion="4.0.30319"
|
CLRVersion="4.0.30319"
|
||||||
FileList=''
|
FileList=''
|
||||||
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
|
RequiredAssemblies = 'OpenStack.dll'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\HP\</OutputPath>
|
<OutputPath>..\..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\HP\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
@ -32,12 +32,28 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OpenStack, Version=0.9.1.0, Culture=neutral, PublicKeyToken=baf191d8aca7391c, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\OpenStack-SDK-DotNet.0.9.1.0\lib\net40\OpenStack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
|
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Net.Http.Extensions">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Primitives">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@ -50,16 +66,13 @@
|
|||||||
<Compile Include="Utility\HPRegistrationManager.cs" />
|
<Compile Include="Utility\HPRegistrationManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="Deployment\HP.psd1">
|
<None Include="Deployment\HP.psd1">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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">
|
<ProjectReference Include="..\Openstack.Client.Powershell\Openstack.Client.Powershell.csproj">
|
||||||
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
|
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
|
||||||
<Name>Openstack.Client.Powershell</Name>
|
<Name>Openstack.Client.Powershell</Name>
|
||||||
@ -70,6 +83,11 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>copy .\Deployment\HP.psd1 C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\HP</PostBuildEvent>
|
<PostBuildEvent>copy .\Deployment\HP.psd1 C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\HP</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||||
|
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||||
|
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
@ -4,12 +4,13 @@ using System.Linq;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
using OpenStack.Client.Powershell.Utility;
|
using OpenStack.Client.Powershell.Utility;
|
||||||
using OpenStack.Identity;
|
using OpenStack.Identity;
|
||||||
|
|
||||||
namespace HP.OpenStack.Client.Powershell.Utility
|
namespace HP.OpenStack.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
|
[ServiceProviderAttribute("HP")]
|
||||||
public class HPRegistrationManager : RegistrationManager
|
public class HPRegistrationManager : RegistrationManager
|
||||||
{
|
{
|
||||||
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
@{
|
|
||||||
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"
|
|
||||||
FormatsToProcess=""
|
|
||||||
FileList=''
|
|
||||||
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
9
HP.Openstack.Client.Powershell/packages.config
Normal file
9
HP.Openstack.Client.Powershell/packages.config
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
|
||||||
|
<package id="OpenStack-SDK-DotNet" version="0.9.1.0" targetFramework="net45" />
|
||||||
|
<package id="System.Management.Automation" version="6.1.7601.17515" targetFramework="net45" />
|
||||||
|
</packages>
|
@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D4A8C6
|
|||||||
.nuget\NuGet.targets = .nuget\NuGet.targets
|
.nuget\NuGet.targets = .nuget\NuGet.targets
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
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}"
|
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
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rackspace.Openstack.Client.Powershell", "Rackspace.Client.Powershell\Rackspace.Openstack.Client.Powershell.csproj", "{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rackspace.Openstack.Client.Powershell", "Rackspace.Client.Powershell\Rackspace.Openstack.Client.Powershell.csproj", "{8E2903DF-9FB6-48F8-85BF-FD2422BE38AF}"
|
||||||
@ -46,21 +44,6 @@ Global
|
|||||||
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|Mixed Platforms.ActiveCfg = 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|Mixed Platforms.Build.0 = TransformTool Build|Any CPU
|
||||||
{32BAC168-2EC8-4074-9E6D-8C13460DCFAD}.TransformTool Build|x86.ActiveCfg = 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.ActiveCfg = Debug|Any CPU
|
||||||
{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Debug|Any CPU
|
||||||
|
@ -26,6 +26,8 @@ using OpenStack.Client.Powershell.Providers.Common;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Management.Automation.Host;
|
using System.Management.Automation.Host;
|
||||||
|
using System.Threading;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
@ -82,6 +84,19 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="service"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected T CreateServiceClient<T>(CoreServices service) where T : IOpenStackServiceClient
|
||||||
|
{
|
||||||
|
ServiceProvider provider = this.Context.CurrentServiceProvider;
|
||||||
|
return this.CoreClient.CreateServiceClientByName<T>(provider.ServiceMaps.TranslateServiceName(service));
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
protected IOpenStackClient CoreClient
|
protected IOpenStackClient CoreClient
|
||||||
{
|
{
|
||||||
@ -95,6 +110,17 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override void StopProcessing()
|
||||||
|
{
|
||||||
|
CancellationTokenSource source = (CancellationTokenSource)this.SessionState.PSVariable.Get("CancellationTokenSource").Value;
|
||||||
|
source.Cancel();
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -209,6 +235,7 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
/// <param name="entity"></param>
|
/// <param name="entity"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
|
|
||||||
protected bool UserConfirmsDeleteAction(string entity)
|
protected bool UserConfirmsDeleteAction(string entity)
|
||||||
{
|
{
|
||||||
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||||
@ -301,10 +328,10 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
//protected StoragePath CreateStoragePath(string path)
|
protected StoragePath CreateStoragePath(string path)
|
||||||
//{
|
{
|
||||||
// return ((OSDriveInfo)this.Drive).CreateStoragePath(path);
|
return ((ObjectStoragePSDriveInfo)this.Drive).CreateStoragePath(path);
|
||||||
//}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,6 @@ limitations under the License.
|
|||||||
using System;
|
using System;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
|
||||||
using System.IO;
|
|
||||||
using System.Xml;
|
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
@ -61,9 +58,9 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
{
|
{
|
||||||
if (((string)setting.Key) == "SecretKey" || ((string)setting.Key)== "AccessKey")
|
if (((string)setting.Key) == "SecretKey" || ((string)setting.Key)== "AccessKey")
|
||||||
{
|
{
|
||||||
DictionaryEntry entry = new DictionaryEntry();
|
var entry = new DictionaryEntry();
|
||||||
entry.Value = "***********";
|
entry.Value = "***********";
|
||||||
entry.Key = setting.Key;
|
entry.Key = setting.Key;
|
||||||
WriteObject(entry);
|
WriteObject(entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -31,8 +31,6 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||||
public class GetServiceProvidersCmdlet : BasePSCmdlet
|
public class GetServiceProvidersCmdlet : BasePSCmdlet
|
||||||
{
|
{
|
||||||
#region Parameters
|
|
||||||
#endregion
|
|
||||||
#region Methods
|
#region Methods
|
||||||
|
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -42,8 +40,12 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
ConfigurationManager manager = new ConfigurationManager();
|
var manager = new ConfigurationManager();
|
||||||
manager.Load();
|
manager.Load();
|
||||||
|
|
||||||
|
this.WriteObject("");
|
||||||
|
this.WriteObject("Current Service Provider : " + this.Context.CurrentServiceProvider.Name);
|
||||||
|
this.WriteObject("-----------------------------------------");
|
||||||
this.WriteObject(manager.GetServiceProviders());
|
this.WriteObject(manager.GetServiceProviders());
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -17,7 +17,6 @@ using System;
|
|||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
using OpenStack.Client.Powershell.Cmdlets.Common;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using OpenStack.Client.Powershell.Providers.Common;
|
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Cmdlets.GroupManagement
|
namespace OpenStack.Client.Powershell.Cmdlets.GroupManagement
|
||||||
{
|
{
|
||||||
|
@ -14,13 +14,11 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
using System.Linq;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
@ -34,13 +32,13 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
string configFilePath = this.ConfigFilePath;
|
AvailabilityZone zone = this.Context.CurrentServiceProvider.AvailabilityZones.Where(z => z.IsDefault == true).Single();
|
||||||
XDocument doc = XDocument.Load(configFilePath);
|
|
||||||
XElement defaultZoneNode = doc.XPathSelectElement("//AvailabilityZone[@isDefault='True']");
|
if (zone != null) {
|
||||||
|
Console.WriteLine("");
|
||||||
Console.WriteLine("");
|
Console.WriteLine("Current Availability Zone is " + zone.Name);
|
||||||
Console.WriteLine("Current Availability Zone is " + defaultZoneNode.Attribute("name").Value);
|
Console.WriteLine("");
|
||||||
Console.WriteLine("");
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,74 +21,68 @@ using OpenStack.Client.Powershell.Cmdlets.Common;
|
|||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
[Cmdlet("Get", "Zones", SupportsShouldProcess = true)]
|
[Cmdlet("Get", "Zones", SupportsShouldProcess = true)]
|
||||||
public class GetZonesCmdlet : BasePSCmdlet
|
public class GetZonesCmdlet : BasePSCmdlet
|
||||||
{
|
{
|
||||||
private SwitchParameter _verbose = true;
|
//private SwitchParameter _verbose = true;
|
||||||
|
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
[Parameter(Mandatory = false, ParameterSetName = "gc0", ValueFromPipelineByPropertyName = true, HelpMessage = "Prints extended information for each service.")]
|
//[Parameter(Mandatory = false, ParameterSetName = "gz", ValueFromPipelineByPropertyName = true, HelpMessage = "Prints extended information for each service.")]
|
||||||
[Alias("v")]
|
//[Alias("v")]
|
||||||
[ValidateNotNullOrEmpty]
|
//[ValidateNotNullOrEmpty]
|
||||||
public SwitchParameter Verbose2
|
//public SwitchParameter Verbose
|
||||||
{
|
//{
|
||||||
get { return _verbose; }
|
// get { return _verbose; }
|
||||||
set { _verbose = value; }
|
// set { _verbose = value; }
|
||||||
}
|
//}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
private void ShowVerboseOutput(IEnumerable<XElement> zoneKeyNode)
|
private void ShowVerboseOutput()
|
||||||
{
|
{
|
||||||
foreach (XElement element in zoneKeyNode)
|
foreach (AvailabilityZone zone in this.Context.CurrentServiceProvider.AvailabilityZones)
|
||||||
{
|
{
|
||||||
this.WriteHeaderSection("Zone : " + element.Attribute("name").Value);
|
this.WriteHeaderSection("Zone : " + zone.Name);
|
||||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zone.ShellForegroundColor);
|
||||||
Console.WriteLine("Zone Id : " + element.Attribute("id").Value);
|
Console.WriteLine("Zone Id : " + zone.Id);
|
||||||
Console.WriteLine("Zone Name : " + element.Attribute("name").Value);
|
Console.WriteLine("Zone Name : " + zone.Name);
|
||||||
Console.WriteLine("Shell Foreground Color : " + element.Attribute("shellForegroundColor").Value);
|
Console.WriteLine("Shell Foreground Color : " + zone.ShellForegroundColor);
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
Console.WriteLine("The following Services are available from this Availability Zone");
|
Console.WriteLine("The following Services are available from this Availability Zone");
|
||||||
Console.WriteLine("----------------------------------------------------------------");
|
Console.WriteLine("----------------------------------------------------------------");
|
||||||
this.WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(element.Attribute("name").Value));
|
|
||||||
|
this.WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(zone.Name));
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
}
|
}
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
private void ShowNonVerboseOutput(IEnumerable<XElement> zoneKeyNode)
|
private void ShowNonVerboseOutput()
|
||||||
{
|
{
|
||||||
//Console.WriteLine("");
|
foreach (AvailabilityZone zone in this.Context.CurrentServiceProvider.AvailabilityZones)
|
||||||
//Console.WriteLine("Current Availability Zones include ");
|
{
|
||||||
//Console.WriteLine("");
|
this.WriteHeaderSection("Zone : " + zone.Name);
|
||||||
//foreach (XElement element in zoneKeyNode)
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zone.ShellForegroundColor);
|
||||||
//{
|
Console.WriteLine("Zone Id : " + zone.Id);
|
||||||
// Zone zone = new Zone();
|
Console.WriteLine("Zone Name : " + zone.Name);
|
||||||
// zone.Name = element.Attribute("name").Value;
|
Console.WriteLine("Shell Foreground Color : " + zone.ShellForegroundColor);
|
||||||
// zone.ShellForegroundColor = element.Attribute("shellForegroundColor").Value;
|
Console.WriteLine("");
|
||||||
// zone.Id = element.Attribute("id").Value;
|
}
|
||||||
|
Console.WriteLine("");
|
||||||
// if (element.Attribute("isDefault").Value == "True")
|
|
||||||
// zone.IsDefault = true;
|
|
||||||
// else
|
|
||||||
// zone.IsDefault = false;
|
|
||||||
|
|
||||||
// this.WriteObject(zone);
|
|
||||||
//}
|
|
||||||
//Console.WriteLine("");
|
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -97,18 +91,16 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
string configFilePath = this.ConfigFilePath; ;
|
this.ShowVerboseOutput();
|
||||||
XDocument doc = XDocument.Load(configFilePath);
|
|
||||||
IEnumerable<XElement> zoneKeyNode = doc.Descendants("AvailabilityZone");
|
|
||||||
|
|
||||||
if (_verbose)
|
//if (_verbose)
|
||||||
{
|
//{
|
||||||
this.ShowVerboseOutput(zoneKeyNode);
|
// this.ShowVerboseOutput();
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
this.ShowNonVerboseOutput(zoneKeyNode);
|
// this.ShowNonVerboseOutput();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,12 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
public class NewServiceProvidersCmdlet : BasePSCmdlet
|
public class NewServiceProvidersCmdlet : BasePSCmdlet
|
||||||
{
|
{
|
||||||
|
|
||||||
private string _name = "HP21";
|
private string _name = "";
|
||||||
private bool _isDefault = false;
|
private bool _isDefault = false;
|
||||||
private string _authenticationServiceURI = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens";
|
private string _authenticationServiceURI = "";
|
||||||
private string _username = "travis.plummer@hp.com";
|
private string _username = "";
|
||||||
private string _password = "NoRemorseGlock27";
|
private string _password = "";
|
||||||
private string _defTenantId = "travis.plummer@hp.com";
|
private string _defTenantId = "";
|
||||||
|
|
||||||
#region Parameters
|
#region Parameters
|
||||||
|
|
||||||
|
@ -13,31 +13,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Xml.Linq;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenStack;
|
|
||||||
using System.Xml.XPath;
|
|
||||||
using OpenStack.Client.Powershell.Providers.Common;
|
|
||||||
using OpenStack.Client.Powershell.Utility;
|
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)]
|
[Cmdlet(VerbsCommon.Set, "Config", SupportsShouldProcess = true)]
|
||||||
public class SetConfigCmdlet : BasePSCmdlet
|
public class SetConfigCmdlet : BasePSCmdlet
|
||||||
{
|
{
|
||||||
private string _key;
|
//private string _configFilePath = @"C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Rackspace.Client.Powershell\Deployment\Rackspace.config";
|
||||||
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 SwitchParameter _reset = false;
|
||||||
private string _oldAccessKey;
|
|
||||||
|
|
||||||
#region Parameters
|
#region Parameters
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -66,310 +52,29 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
get { return _configFilePath; }
|
get { return _configFilePath; }
|
||||||
set { _configFilePath = value; }
|
set { _configFilePath = value; }
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
//=========================================================================================
|
|
||||||
//[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; }
|
|
||||||
//}
|
|
||||||
#endregion
|
#endregion
|
||||||
//=======================================================================================================
|
//=======================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </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======================================================
|
//=================================================zx======================================================
|
||||||
private void LoadConfigFile()
|
private void LoadConfigFile()
|
||||||
{
|
{
|
||||||
ConfigurationManager configManager = new ConfigurationManager();
|
var configManager = new ConfigurationManager();
|
||||||
configManager.Load(this.ConfigFilePathKey);
|
configManager.Load(this.ConfigFilePathKey);
|
||||||
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
||||||
|
|
||||||
ExtensionManager loader = new ExtensionManager(this.SessionState, this.Context);
|
var loader = new ExtensionManager(this.SessionState, this.Context);
|
||||||
|
|
||||||
loader.LoadCore(provider);
|
loader.LoadCore(provider);
|
||||||
loader.LoadExtension(provider);
|
loader.LoadExtension(provider);
|
||||||
|
|
||||||
// Show the User the new ServiceCatalog that we just received..
|
// Show the User the new ServiceCatalog that we just received..
|
||||||
|
|
||||||
this.WriteServices();
|
var capabilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient, this);
|
||||||
|
capabilities.WriteServices();
|
||||||
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
|
capabilities.WriteContainers();
|
||||||
|
|
||||||
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>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="address"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
//======================================================================================================================
|
|
||||||
private string GetContainerName(string url)
|
|
||||||
{
|
|
||||||
string[] elements = url.Split('/');
|
|
||||||
return elements[elements.Length - 1];
|
|
||||||
}
|
|
||||||
//======================================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
//======================================================================================================================
|
|
||||||
private string GetDNSPortion(string url)
|
|
||||||
{
|
|
||||||
string[] elements = url.Split('/');
|
|
||||||
return elements[2];
|
|
||||||
}
|
|
||||||
//=======================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
//=======================================================================================================
|
|
||||||
//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..
|
|
||||||
|
|
||||||
// if (_oldAccessKey != this.Settings.Username)
|
|
||||||
// {
|
|
||||||
// this.InitializeSession(this.Settings);
|
|
||||||
|
|
||||||
// // 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 (this.Context.ServiceCatalog.DoesServiceExist("OS-Storage"))
|
|
||||||
// {
|
|
||||||
// this.WriteContainers(_configFilePath);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (this.Drive.Name == "OpenStack")
|
|
||||||
// {
|
|
||||||
// this.SessionState.InvokeCommand.InvokeScript(@"cd\");
|
|
||||||
// ((CommonDriveInfo)this.Drive).CurrentContainer.Load();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// this.SessionState.PSVariable.Set(new PSVariable("ConfigPath", configFilePath));
|
|
||||||
|
|
||||||
// //Context tempContext = (Context)this.SessionState.PSVariable.GetValue("Context", null);
|
|
||||||
// //this.UpdateCache(tempContext);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//=======================================================================================================
|
//=======================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -378,20 +83,6 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
this.LoadConfigFile();
|
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;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,6 @@
|
|||||||
//============================================================================ */
|
//============================================================================ */
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using OpenStack.Client.Powershell.Utility;
|
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
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
@ -64,10 +56,10 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
ConfigurationManager manager = new ConfigurationManager();
|
var manager = new ConfigurationManager();
|
||||||
manager.Load();
|
manager.Load();
|
||||||
|
|
||||||
ServiceProvider provider = manager.GetServiceProvider(this.Name);
|
var provider = manager.GetServiceProvider(this.Name);
|
||||||
provider.IsDefault = this.SetDefault;
|
provider.IsDefault = this.SetDefault;
|
||||||
|
|
||||||
this.WriteObject("");
|
this.WriteObject("");
|
||||||
@ -94,13 +86,13 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
{
|
{
|
||||||
if (this.SetDefault)
|
if (this.SetDefault)
|
||||||
{
|
{
|
||||||
ConfigurationManager configManager = new ConfigurationManager();
|
var configManager = new ConfigurationManager();
|
||||||
configManager.Load();
|
configManager.Load();
|
||||||
configManager.SetDefaultServiceProvider(provider.Name);
|
configManager.SetDefaultServiceProvider(provider.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.WriteObject(" - Loading Service Provider extensions ");
|
this.WriteObject(" - Loading Service Provider extensions ");
|
||||||
ExtensionManager manager = new ExtensionManager(this.SessionState, this.Context);
|
var manager = new ExtensionManager(this.SessionState, this.Context);
|
||||||
manager.LoadExtension(provider);
|
manager.LoadExtension(provider);
|
||||||
this.ShowAccountState();
|
this.ShowAccountState();
|
||||||
}
|
}
|
||||||
@ -115,201 +107,14 @@ namespace OpenStack.Client.Powershell.Cmdlets.Common
|
|||||||
|
|
||||||
this.WriteObject(" - Success!");
|
this.WriteObject(" - Success!");
|
||||||
this.WriteObject("");
|
this.WriteObject("");
|
||||||
this.WriteServices();
|
|
||||||
|
|
||||||
// If ObjectStorage is among those new Services, show the new Container set bound to those credentials..
|
// This is a hack for sure.. Need to move Zones into Vendor specific section.
|
||||||
|
|
||||||
if (this.Context.ServiceCatalog.Exists("Object Storage"))
|
this.Context.CurrentRegion = "region-a.geo-1";
|
||||||
{
|
|
||||||
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");
|
var capabilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient, this);
|
||||||
foreach (PSDriveInfo deadDrive in deadDrives)
|
capabilities.WriteServices();
|
||||||
{
|
capabilities.WriteContainers();
|
||||||
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
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,11 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
============================================================================ */
|
============================================================================ */
|
||||||
using System;
|
using System;
|
||||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
using System.Collections.Generic;
|
using OpenStack.Client.Powershell.Cmdlets.Common;
|
||||||
using Openstack.Objects.Domain;
|
using OpenStack.Client.Powershell.Utility;
|
||||||
using Openstack.Client.Powershell.Providers.Storage;
|
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using Openstack.Common.Properties;
|
|
||||||
using Openstack.Objects.DataAccess;
|
|
||||||
|
|
||||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||||
{
|
{
|
||||||
@ -32,6 +27,7 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
|
|||||||
{
|
{
|
||||||
private string _Zone;
|
private string _Zone;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -45,124 +41,109 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
|
|||||||
{
|
{
|
||||||
get { return _Zone; }
|
get { return _Zone; }
|
||||||
set { _Zone = value; }
|
set { _Zone = value; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Methods
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected override void ProcessRecord()
|
protected override void ProcessRecord()
|
||||||
{
|
{
|
||||||
if (this.Drive.Provider.Name != "OS-Cloud" && this.Drive.Provider.Name != "OS-Storage")
|
if (this.Drive.Provider.Name != "OpenStack-Cloud" && this.Drive.Provider.Name != "Object Storage") {
|
||||||
{
|
ShowError();
|
||||||
ConsoleColor oldColor = Console.ForegroundColor;
|
|
||||||
Console.ForegroundColor = ConsoleColor.Red;
|
|
||||||
Console.WriteLine("");
|
|
||||||
Console.WriteLine("Setting the Availability Zone requires you to be connected to the OpenStack: drive or a valid Storage Container. Please map to one of these drive types and reissue the command.");
|
|
||||||
Console.WriteLine("");
|
|
||||||
Console.ForegroundColor = oldColor;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string configFilePath = this.ConfigFilePath;
|
// Mark down the new default Region and reload the config file..
|
||||||
XDocument doc = XDocument.Load(configFilePath);
|
|
||||||
XElement zoneKeyNode = doc.XPathSelectElement("//AvailabilityZone[@id='" + _Zone + "']");
|
|
||||||
XElement defaultZoneNode = doc.XPathSelectElement("//AvailabilityZone[@isDefault='True']");
|
|
||||||
|
|
||||||
defaultZoneNode.SetAttributeValue("isDefault", "False");
|
XElement zoneKeyNode = SaveZone();
|
||||||
zoneKeyNode.SetAttributeValue("isDefault", "True");
|
this.Context.CurrentRegion = zoneKeyNode.Attribute("name").Value;
|
||||||
doc.Save(configFilePath);
|
this.Context.Settings.Load(this.ConfigFilePath);
|
||||||
this.Settings.Load(configFilePath);
|
|
||||||
|
|
||||||
this.Context.Forecolor = zoneKeyNode.Attribute("shellForegroundColor").Value;
|
|
||||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zoneKeyNode.Attribute("shellForegroundColor").Value);
|
|
||||||
Console.WriteLine("");
|
|
||||||
Console.WriteLine("New Availability Zone " + zoneKeyNode.Attribute("name").Value + " selected.");
|
|
||||||
Console.WriteLine("");
|
|
||||||
|
|
||||||
|
|
||||||
if (this.Drive.Name == "OpenStack")
|
|
||||||
this.SessionState.InvokeCommand.InvokeScript(@"cd\");
|
|
||||||
else
|
|
||||||
this.SessionState.InvokeCommand.InvokeScript("cd c:");
|
|
||||||
|
|
||||||
|
ConfigurationManager manager = new ConfigurationManager();
|
||||||
|
manager.Load();
|
||||||
|
|
||||||
|
this.SetUI(zoneKeyNode);
|
||||||
|
this.ChanegDirectory();
|
||||||
this.UpdateCache();
|
this.UpdateCache();
|
||||||
this.WriteServices(zoneKeyNode.Attribute("name").Value);
|
|
||||||
this.WriteContainers();
|
// Now show the User what he is getting for this action..
|
||||||
|
|
||||||
|
var abilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient , this);
|
||||||
|
abilities.WriteServices();
|
||||||
|
abilities.WriteContainers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//=======================================================================================================
|
//=======================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
//=======================================================================================================
|
||||||
|
private void ShowError()
|
||||||
|
{
|
||||||
|
ConsoleColor oldColor = Console.ForegroundColor;
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("Setting the Availability Zone requires you to be connected to the OpenStack: drive or a valid Storage Container. Please map to one of these drive types and reissue the command.");
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.ForegroundColor = oldColor;
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="zoneKeyNode"></param>
|
||||||
|
//=======================================================================================================
|
||||||
|
private void SetUI(XElement zoneKeyNode)
|
||||||
|
{
|
||||||
|
this.Context.Forecolor = zoneKeyNode.Attribute("shellForegroundColor").Value;
|
||||||
|
Console.ForegroundColor =(ConsoleColor) Enum.Parse(typeof (ConsoleColor), zoneKeyNode.Attribute("shellForegroundColor").Value);
|
||||||
|
Console.WriteLine("");
|
||||||
|
Console.WriteLine("New Availability Zone " + zoneKeyNode.Attribute("name").Value + " selected.");
|
||||||
|
Console.WriteLine("");
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=======================================================================================================
|
||||||
|
private void ChanegDirectory()
|
||||||
|
{
|
||||||
|
if (this.Drive.Provider.Name == "Object Storage")
|
||||||
|
this.SessionState.InvokeCommand.InvokeScript(@"cd\");
|
||||||
|
else
|
||||||
|
this.SessionState.InvokeCommand.InvokeScript("cd c:");
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=======================================================================================================
|
||||||
|
private XElement SaveZone()
|
||||||
|
{
|
||||||
|
string configFilePath = this.ConfigFilePath;
|
||||||
|
XDocument doc = XDocument.Load(configFilePath);
|
||||||
|
XElement zoneKeyNode = doc.XPathSelectElement("//AvailabilityZone[@id='" + _Zone + "']");
|
||||||
|
XElement defaultZoneNode = doc.XPathSelectElement("//AvailabilityZone[@isDefault='True']");
|
||||||
|
|
||||||
|
defaultZoneNode.SetAttributeValue("isDefault", "False");
|
||||||
|
zoneKeyNode.SetAttributeValue("isDefault", "True");
|
||||||
|
doc.Save(configFilePath);
|
||||||
|
return zoneKeyNode;
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
//=======================================================================================================
|
//=======================================================================================================
|
||||||
private void WriteServices(string availabilityZone)
|
private void WriteServices(string availabilityZone)
|
||||||
{
|
{
|
||||||
this.WriteHeader("This Availability Zone has the following services available.");
|
this.WriteHeader("This Availability Zone has the following services available.");
|
||||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||||
WriteObject(this.Context.ServiceCatalog.GetAZServices(availabilityZone));
|
WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(availabilityZone));
|
||||||
}
|
|
||||||
//==================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
//==================================================================================================
|
|
||||||
private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo)
|
|
||||||
{
|
|
||||||
List<StorageContainer> storageContainers = null;
|
|
||||||
OSDriveParameters parameters = new OSDriveParameters();
|
|
||||||
|
|
||||||
if (this.Settings != null)
|
|
||||||
{
|
|
||||||
parameters.Settings = this.Settings;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parameters.Settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IContainerRepository storageContainerRepository = this.RepositoryFactory.CreateContainerRepository();
|
|
||||||
storageContainers = storageContainerRepository.GetStorageContainers();
|
|
||||||
}
|
|
||||||
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
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
drives.Add(kvsDriveInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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>
|
/// <summary>
|
||||||
@ -183,80 +164,6 @@ namespace Openstack.Client.Powershell.Cmdlets.Common
|
|||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
WriteObject(" ");
|
WriteObject(" ");
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
#endregion
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
//=========================================================================================
|
|
||||||
private void WriteContainers()
|
|
||||||
{
|
|
||||||
List<string> invalidDriveNames = new List<string>();
|
|
||||||
OSDriveParameters parameters = new OSDriveParameters();
|
|
||||||
HPOSNavigationProvider provider = new HPOSNavigationProvider();
|
|
||||||
Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Settings, this.SessionState.Provider.GetOne("OS-Storage"));
|
|
||||||
|
|
||||||
if (drives != null)
|
|
||||||
{
|
|
||||||
this.WriteHeader("Storage Containers available in this Region include");
|
|
||||||
|
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (PSDriveInfo drive in drives)
|
|
||||||
{
|
|
||||||
if (drive.Name != string.Empty)
|
|
||||||
{
|
|
||||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//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(" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,18 +14,19 @@
|
|||||||
//limitations under the License.
|
//limitations under the License.
|
||||||
//============================================================================ */
|
//============================================================================ */
|
||||||
//using System.Management.Automation;
|
//using System.Management.Automation;
|
||||||
//using OpenStack.Objects;
|
//using OpenStack;
|
||||||
//using OpenStack.Objects.Domain;
|
|
||||||
//using OpenStack.Client.Powershell.Providers.Storage;
|
//using OpenStack.Client.Powershell.Providers.Storage;
|
||||||
//using System;
|
//using System;
|
||||||
//using OpenStack.Objects.DataAccess.Storage;
|
|
||||||
//using OpenStack.Client.Powershell.Providers.Common;
|
//using OpenStack.Client.Powershell.Providers.Common;
|
||||||
//using System.IO;
|
//using System.IO;
|
||||||
|
//using OpenStack.Client.Powershell.Utility;
|
||||||
|
//using OpenStack.Storage;
|
||||||
|
//using System.Net.Http;
|
||||||
|
|
||||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||||
//{
|
//{
|
||||||
// [Cmdlet(VerbsCommon.Copy, "Item", SupportsShouldProcess = true)]
|
// [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 class CopyItemCmdlet : BasePSCmdlet
|
||||||
// {
|
// {
|
||||||
// public const string cDelimiter = "/";
|
// public const string cDelimiter = "/";
|
||||||
@ -33,11 +34,11 @@
|
|||||||
// private string _sourcePath;
|
// private string _sourcePath;
|
||||||
// private string _targetPath;
|
// private string _targetPath;
|
||||||
// private SwitchParameter _recursive;
|
// private SwitchParameter _recursive;
|
||||||
// private long _bytesCopied = 0;
|
// private long _bytesCopied = 0;
|
||||||
// private int _filesCopied = 0;
|
// private int _filesCopied = 0;
|
||||||
// private long _totalBytesCopied = 0;
|
// private long _totalBytesCopied = 0;
|
||||||
// private int _totalFilesCopied = 0;
|
// private int _totalFilesCopied = 0;
|
||||||
|
|
||||||
// #region Ctors
|
// #region Ctors
|
||||||
////=========================================================================================
|
////=========================================================================================
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@ -106,11 +107,11 @@
|
|||||||
// {
|
// {
|
||||||
// get
|
// get
|
||||||
// {
|
// {
|
||||||
// if (((OSDriveInfo)this.Drive).SharePath == null)
|
// if (((ObjectStoragePSDriveInfo)this.Drive).SharePath == null)
|
||||||
// return this.Context.ServiceCatalog.GetService("object-store").Url;
|
// return this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", String.Empty);
|
||||||
// else
|
// else
|
||||||
// //return ((OSDriveInfo)this.Drive).SharePath;
|
// //return ((OSDriveInfo)this.Drive).SharePath;
|
||||||
// return ((OSDriveInfo)this.Drive).SharePath.Replace(this.Drive.Name, string.Empty);
|
// return ((ObjectStoragePSDriveInfo)this.Drive).SharePath.Replace(this.Drive.Name, string.Empty);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// #endregion
|
// #endregion
|
||||||
@ -191,24 +192,42 @@
|
|||||||
///// <param name="sender"></param>
|
///// <param name="sender"></param>
|
||||||
///// <param name="e"></param>
|
///// <param name="e"></param>
|
||||||
////=========================================================================================
|
////=========================================================================================
|
||||||
// private void ListChanged(object sender, CopyOperationInfoEventArgs e)
|
// //private void ListChanged(object sender, CopyOperationInfoEventArgs e)
|
||||||
|
// //{
|
||||||
|
// // //if (e.ExceptionMessage == null)
|
||||||
|
// // //{
|
||||||
|
// // // if (e.Filename != null || e.Filename != string.Empty)
|
||||||
|
// // // {
|
||||||
|
// // // Console.WriteLine("Copying file " + e.Filename);
|
||||||
|
// // // _bytesCopied = _bytesCopied + e.BytesCopied;
|
||||||
|
// // // ++_filesCopied;
|
||||||
|
// // // _totalBytesCopied = _totalBytesCopied + e.BytesCopied;
|
||||||
|
// // // ++_totalFilesCopied;
|
||||||
|
// // // }
|
||||||
|
// // //}
|
||||||
|
// // //else
|
||||||
|
// // //{
|
||||||
|
// // // Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
// // // Console.WriteLine("Error : " + e.ExceptionMessage);
|
||||||
|
// // // Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
// // //}
|
||||||
|
// //}
|
||||||
|
////================================================================================
|
||||||
|
///// <summary>
|
||||||
|
/////
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="path"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
////================================================================================
|
||||||
|
// private FileStream GetFileStream(StoragePath path)
|
||||||
// {
|
// {
|
||||||
// if (e.ExceptionMessage == null)
|
// if (!path.Volume.EndsWith(@"\") && !path.Path.StartsWith(@"\"))
|
||||||
// {
|
// {
|
||||||
// if (e.Filename != null || e.Filename != string.Empty)
|
// return new FileStream(path.Volume + @"\" + path.Path, FileMode.Open);
|
||||||
// {
|
|
||||||
// Console.WriteLine("Copying file " + e.Filename);
|
|
||||||
// _bytesCopied = _bytesCopied + e.BytesCopied;
|
|
||||||
// ++_filesCopied;
|
|
||||||
// _totalBytesCopied = _totalBytesCopied + e.BytesCopied;
|
|
||||||
// ++_totalFilesCopied;
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// Console.ForegroundColor = ConsoleColor.Red;
|
// return new FileStream(path.Volume + path.Path, FileMode.Open);
|
||||||
// Console.WriteLine("Error : " + e.ExceptionMessage);
|
|
||||||
// Console.ForegroundColor = ConsoleColor.Green;
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
////=================================================================================================
|
////=================================================================================================
|
||||||
@ -218,32 +237,44 @@
|
|||||||
////=================================================================================================
|
////=================================================================================================
|
||||||
// private void ProcessNonQueuedCopy()
|
// private void ProcessNonQueuedCopy()
|
||||||
// {
|
// {
|
||||||
// StoragePath sourcePath = this.CreateStoragePath(this.SourcePath);
|
// StoragePath sourcePath = this.CreateStoragePath(this.SourcePath);
|
||||||
// StoragePath targetPath = this.CreateValidTargetPath(sourcePath, this.TargetPath);
|
// StoragePath targetPath = this.CreateValidTargetPath(sourcePath, this.TargetPath);
|
||||||
// IStorageObjectRepository repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
// IStorageServiceClient service = this.CoreClient.CreateServiceClient<IStorageServiceClient>();
|
||||||
|
// string containerName = Path.GetFileNameWithoutExtension(this.SourcePath);
|
||||||
|
|
||||||
|
|
||||||
// if (sourcePath.PathType == OpenStack.Common.PathType.Local && targetPath.PathType == OpenStack.Common.PathType.Remote)
|
// if (sourcePath.PathType == PathType.Local && targetPath.PathType == PathType.Remote) {
|
||||||
// {
|
// service.CreateStorageObject(containerName, targetPath.ResourcePath, null, this.GetFileStream(sourcePath));
|
||||||
// long lastSegment = repository.GetLastSegmentId(targetPath);
|
|
||||||
// if (lastSegment != 0)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine("");
|
|
||||||
// Console.WriteLine(" You've already uploaded a portion of this file.");
|
|
||||||
// Console.WriteLine(" Would you like to resume your previous upload? [Y/N]");
|
|
||||||
// ConsoleKeyInfo response = Console.ReadKey();
|
|
||||||
// if (response.Key != ConsoleKey.Y)
|
|
||||||
// {
|
|
||||||
// repository.DeleteStorageObject(targetPath.AbsoluteURI + @"_temp\");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ((StorageObjectRepository)repository).Changed += new StorageObjectRepository.CopyOperationCompleteEventHandler(ListChanged);
|
|
||||||
// Console.WriteLine("");
|
|
||||||
// repository.Copy(sourcePath.AbsoluteURI, targetPath.AbsoluteURI, true);
|
// //StoragePath sourcePath = this.CreateStoragePath(this.SourcePath);
|
||||||
// this.PrintTotals();
|
// //StoragePath targetPath = this.CreateValidTargetPath(sourcePath, this.TargetPath);
|
||||||
// ((StorageObjectRepository)repository).Changed -= new StorageObjectRepository.CopyOperationCompleteEventHandler(ListChanged);
|
// //IStorageObjectRepository repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
||||||
|
|
||||||
|
|
||||||
|
// //if (sourcePath.PathType == OpenStack.Common.PathType.Local && targetPath.PathType == OpenStack.Common.PathType.Remote)
|
||||||
|
// //{
|
||||||
|
// // long lastSegment = repository.GetLastSegmentId(targetPath);
|
||||||
|
// // if (lastSegment != 0)
|
||||||
|
// // {
|
||||||
|
// // Console.WriteLine("");
|
||||||
|
// // Console.WriteLine(" You've already uploaded a portion of this file.");
|
||||||
|
// // Console.WriteLine(" Would you like to resume your previous upload? [Y/N]");
|
||||||
|
// // ConsoleKeyInfo response = Console.ReadKey();
|
||||||
|
// // if (response.Key != ConsoleKey.Y)
|
||||||
|
// // {
|
||||||
|
// // repository.DeleteStorageObject(targetPath.AbsoluteURI + @"_temp\");
|
||||||
|
// // }
|
||||||
|
// // }
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //((StorageObjectRepository)repository).Changed += new StorageObjectRepository.CopyOperationCompleteEventHandler(ListChanged);
|
||||||
|
// //Console.WriteLine("");
|
||||||
|
// //repository.Copy(sourcePath.AbsoluteURI, targetPath.AbsoluteURI, true);
|
||||||
|
// //this.PrintTotals();
|
||||||
|
// //((StorageObjectRepository)repository).Changed -= new StorageObjectRepository.CopyOperationCompleteEventHandler(ListChanged);
|
||||||
// }
|
// }
|
||||||
////=========================================================================================
|
////=========================================================================================
|
||||||
///// <summary>
|
///// <summary>
|
||||||
@ -252,7 +283,7 @@
|
|||||||
////=========================================================================================
|
////=========================================================================================
|
||||||
// protected override void ProcessRecord()
|
// protected override void ProcessRecord()
|
||||||
// {
|
// {
|
||||||
// OSDriveInfo drive = this.SessionState.Drive.Current as OSDriveInfo;
|
// ObjectStoragePSDriveInfo drive = this.SessionState.Drive.Current as ObjectStoragePSDriveInfo;
|
||||||
// this.ProcessNonQueuedCopy();
|
// this.ProcessNonQueuedCopy();
|
||||||
// }
|
// }
|
||||||
// #endregion
|
// #endregion
|
||||||
|
@ -17,23 +17,13 @@ Echo ''
|
|||||||
$a.ForegroundColor = "gray"
|
$a.ForegroundColor = "gray"
|
||||||
Echo '========================================================================================'
|
Echo '========================================================================================'
|
||||||
$a.ForegroundColor = "yellow"
|
$a.ForegroundColor = "yellow"
|
||||||
Echo 'Welcome to the OpenStack Powershell Environment.'
|
Echo 'Welcome to the OpenStack Powershell Environment.11'
|
||||||
$a.ForegroundColor = "gray"
|
$a.ForegroundColor = "gray"
|
||||||
Echo '========================================================================================'
|
Echo '========================================================================================'
|
||||||
Echo ''
|
Echo ''
|
||||||
$a.ForegroundColor = "green"
|
$a.ForegroundColor = "green"
|
||||||
echo ' ==> Registering Providers...'
|
echo ' ==> Registering Providers...'
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
# ACTION REQUIRED! ==> Substitute the example CD commands path below to match your setup. This should be the final output of the Solution as dictated by the
|
|
||||||
# $(TargetDir) macro in the Post-Build Script.
|
|
||||||
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Save the current value in the $p variable.
|
#Save the current value in the $p variable.
|
||||||
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
|
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
|
||||||
|
|
||||||
@ -43,32 +33,9 @@ $p += ";C:\Users\tplummer\Documents\WindowsPowerShell\Modules\OpenStack\"
|
|||||||
#Add the paths in $p to the PSModulePath value.
|
#Add the paths in $p to the PSModulePath value.
|
||||||
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
|
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
|
||||||
|
|
||||||
|
import-module Openstack-Core -DisableNameChecking
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#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 Builds:
|
||||||
cd 1-3-4-5
|
|
||||||
|
|
||||||
#set-sp Rackspace
|
|
||||||
|
|
||||||
|
|
||||||
#cd OpenStack:
|
|
||||||
#cd Networks
|
|
||||||
#get-sp
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# Let the User know what's going on..
|
# Let the User know what's going on..
|
||||||
|
@ -9,7 +9,7 @@ PowerShellVersion="2.0"
|
|||||||
CLRVersion="4.0.30319"
|
CLRVersion="4.0.30319"
|
||||||
FormatsToProcess="OpenStack.format.ps1xml"
|
FormatsToProcess="OpenStack.format.ps1xml"
|
||||||
FileList='OpenStack.config'
|
FileList='OpenStack.config'
|
||||||
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
|
RequiredAssemblies = 'OpenStack.dll'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,22 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<appSettings>
|
<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>
|
<StorageManagement>
|
||||||
<add key="largeFileSize" value="314572800" />
|
<add key="largeFileSize" value="314572800" />
|
||||||
<add key="defSegmentNumber" value="16" />
|
<add key="defSegmentNumber" value="16" />
|
||||||
@ -27,29 +11,31 @@
|
|||||||
<add key="HttpTimeoutInterval" value="9200000" />
|
<add key="HttpTimeoutInterval" value="9200000" />
|
||||||
<add key="PasteGetURIResultsToClipboard" value="true" />
|
<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="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:\" />
|
<add key="NewReleaseFolder" value="e:\" />
|
||||||
<SharedContainers></SharedContainers>
|
|
||||||
</StorageManagement>
|
</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>
|
<ComputeServices>
|
||||||
<add key="LogReadAttemptsMax" value="20" />
|
<add key="LogReadAttemptsMax" value="20" />
|
||||||
<add key="LogReadAttemptIntervalInMilliSeconds" value="40000" />
|
<add key="LogReadAttemptIntervalInMilliSeconds" value="40000" />
|
||||||
<add key="EnableCredentialTracking" value="true" />
|
<add key="EnableCredentialTracking" value="true" />
|
||||||
<add key="SSHClientPath" value="C:\Users\tplummer\Desktop\Utilities\Putty.exe" />
|
<add key="SSHClientPath" value="C:\Users\tplummer\Desktop\Utilities\Putty.exe" />
|
||||||
</ComputeServices>
|
</ComputeServices>
|
||||||
<AvailabilityZones>
|
<IdentityServices>
|
||||||
<AvailabilityZone id="1" isDefault="True" name="region-a.geo-1" shellForegroundColor="Green" />
|
<ServiceProvider name="" isDefault = "true">
|
||||||
<AvailabilityZone id="2" isDefault="False" name="region-b.geo-1" shellForegroundColor="Green" />
|
<add key="AuthenticationServiceURI" value="" displayName="Authentication Service URI" helpText ="" isMandatory="True"/>
|
||||||
</AvailabilityZones>
|
<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"/>
|
||||||
|
<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>
|
||||||
|
<ServiceMaps>
|
||||||
|
<ServiceMap source="ObjectStorage" target="Object Storage"/>
|
||||||
|
<ServiceMap source="ImageManagement" target="Image Management"/>
|
||||||
|
<ServiceMap source="BlockStorage" target="Block Storage"/>
|
||||||
|
<ServiceMap source="Compute" target="Compute"/>
|
||||||
|
</ServiceMaps>
|
||||||
|
</ServiceProvider>
|
||||||
|
</IdentityServices>
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
@ -21,7 +21,7 @@
|
|||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core\</OutputPath>
|
<OutputPath>..\..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core\</OutputPath>
|
||||||
<DefineConstants>DEBUG</DefineConstants>
|
<DefineConstants>DEBUG</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
@ -64,7 +64,11 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Newtonsoft.Json.6.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OpenStack, Version=0.9.1.0, Culture=neutral, PublicKeyToken=baf191d8aca7391c, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\OpenStack-SDK-DotNet.0.9.1.0\lib\net40\OpenStack.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.ComponentModel.Composition" />
|
<Reference Include="System.ComponentModel.Composition" />
|
||||||
@ -75,7 +79,14 @@
|
|||||||
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Net.Http.Extensions">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
|
<Reference Include="System.Net.Http.Primitives">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.Security" />
|
<Reference Include="System.Security" />
|
||||||
<Reference Include="System.ServiceModel" />
|
<Reference Include="System.ServiceModel" />
|
||||||
@ -90,7 +101,6 @@
|
|||||||
<Reference Include="XamlBuildTask" />
|
<Reference Include="XamlBuildTask" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BaseNavigationCmdletProvider.cs" />
|
|
||||||
<Compile Include="Cmdlets\BasePSCmdlet.cs" />
|
<Compile Include="Cmdlets\BasePSCmdlet.cs" />
|
||||||
<Compile Include="Cmdlets\Common\BaseAuthenticationCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\BaseAuthenticationCmdlet.cs" />
|
||||||
<Compile Include="Cmdlets\Common\BasePSCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\BasePSCmdlet.cs" />
|
||||||
@ -100,7 +110,13 @@
|
|||||||
<Compile Include="Cmdlets\Common\GetZoneCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\GetZoneCmdlet.cs" />
|
||||||
<Compile Include="Cmdlets\Common\GetZonesCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\GetZonesCmdlet.cs" />
|
||||||
<Compile Include="Cmdlets\Common\SetConfigCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\SetConfigCmdlet.cs" />
|
||||||
|
<Compile Include="Cmdlets\Common\SetZoneCmdlet.cs" />
|
||||||
|
<Compile Include="Cmdlets\Common\TokenTestCmdlet.cs" />
|
||||||
|
<Compile Include="Providers\Common\BaseNavigationCmdletProvider.cs" />
|
||||||
|
<Compile Include="Providers\Common\CommonDriveInfo.cs" />
|
||||||
|
<Compile Include="Providers\Common\CommonDriveParameters.cs" />
|
||||||
<Compile Include="Utility\AccountCapabilities.cs" />
|
<Compile Include="Utility\AccountCapabilities.cs" />
|
||||||
|
<Compile Include="Utility\AvailabilityZone.cs" />
|
||||||
<Compile Include="Utility\CredentialElement.cs" />
|
<Compile Include="Utility\CredentialElement.cs" />
|
||||||
<Compile Include="Cmdlets\Common\GetServiceProvidersCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\GetServiceProvidersCmdlet.cs" />
|
||||||
<Compile Include="Cmdlets\Common\NewServiceProviderCmdlet.cs" />
|
<Compile Include="Cmdlets\Common\NewServiceProviderCmdlet.cs" />
|
||||||
@ -111,30 +127,36 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Providers\ObjectStorage\StorageItemViewModel.cs" />
|
<Compile Include="Providers\ObjectStorage\StorageItemViewModel.cs" />
|
||||||
<Compile Include="Utility\CredentialManager.cs" />
|
<Compile Include="Utility\CredentialManager.cs" />
|
||||||
<Compile Include="Providers\ObjectStorage\HPOSDriveInfo.cs" />
|
<Compile Include="Providers\ObjectStorage\ObjectStoragePSDriveInfo.cs" />
|
||||||
<Compile Include="Providers\ObjectStorage\HPOSDriveParameters.cs" />
|
<Compile Include="Providers\ObjectStorage\ObjectStorageDriveParameters.cs" />
|
||||||
<Compile Include="Providers\ObjectStorage\HPOSNavigationProvider.cs" />
|
<Compile Include="Providers\ObjectStorage\ObjectStorageNavigationProvider.cs" />
|
||||||
<Compile Include="Utility\Context.cs" />
|
<Compile Include="Utility\Context.cs" />
|
||||||
<Compile Include="Utility\Enums.cs" />
|
<Compile Include="Utility\Enums.cs" />
|
||||||
<Compile Include="Utility\ExtensionManager.cs" />
|
<Compile Include="Utility\ExtensionManager.cs" />
|
||||||
|
<Compile Include="Providers\ObjectStorage\ObjectStorageDriveConverter.cs" />
|
||||||
|
<Compile Include="Utility\ExtensionMethods.cs" />
|
||||||
<Compile Include="Utility\OpenstackCoreRegistrationManager.cs" />
|
<Compile Include="Utility\OpenstackCoreRegistrationManager.cs" />
|
||||||
<Compile Include="Utility\RegistrationManager.cs" />
|
<Compile Include="Utility\RegistrationManager.cs" />
|
||||||
<Compile Include="Utility\RegistrationResponse.cs" />
|
<Compile Include="Utility\RegistrationResponse.cs" />
|
||||||
<Compile Include="Utility\SecureStringHelper.cs" />
|
<Compile Include="Utility\SecureStringHelper.cs" />
|
||||||
|
<Compile Include="Utility\ServiceMap.cs" />
|
||||||
<Compile Include="Utility\ServiceProvider.cs" />
|
<Compile Include="Utility\ServiceProvider.cs" />
|
||||||
<Compile Include="Utility\ConfigurationManager.cs" />
|
<Compile Include="Utility\ConfigurationManager.cs" />
|
||||||
|
<Compile Include="Utility\ServiceProviderAttribute.cs" />
|
||||||
<Compile Include="Utility\Settings.cs" />
|
<Compile Include="Utility\Settings.cs" />
|
||||||
<Compile Include="Utility\StoragePath.cs" />
|
<Compile Include="Utility\StoragePath.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</None>
|
||||||
|
<None Include="Deployment\NavigationGraph.dgml" />
|
||||||
<None Include="Deployment\Openstack.config">
|
<None Include="Deployment\Openstack.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="Deployment\DevProfile.ps1" />
|
<None Include="Deployment\DevProfile.ps1" />
|
||||||
<None Include="Deployment\PostBuild.bat" />
|
<None Include="Deployment\PostBuild.bat" />
|
||||||
<None Include="Deployment\ScratchPad\app.config" />
|
|
||||||
<None Include="Deployment\Openstack.config.example">
|
<None Include="Deployment\Openstack.config.example">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
@ -148,12 +170,6 @@
|
|||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="Deployment\PostBuild.example" />
|
<None Include="Deployment\PostBuild.example" />
|
||||||
<None Include="Deployment\ScratchPad\PostBuild.targets">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="Deployment\ScratchPad\ProCLI.config">
|
|
||||||
<SubType>Designer</SubType>
|
|
||||||
</None>
|
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<Resource Include="Deployment\powershell.exe.config">
|
<Resource Include="Deployment\powershell.exe.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@ -171,7 +187,6 @@
|
|||||||
<Folder Include="Cmdlets\Security\" />
|
<Folder Include="Cmdlets\Security\" />
|
||||||
<Folder Include="Migrations\" />
|
<Folder Include="Migrations\" />
|
||||||
<Folder Include="Providers\BlockStorage\" />
|
<Folder Include="Providers\BlockStorage\" />
|
||||||
<Folder Include="Providers\Common\" />
|
|
||||||
<Folder Include="Providers\Compute\" />
|
<Folder Include="Providers\Compute\" />
|
||||||
<Folder Include="Providers\Dbaas\" />
|
<Folder Include="Providers\Dbaas\" />
|
||||||
<Folder Include="Providers\Networking\" />
|
<Folder Include="Providers\Networking\" />
|
||||||
@ -181,13 +196,11 @@
|
|||||||
<Content Include="Deployment\Aliases.txt">
|
<Content Include="Deployment\Aliases.txt">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Deployment\ScratchPad\AnotherTest.txt">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
<Content Include="Deployment\ApacheLicense.txt" />
|
<Content Include="Deployment\ApacheLicense.txt" />
|
||||||
<Content Include="Deployment\CredentialList.xml">
|
<Content Include="Deployment\CredentialList.xml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Deployment\NavigationGraph.txt" />
|
||||||
<Content Include="Deployment\Openstack.Client.Powershell.dll-Help.xml">
|
<Content Include="Deployment\Openstack.Client.Powershell.dll-Help.xml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
@ -202,7 +215,7 @@
|
|||||||
<Content Include="Deployment\ScratchPad\ServerData\Server1.xml" />
|
<Content Include="Deployment\ScratchPad\ServerData\Server1.xml" />
|
||||||
<Content Include="Deployment\ScratchPad\ServerData\Servers.xml" />
|
<Content Include="Deployment\ScratchPad\ServerData\Servers.xml" />
|
||||||
<Content Include="License.txt" />
|
<Content Include="License.txt" />
|
||||||
<None Include="Deployment\Openstack.psd1">
|
<None Include="Deployment\Openstack-Core.psd1">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<None Include="Deployment\ReleaseNotes.xml">
|
<None Include="Deployment\ReleaseNotes.xml">
|
||||||
@ -213,12 +226,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WCFMetadata Include="Service References\" />
|
<WCFMetadata Include="Service References\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\openstack-sdk-dotnet\Openstack\Openstack\Openstack.csproj">
|
|
||||||
<Project>{b2c92371-b62b-45a2-adeb-edebefa3a75c}</Project>
|
|
||||||
<Name>Openstack</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!--<PropertyGroup>
|
<!--<PropertyGroup>
|
||||||
<SlowCheetahTargets Condition=" '$(SlowCheetahTargets)'=='' ">$(LOCALAPPDATA)\Microsoft\MSBuild\SlowCheetah\v1\SlowCheetah.Transforms.targets</SlowCheetahTargets>
|
<SlowCheetahTargets Condition=" '$(SlowCheetahTargets)'=='' ">$(LOCALAPPDATA)\Microsoft\MSBuild\SlowCheetah\v1\SlowCheetah.Transforms.targets</SlowCheetahTargets>
|
||||||
@ -231,10 +238,36 @@
|
|||||||
Echo Executing Post-Build Scripts
|
Echo Executing Post-Build Scripts
|
||||||
Echo =====================
|
Echo =====================
|
||||||
|
|
||||||
|
md %25USERPROFILE%25\Documents\WindowsPowerShell
|
||||||
|
md %25USERPROFILE%25\Documents\WindowsPowerShell\Modules
|
||||||
|
md %25USERPROFILE%25\Documents\WindowsPowerShell\Modules\Openstack
|
||||||
|
md %25USERPROFILE%25\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core
|
||||||
|
md %25USERPROFILE%25\Documents\OS
|
||||||
|
md $(ProjectDir)bin\debug
|
||||||
|
|
||||||
|
copy $(ProjectDir)\Deployment\*.* %25USERPROFILE%25\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core
|
||||||
|
copy $(ProjectDir)\Deployment\DevProfile.ps1 %25USERPROFILE%25\Documents\WindowsPowerShell\Microsoft.Powershell_profile.ps1
|
||||||
|
copy $(ProjectDir)\Deployment\Openstack.config %25USERPROFILE%25\Documents\OS\Openstack.config
|
||||||
|
|
||||||
|
|
||||||
|
echo 'Proj Dir = ' + $(ProjectDir)
|
||||||
|
echo 'userProfile = ' + %25USERPROFILE%25
|
||||||
|
|
||||||
|
|
||||||
|
echo copy C:\Users\tplummer\Source\Repos\FixIt\openstack-cli-powershell\Openstack.Client.Powershell\Deployment\Openstack.config %25USERPROFILE%25\Documents\OS\Openstack.config
|
||||||
|
|
||||||
|
|
||||||
|
Echo The statement below is causing symbol mismatches when attaching the debugger remotely. For now, you should point this projects output folder
|
||||||
|
Echo to the correct runtime location. That is C:\Users\username\Documents\WindowsPowerShell\Modules\Openstack\Openstack-Core
|
||||||
|
Echo ' copy $(ProjectDir)bin\debug\*.* %25USERPROFILE%25\Documents\WindowsPowershell\Modules\Openstack\openstack-core
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -250,4 +283,9 @@ copy C:\Users\tplummer\Source\Repos\openstack-cli-powershell\Openstack.Client.Po
|
|||||||
<PreBuildEvent>
|
<PreBuildEvent>
|
||||||
</PreBuildEvent>
|
</PreBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||||
|
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||||
|
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||||
|
</Target>
|
||||||
</Project>
|
</Project>
|
@ -1,4 +1,5 @@
|
|||||||
/* ============================================================================
|
|
||||||
|
/* ============================================================================
|
||||||
Copyright 2014 Hewlett Packard
|
Copyright 2014 Hewlett Packard
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -16,40 +17,30 @@ limitations under the License.
|
|||||||
using System;
|
using System;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using System.Management.Automation.Provider;
|
using System.Management.Automation.Provider;
|
||||||
using Openstack.Objects.DataAccess;
|
|
||||||
using Openstack.Common.Properties;
|
|
||||||
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.Objects.Utility;
|
|
||||||
using Openstack.Objects.Domain.Admin;
|
|
||||||
using Openstack.Objects.DataAccess.Security;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
using OpenStack.Client.Powershell.Utility;
|
||||||
|
using System.Linq;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace Openstack.Client.Powershell.Providers.Common
|
namespace OpenStack.Client.Powershell.Providers.Common
|
||||||
{
|
{
|
||||||
public class BaseNavigationCmdletProvider : NavigationCmdletProvider
|
public class BaseNavigationCmdletProvider : NavigationCmdletProvider
|
||||||
{
|
{
|
||||||
static BaseRepositoryFactory _repositoryFactory;
|
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
protected BaseRepositoryFactory RepositoryFactory
|
protected OpenStackClient CoreClient
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return (BaseRepositoryFactory)this.SessionState.PSVariable.Get("BaseRepositoryFactory").Value;
|
return (OpenStackClient)this.SessionState.PSVariable.Get("CoreClient").Value;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
this.SessionState.PSVariable.Set(new PSVariable("BaseRepositoryFactory", value));
|
this.SessionState.PSVariable.Set(new PSVariable("CoreClient", value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -109,7 +100,7 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\CLI.config";
|
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,14 +109,29 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
private void SetZoneColor()
|
private void SetZoneColor(ServiceProvider provider)
|
||||||
{
|
{
|
||||||
string configFilePath = this.ConfigFilePath;
|
// We don't throw a critical exception if this operation fails..
|
||||||
XDocument doc = XDocument.Load(configFilePath);
|
|
||||||
XElement defaultZoneNode = doc.XPathSelectElement("//AvailabilityZone[@isDefault='True']");
|
AvailabilityZone defZone = provider.AvailabilityZones.Where(z => z.IsDefault == true).DefaultIfEmpty(null).FirstOrDefault();
|
||||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defaultZoneNode.Attribute("shellForegroundColor").Value);
|
if (defZone == null) return;
|
||||||
this.Host.UI.RawUI.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defaultZoneNode.Attribute("shellForegroundColor").Value);
|
|
||||||
this.Context.Forecolor = defaultZoneNode.Attribute("shellForegroundColor").Value;
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defZone.ShellForegroundColor);
|
||||||
|
this.Host.UI.RawUI.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defZone.ShellForegroundColor);
|
||||||
|
this.Context.Forecolor = defZone.ShellForegroundColor;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="service"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected T CreateServiceClient<T>(CoreServices service) where T : IOpenStackServiceClient
|
||||||
|
{
|
||||||
|
ServiceProvider provider = this.Context.CurrentServiceProvider;
|
||||||
|
return this.CoreClient.CreateServiceClientByName<T>(provider.ServiceMaps.TranslateServiceName(service));
|
||||||
}
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -134,35 +140,28 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
protected void InitializeSession()
|
protected void InitializeSession()
|
||||||
{
|
{
|
||||||
if (!IsContextInitialized())
|
ConfigurationManager configManager = new ConfigurationManager();
|
||||||
|
ExtensionManager extensionManager = new ExtensionManager(this.SessionState, this.Context);
|
||||||
|
configManager.Load();
|
||||||
|
|
||||||
|
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
||||||
|
|
||||||
|
if (provider.Name == String.Empty && provider.IsDefault == true)
|
||||||
{
|
{
|
||||||
Context context = new Context();
|
// Technically Core is already loaded (you're in it :) but this signs in for you to the ServiceProvider selected..
|
||||||
CredentialManager manager = new CredentialManager(false);
|
// This is just used in the case where it's the Users first time loading the CLI..
|
||||||
AuthenticationRequest request = manager.BuildAuthenticationRequest();
|
|
||||||
|
|
||||||
if (request != null)
|
extensionManager.LoadCore(provider);
|
||||||
{
|
|
||||||
KeystoneAuthProvider authProvider = new KeystoneAuthProvider();
|
|
||||||
AuthenticationResponse response = authProvider.Authenticate(request);
|
|
||||||
|
|
||||||
context.ServiceCatalog = response.ServiceCatalog;
|
|
||||||
context.Settings = Settings.Default;
|
|
||||||
|
|
||||||
context.AccessToken = response.Token;
|
|
||||||
context.ProductName = "Openstack-WinCLI";
|
|
||||||
context.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
||||||
|
|
||||||
this.SessionState.PSVariable.Set(new PSVariable("Context", context));
|
|
||||||
this.SessionState.PSVariable.Set(new PSVariable("BaseRepositoryFactory", new BaseRepositoryFactory(context)));
|
|
||||||
this.SetZoneColor();
|
|
||||||
|
|
||||||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
|
||||||
//string currentVersion = "1.4.0.0";
|
|
||||||
UpdateManager updateManager = new UpdateManager(this.Context, currentVersion, this.RepositoryFactory);
|
|
||||||
updateManager.ProcessUpdateCheck();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
{
|
||||||
|
// Load any extensions that were supplied by the ServiceProvider...
|
||||||
|
|
||||||
|
extensionManager.LoadExtension(provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.SetZoneColor(provider);
|
||||||
|
}
|
||||||
#region Implementation of DriveCmdletProvider
|
#region Implementation of DriveCmdletProvider
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -176,57 +175,6 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
}
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T"></typeparam>
|
|
||||||
/// <param name="graph"></param>
|
|
||||||
/// <param name="path"></param>
|
|
||||||
//==================================================================================================
|
|
||||||
protected void WriteJSON<T> (T graph, string path)
|
|
||||||
{
|
|
||||||
MemoryStream stream = new MemoryStream();
|
|
||||||
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(T));
|
|
||||||
ser.WriteObject(stream, graph);
|
|
||||||
|
|
||||||
string retValue = Encoding.Default.GetString(stream.ToArray());
|
|
||||||
WriteItemObject(retValue, path, false);
|
|
||||||
WriteItemObject("", path, false);
|
|
||||||
}
|
|
||||||
//==================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
/// Writes out the files represented as StorageObjects for the supplied path.
|
|
||||||
/// </summary>
|
|
||||||
//==================================================================================================
|
|
||||||
protected void WriteXML<T>(T graph, string path)
|
|
||||||
{
|
|
||||||
XmlTextWriter xtw = null;
|
|
||||||
MemoryStream stream = new MemoryStream();
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
XmlDocument document = new XmlDocument();
|
|
||||||
StringWriter writer = null;
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(T));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
serializer.Serialize(stream, graph);
|
|
||||||
stream.Position = 0;
|
|
||||||
document.Load(stream);
|
|
||||||
|
|
||||||
writer = new StringWriter(builder);
|
|
||||||
xtw = new XmlTextWriter(writer);
|
|
||||||
xtw.Formatting = Formatting.Indented;
|
|
||||||
|
|
||||||
document.WriteTo(xtw);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
xtw.Close();
|
|
||||||
}
|
|
||||||
WriteItemObject(builder.ToString(), path, false);
|
|
||||||
WriteItemObject("", path, false);
|
|
||||||
}
|
|
||||||
//==================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the user decides to delete a KVSDrive.
|
/// Called when the user decides to delete a KVSDrive.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="drive"></param>
|
/// <param name="drive"></param>
|
||||||
@ -274,30 +222,7 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
//==================================================================================================
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
//==================================================================================================
|
|
||||||
protected ResponseFormat ResponseFormat
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return (ResponseFormat)this.SessionState.PSVariable.Get("ResponseFormat").Value;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
PSVariable variable = new PSVariable("ResponseFormat");
|
|
||||||
variable.Value = ResponseFormat.data;
|
|
||||||
|
|
||||||
this.SessionState.PSVariable.Set(variable);
|
|
||||||
return ResponseFormat.data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This test should not verify the existance of the item at the path.
|
/// This test should not verify the existance of the item at the path.
|
||||||
|
@ -16,8 +16,6 @@ limitations under the License.
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Management.Automation;
|
using System.Management.Automation;
|
||||||
using Openstack.Objects.DataAccess;
|
|
||||||
using Openstack.Common.DataAccess;
|
|
||||||
using Openstack.Client.Powershell.Providers.Common;
|
using Openstack.Client.Powershell.Providers.Common;
|
||||||
|
|
||||||
namespace Openstack.Client.Powershell.Providers.Common
|
namespace Openstack.Client.Powershell.Providers.Common
|
||||||
@ -25,61 +23,62 @@ namespace Openstack.Client.Powershell.Providers.Common
|
|||||||
public class CommonDriveInfo : PSDriveInfo
|
public class CommonDriveInfo : PSDriveInfo
|
||||||
{
|
{
|
||||||
private CommonDriveParameters _parameters = null;
|
private CommonDriveParameters _parameters = null;
|
||||||
private BaseUIContainer _currentContainer = null;
|
//private BaseUIContainer _currentContainer = null;
|
||||||
|
|
||||||
#region Ctors
|
#region Ctors
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="driveInfo"></param>
|
/// <param name="driveInfo"></param>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public CommonDriveInfo(PSDriveInfo driveInfo, CommonDriveParameters parameters) : base (driveInfo)
|
public CommonDriveInfo(PSDriveInfo driveInfo, CommonDriveParameters parameters)
|
||||||
|
: base(driveInfo)
|
||||||
{
|
{
|
||||||
_parameters = parameters;
|
_parameters = parameters;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Methods
|
#region Methods
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public Hashtable GetParameters()
|
public Hashtable GetParameters()
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Properties
|
#region Properties
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public BaseUIContainer CurrentTenant
|
//public BaseUIContainer CurrentTenant
|
||||||
{
|
//{
|
||||||
get { return _currentContainer; }
|
// get { return _currentContainer; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_currentContainer = value;
|
// _currentContainer = value;
|
||||||
this.CurrentLocation = _currentContainer.Path;
|
// this.CurrentLocation = _currentContainer.Path;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public BaseUIContainer CurrentContainer
|
//public BaseUIContainer CurrentContainer
|
||||||
{
|
//{
|
||||||
get { return _currentContainer; }
|
// get { return _currentContainer; }
|
||||||
set
|
// set
|
||||||
{
|
// {
|
||||||
_currentContainer = value;
|
// _currentContainer = value;
|
||||||
this.CurrentLocation = _currentContainer.Path;
|
// this.CurrentLocation = _currentContainer.Path;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,159 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Management.Automation;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
using OpenStack;
|
||||||
|
using OpenStack.Client.Powershell.Providers.Storage;
|
||||||
|
using OpenStack.Client.Powershell.Utility;
|
||||||
|
using OpenStack.Storage;
|
||||||
|
|
||||||
|
namespace OpenStack.Client.Powershell.Providers.Storage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class is responsible for Converting the Users current set of Storage Containers into PSDrives..
|
||||||
|
/// </summary>
|
||||||
|
public class ObjectStorageDriveConverter
|
||||||
|
{
|
||||||
|
private Context _context;
|
||||||
|
private ProviderInfo _providerInfo;
|
||||||
|
private IOpenStackClient _client;
|
||||||
|
private SessionState _sessionState;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private SessionState SessionState
|
||||||
|
{
|
||||||
|
get { return _sessionState; }
|
||||||
|
set { _sessionState = value; }
|
||||||
|
}
|
||||||
|
private IOpenStackClient CoreClient
|
||||||
|
{
|
||||||
|
get { return _client; }
|
||||||
|
set { _client = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private Context Context
|
||||||
|
{
|
||||||
|
get { return _context; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProviderInfo ProviderInfo
|
||||||
|
{
|
||||||
|
get { return _providerInfo; }
|
||||||
|
set { _providerInfo = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Ctors
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="providerInfo"></param>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
public ObjectStorageDriveConverter(Context context, ProviderInfo providerInfo, IOpenStackClient client)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
_providerInfo = providerInfo;
|
||||||
|
_client = client;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="service"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected T CreateServiceClient<T>(CoreServices service) where T : IOpenStackServiceClient
|
||||||
|
{
|
||||||
|
ServiceProvider provider = this.Context.CurrentServiceProvider;
|
||||||
|
return this.CoreClient.CreateServiceClientByName<T>(provider.ServiceMaps.TranslateServiceName(service));
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
public System.Collections.ObjectModel.Collection<PSDriveInfo> ConvertContainers()
|
||||||
|
{
|
||||||
|
IEnumerable<StorageContainer> storageContainers = null;
|
||||||
|
var parameters = new ObjectStorageDriveParameters();
|
||||||
|
|
||||||
|
if (this.Context != null && this.Context.Settings != null) {
|
||||||
|
parameters.Settings = this.Context.Settings;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new NullReferenceException("Context and/or Settings");
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.CoreClient.SetRegion(this.Context.CurrentRegion);
|
||||||
|
Task<StorageAccount> getAccountTask = this.CreateServiceClient<IStorageServiceClient>(CoreServices.ObjectStorage).GetStorageAccount();
|
||||||
|
getAccountTask.Wait();
|
||||||
|
storageContainers = getAccountTask.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 serviceName = this.Context.CurrentServiceProvider.ServiceMaps.TranslateServiceName(CoreServices.ObjectStorage);
|
||||||
|
string publicStoreUrl = this.Context.ServiceCatalog.GetPublicEndpoint(serviceName, this.Context.CurrentRegion).ToString();
|
||||||
|
|
||||||
|
if (storageContainers.Count() > 0)
|
||||||
|
{
|
||||||
|
foreach (StorageContainer storageContainer in storageContainers)
|
||||||
|
{
|
||||||
|
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, this.ProviderInfo, "/", "Root folder for your storageContainer", null);
|
||||||
|
ObjectStoragePSDriveInfo kvsDriveInfo = new ObjectStoragePSDriveInfo(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 ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
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 OpenStack.Client.Powershell.Utility;
|
||||||
|
|
||||||
|
namespace OpenStack.Client.Powershell.Providers.Storage
|
||||||
|
{
|
||||||
|
public class ObjectStorageDriveParameters
|
||||||
|
{
|
||||||
|
private Settings _settings;
|
||||||
|
|
||||||
|
public Settings Settings
|
||||||
|
{
|
||||||
|
get { return _settings; }
|
||||||
|
set { _settings = value; }
|
||||||
|
}
|
||||||
|
#region Ctors
|
||||||
|
//=================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="settings"></param>
|
||||||
|
//=================================================================================
|
||||||
|
public ObjectStorageDriveParameters()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
745
Openstack.Client.Powershell/Providers/ObjectStorage/ObjectStorageNavigationProvider.cs
Normal file
745
Openstack.Client.Powershell/Providers/ObjectStorage/ObjectStorageNavigationProvider.cs
Normal file
@ -0,0 +1,745 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
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.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 System.Management.Automation.Runspaces;
|
||||||
|
using OpenStack;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Threading;
|
||||||
|
using OpenStack.Client.Powershell.Providers.ObjectStorage;
|
||||||
|
using System.Diagnostics.Contracts;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
|
namespace OpenStack.Client.Powershell.Providers.Storage
|
||||||
|
{
|
||||||
|
[CmdletProvider("Object Storage", ProviderCapabilities.ExpandWildcards)]
|
||||||
|
public class ObjectStorageNavigationProvider : BaseNavigationCmdletProvider
|
||||||
|
{
|
||||||
|
const string cDelimiter = @"\";
|
||||||
|
const string cFolderMarker = "folder.txt";
|
||||||
|
|
||||||
|
private class FolderStatistics
|
||||||
|
{
|
||||||
|
public long TotalFilesFound = 0;
|
||||||
|
public long TotalBytes = 0;
|
||||||
|
public long TotalFoldersFound = 0;
|
||||||
|
}
|
||||||
|
private IStorageServiceClient _storageClient;
|
||||||
|
|
||||||
|
#region Implementation of DriveCmdletProvider
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Removes an Item from the store..
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override void ClearItem(string path)
|
||||||
|
{
|
||||||
|
base.ClearItem(path);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private string StorageServiceURL
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.Drive == null || this.Drive.SharePath == null) {
|
||||||
|
string serviceName = this.Context.CurrentServiceProvider.ServiceMaps.TranslateServiceName(CoreServices.ObjectStorage);
|
||||||
|
return this.Context.ServiceCatalog.GetPublicEndpoint(serviceName, this.Context.CurrentRegion).ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return this.Drive.SharePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
public System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo)
|
||||||
|
{
|
||||||
|
Contract.Assert(settings != null);
|
||||||
|
|
||||||
|
IEnumerable<StorageContainer> storageContainers = null;
|
||||||
|
ObjectStorageDriveParameters parameters = new ObjectStorageDriveParameters();
|
||||||
|
|
||||||
|
if (this.Settings != null) {
|
||||||
|
parameters.Settings = this.Settings;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parameters.Settings = settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Get a list of Storage Containers...
|
||||||
|
|
||||||
|
Task<IEnumerable<StorageContainer>> getContainersTask = this.CreateServiceClient<IStorageServiceClient>(CoreServices.ObjectStorage).ListStorageContainers();
|
||||||
|
getContainersTask.Wait();
|
||||||
|
storageContainers = getContainersTask.Result;
|
||||||
|
}
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
ObjectStoragePSDriveInfo kvsDriveInfo = new ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL);
|
||||||
|
//kvsDriveInfo.SharePath = storageContainer.SharePath;
|
||||||
|
drives.Add(kvsDriveInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.ProviderInfo, "/", "Root folder for your storageContainer", null);
|
||||||
|
return new Collection<PSDriveInfo>
|
||||||
|
{
|
||||||
|
new ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return drives;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private void SetDefaultDrive()
|
||||||
|
{
|
||||||
|
Runspace runSpace = Runspace.DefaultRunspace;
|
||||||
|
runSpace.Open();
|
||||||
|
Pipeline pipeline = runSpace.CreatePipeline();
|
||||||
|
Command setDefaultDriveCmd = new Command("Set-Location OS-Init:");
|
||||||
|
pipeline.Commands.Add(setDefaultDriveCmd);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private Collection<PSDriveInfo> CreateDefaultDrive(ObjectStorageDriveParameters parameters)
|
||||||
|
{
|
||||||
|
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 ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// This is called when the CLIManifest.psd1 is registered with the Import-Module cmdlet.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override System.Collections.ObjectModel.Collection<PSDriveInfo> InitializeDefaultDrives()
|
||||||
|
{
|
||||||
|
Thread.Sleep(new TimeSpan(0, 0, 0, 5, 0));
|
||||||
|
|
||||||
|
this.InitializeSession();
|
||||||
|
|
||||||
|
if (this.Context.ServiceCatalog.Exists(this.ProviderInfo.Name))
|
||||||
|
{
|
||||||
|
IEnumerable<StorageContainer> storageContainers = null;
|
||||||
|
ObjectStorageDriveParameters parameters = new ObjectStorageDriveParameters();
|
||||||
|
var storageServiceClient = this.CreateServiceClient<IStorageServiceClient>(CoreServices.ObjectStorage);
|
||||||
|
Task<StorageAccount> accountTask = storageServiceClient.GetStorageAccount();
|
||||||
|
|
||||||
|
accountTask.Wait();
|
||||||
|
StorageAccount account = accountTask.Result;
|
||||||
|
storageContainers = account.Containers;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if (storageContainers != null)
|
||||||
|
{
|
||||||
|
if (storageContainers.Count() == 1 && storageContainers.First().Name == string.Empty)
|
||||||
|
{
|
||||||
|
return this.CreateDefaultDrive(parameters);
|
||||||
|
}
|
||||||
|
parameters.Settings = this.Settings;
|
||||||
|
|
||||||
|
foreach (StorageContainer storageContainer in storageContainers)
|
||||||
|
{
|
||||||
|
PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, this.ProviderInfo, "/", "Root folder for your storageContainer", null);
|
||||||
|
ObjectStoragePSDriveInfo kvsDriveInfo = new ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, this.StorageServiceURL);
|
||||||
|
//kvsDriveInfo.SharePath = storageContainer.SharePath;
|
||||||
|
drives.Add(kvsDriveInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.CreateDefaultDrive(parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
WriteDebug("Exception : HPOSNavigationProvider.InitializeDefaultDrives");
|
||||||
|
WriteDebug(ex.Message);
|
||||||
|
this.WriteError(new ErrorRecord(ex, "1", ErrorCategory.InvalidArgument, this));
|
||||||
|
}
|
||||||
|
return drives;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=======================================================================================================
|
||||||
|
public bool ContainsWildcard(string path)
|
||||||
|
{
|
||||||
|
if (path.Contains("?") || path.Contains("*") || path.Contains("[") || path.Contains("]"))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=======================================================================================================
|
||||||
|
private string GetContainerName(string path)
|
||||||
|
{
|
||||||
|
return this.Drive.Name;
|
||||||
|
|
||||||
|
if (path == "//")
|
||||||
|
{
|
||||||
|
return this.Drive.Name;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves a StorageObject with a fully qualified path from the User.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private IEnumerable<StorageItemViewModel> GetStorageObjects(string path)
|
||||||
|
{
|
||||||
|
List<StorageItemViewModel> modelViewItems = new List<StorageItemViewModel>();
|
||||||
|
Task<StorageFolder> listStorageObjectTask;
|
||||||
|
string folderName = null;
|
||||||
|
|
||||||
|
if (path != @"\" && !path.EndsWith(@"\"))
|
||||||
|
path = path + @"\";
|
||||||
|
|
||||||
|
StoragePath storagePath = this.CreateStoragePath(path);
|
||||||
|
var client = this.CreateServiceClient<IStorageServiceClient>(CoreServices.ObjectStorage);
|
||||||
|
|
||||||
|
if (path == "\\") {
|
||||||
|
folderName = "/";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
folderName = path.Replace(@"\", "/").TrimStart('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
listStorageObjectTask = client.GetStorageFolder(this.GetContainerName(path), folderName);
|
||||||
|
listStorageObjectTask.Wait();
|
||||||
|
foreach (StorageItem item in listStorageObjectTask.Result.Objects.Union<StorageItem>(listStorageObjectTask.Result.Folders))
|
||||||
|
{
|
||||||
|
StorageItemViewModel modelView = new StorageItemViewModel(item);
|
||||||
|
modelViewItems.Add(modelView);
|
||||||
|
}
|
||||||
|
return modelViewItems;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private void WriteData(IEnumerable<StorageItemViewModel> storageItemViewModel, string path, WildcardPattern pattern = null)
|
||||||
|
{
|
||||||
|
FolderStatistics statistics = new FolderStatistics();
|
||||||
|
bool doesExist = false;
|
||||||
|
|
||||||
|
if (storageItemViewModel.Count() > 0 || storageItemViewModel == null)
|
||||||
|
{
|
||||||
|
// Write out any files that we find within this particular folder..
|
||||||
|
|
||||||
|
statistics = this.WriteFiles(storageItemViewModel, path);
|
||||||
|
doesExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//List<StorageItem> folders = storageObjects.Where(so => so.Name.EndsWith(@"\")).ToList<StorageItem>();
|
||||||
|
|
||||||
|
List<StorageItemViewModel> folders = storageItemViewModel.Where(so => so.Type == "Folder").ToList<StorageItemViewModel>();
|
||||||
|
|
||||||
|
// List<StorageObject> folders = storageObjects.Where(so => so.StorageObjectType == StorageObjectType.Folder).ToList<StorageObject>();
|
||||||
|
|
||||||
|
if (folders != null)
|
||||||
|
{
|
||||||
|
// Now we'll write out any decendant folders found within the current directory..
|
||||||
|
|
||||||
|
this.WriteFolders(folders, ref statistics);
|
||||||
|
doesExist = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally write out the summary folder stats section of the command..
|
||||||
|
|
||||||
|
if (doesExist)
|
||||||
|
{
|
||||||
|
this.WriteFolderStatistics(statistics);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("No files or folders found.");
|
||||||
|
Console.WriteLine("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Writes out the files represented as StorageObjects for the supplied path.
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private FolderStatistics WriteFiles(IEnumerable<StorageItemViewModel> storageObjects, string path)
|
||||||
|
{
|
||||||
|
FolderStatistics statistics = new FolderStatistics();
|
||||||
|
|
||||||
|
if (storageObjects != null && storageObjects.ToList() != null)
|
||||||
|
{
|
||||||
|
storageObjects.ToList().ForEach(item =>
|
||||||
|
{
|
||||||
|
if (item.Type == "File")
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||||
|
WriteItemObject(item, item.Name, false);
|
||||||
|
statistics.TotalFilesFound++;
|
||||||
|
//statistics.TotalBytes = statistics.TotalBytes + item.Length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return statistics;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Writes out a list of supplied Folders and returns stats on them as well.
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private void WriteFolders(List<StorageItemViewModel> folders, ref FolderStatistics statistics)
|
||||||
|
{
|
||||||
|
if (folders != null)
|
||||||
|
{
|
||||||
|
// Write out each folder we find in the current directory..
|
||||||
|
|
||||||
|
foreach (StorageItemViewModel obj in folders)
|
||||||
|
{
|
||||||
|
string fixedString = obj.Name.TrimEnd('/');
|
||||||
|
string[] folderNames = fixedString.Split('/');
|
||||||
|
string folderName = folderNames[folderNames.Count() - 1];
|
||||||
|
//obj.Name = folderName;
|
||||||
|
|
||||||
|
if (folderName != "")
|
||||||
|
{
|
||||||
|
WriteItemObject(obj, folderName, false);
|
||||||
|
statistics.TotalFoldersFound++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
statistics.TotalFoldersFound = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Writes out summary information on a given folder.
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private void WriteFolderStatistics(FolderStatistics statistics)
|
||||||
|
{
|
||||||
|
if (statistics.TotalFoldersFound > 0 || statistics.TotalFilesFound > 0)
|
||||||
|
WriteItemObject ("----------------------------------------------------------------------------------------------", cDelimiter, false);
|
||||||
|
WriteItemObject(" ", cDelimiter, false);
|
||||||
|
WriteItemObject("Total # Folders found : " + Convert.ToString(statistics.TotalFoldersFound) , cDelimiter, false);
|
||||||
|
WriteItemObject("Total # Items Found : " + Convert.ToString(statistics.TotalFilesFound) , cDelimiter, false);
|
||||||
|
WriteItemObject("Total # Bytes in Folder : " + Convert.ToString(statistics.TotalBytes), cDelimiter, false);
|
||||||
|
// WriteItemObject("Total Cost of Folder : " + "$" + Convert.ToString(statistics.TotalBytes * 2), cDelimiter, false);
|
||||||
|
WriteItemObject(" ", cDelimiter, false);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Writes out header information to be used during listing operations.
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private void WriteHeader()
|
||||||
|
{
|
||||||
|
// Write out the commands header information first..
|
||||||
|
|
||||||
|
WriteItemObject(" ", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
|
WriteItemObject("==============================================================================================", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
|
WriteItemObject("Storage Container : " + this.Drive.Name, cDelimiter, false);
|
||||||
|
WriteItemObject("Directory of : " + this.Drive.Name + " " + cDelimiter + this.Drive.CurrentLocation, cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
|
WriteItemObject("==============================================================================================", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
WriteItemObject(" ", cDelimiter, false);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private bool CheckDefaultDrive(bool suppressMsg)
|
||||||
|
{
|
||||||
|
if (this.Drive.Name == "OS-Init")
|
||||||
|
{
|
||||||
|
if (!suppressMsg)
|
||||||
|
{
|
||||||
|
Console.WriteLine(" ", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
|
Console.WriteLine("==============================================================================================", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.Red;
|
||||||
|
Console.WriteLine("You are currently connected to the default Container. This drive is used to boot-strap the");
|
||||||
|
Console.WriteLine("Container creation prcoess. The only valid command that you can issue from here is the");
|
||||||
|
Console.WriteLine("New-Container command. After the Container is created successfully, issue CD yourcontainer:");
|
||||||
|
Console.WriteLine("This will bind to that container exposing the full functionality of OpenStack Object Storage. ");
|
||||||
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
|
Console.WriteLine("==============================================================================================", cDelimiter, false);
|
||||||
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
|
Console.WriteLine(" ", cDelimiter, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override object GetItemDynamicParameters(string path)
|
||||||
|
{
|
||||||
|
return base.GetItemDynamicParameters(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void SetItem(string path, object value)
|
||||||
|
{
|
||||||
|
base.SetItem(path, value);
|
||||||
|
}
|
||||||
|
protected override string[] ExpandPath(string path)
|
||||||
|
{
|
||||||
|
return base.ExpandPath(path);
|
||||||
|
}
|
||||||
|
protected override string GetParentPath(string path, string root)
|
||||||
|
{
|
||||||
|
return base.GetParentPath(path, root);
|
||||||
|
}
|
||||||
|
protected override object GetChildNamesDynamicParameters(string path)
|
||||||
|
{
|
||||||
|
return base.GetChildNamesDynamicParameters(path);
|
||||||
|
}
|
||||||
|
protected override object GetChildItemsDynamicParameters(string path, bool recurse)
|
||||||
|
{
|
||||||
|
return base.GetChildItemsDynamicParameters(path, recurse);
|
||||||
|
}
|
||||||
|
protected override object ClearItemDynamicParameters(string path)
|
||||||
|
{
|
||||||
|
return base.ClearItemDynamicParameters(path);
|
||||||
|
}
|
||||||
|
protected override string NormalizeRelativePath(string path, string basePath)
|
||||||
|
{
|
||||||
|
return base.NormalizeRelativePath(path, basePath);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override bool IsItemContainer(string path)
|
||||||
|
{
|
||||||
|
if (path == @"\")
|
||||||
|
{
|
||||||
|
if (this.CheckDefaultDrive(false)) return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StoragePath storagePath = null;
|
||||||
|
|
||||||
|
if (path.Contains(":"))
|
||||||
|
{
|
||||||
|
storagePath = new StoragePath(this.StorageServiceURL + path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storagePath = new StoragePath(this.StorageServiceURL, this.Drive.Name, path.Substring(1) + "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
IStorageServiceClient storageService = this.CoreClient.CreateServiceClient<IStorageServiceClient>();
|
||||||
|
Task<StorageObject> getStorageObjectTask = storageService.GetStorageObject(storagePath.Volume, storagePath.ResourcePath); //(storagePath.AbsoluteURI);
|
||||||
|
getStorageObjectTask.Wait();
|
||||||
|
StorageObject sObject = getStorageObjectTask.Result;
|
||||||
|
|
||||||
|
if (sObject != null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Displays all StorageObjects for a given folder..
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="recurse"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override void GetChildItems(string path, bool recurse)
|
||||||
|
{
|
||||||
|
// Write out the commands header information first..
|
||||||
|
|
||||||
|
if (this.CheckDefaultDrive(true)) return;
|
||||||
|
|
||||||
|
this.WriteHeader();
|
||||||
|
this.WriteData(this.GetStorageObjects(path).ToList<StorageItemViewModel>(), path);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the user decides to delete a KVSDrive.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drive"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override PSDriveInfo RemoveDrive(PSDriveInfo drive)
|
||||||
|
{
|
||||||
|
if (drive == null)
|
||||||
|
{
|
||||||
|
WriteError(new ErrorRecord(new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, drive));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return drive;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Called by the PS runtime when a NewDrive is required..
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drive"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override PSDriveInfo NewDrive(PSDriveInfo drive)
|
||||||
|
{
|
||||||
|
if (drive == null) {
|
||||||
|
WriteError(new ErrorRecord(new ArgumentNullException("drive"), "NullDrive", ErrorCategory.InvalidArgument, drive));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drive.Root == null) {
|
||||||
|
WriteError(new ErrorRecord(new ArgumentNullException("drive.Root"), "NullRoot", ErrorCategory.InvalidArgument, drive));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (drive is ObjectStoragePSDriveInfo) {
|
||||||
|
return drive;
|
||||||
|
}
|
||||||
|
|
||||||
|
var driveParams = this.DynamicParameters as ObjectStorageDriveParameters;
|
||||||
|
return new ObjectStoragePSDriveInfo(drive, driveParams, this.Context, this.StorageServiceURL);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// Called by the PS runtime when
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override object NewDriveDynamicParameters()
|
||||||
|
{
|
||||||
|
// The KVSDriveParameters instance will pull its values from the config file when created..
|
||||||
|
|
||||||
|
return new ObjectStorageDriveParameters();
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private string GetLeafFolder(string path)
|
||||||
|
{
|
||||||
|
string[] elements = path.Replace(@"\", "/").Split('/');
|
||||||
|
return elements[elements.Count() - 2];
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="itemTypeName"></param>
|
||||||
|
/// <param name="newItemValue"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override void NewItem(string path, string itemTypeName, object newItemValue)
|
||||||
|
{
|
||||||
|
//// Validate the folder name first..
|
||||||
|
|
||||||
|
//if (path.Contains("%") || path.Contains("."))
|
||||||
|
//{
|
||||||
|
// Console.WriteLine("");
|
||||||
|
// Console.WriteLine("Folder names cannot contain % or . characters" );
|
||||||
|
// Console.WriteLine("");
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// if (!path.EndsWith("/"))
|
||||||
|
// {
|
||||||
|
// path = path + "/";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// StoragePath newFolderPath = this.CreateStoragePath(path);
|
||||||
|
// this.RepositoryFactory.CreateStorageObjectRepository().MakeFolder(newFolderPath.AbsoluteURI);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private string ExtractPattern(string path)
|
||||||
|
{
|
||||||
|
string[] elements = path.Split('\\');
|
||||||
|
return elements[elements.Length - 1];
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override void GetItem(string path)
|
||||||
|
{
|
||||||
|
// Write out the commands header information first..
|
||||||
|
|
||||||
|
if (this.CheckDefaultDrive(true)) return;
|
||||||
|
this.WriteHeader();
|
||||||
|
IEnumerable<StorageItemViewModel> storageObjects = this.GetStorageObjects(path);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
this.WriteData(storageObjects.ToList<StorageItemViewModel>(), path);
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override bool ItemExists(string path)
|
||||||
|
{
|
||||||
|
if (path == "//")
|
||||||
|
{
|
||||||
|
if (this.CheckDefaultDrive(true))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return base.ItemExists(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base.ItemExists(path);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Properties
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private ObjectStoragePSDriveInfo Drive
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.PSDriveInfo as ObjectStoragePSDriveInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
//=========================================================================================
|
||||||
|
private StoragePath CreateStoragePath(string path)
|
||||||
|
{
|
||||||
|
return this.Drive.CreateStoragePath(path);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
/// This test should not verify the existance of the item at the path.
|
||||||
|
/// It should only perform syntactic and semantic validation of the
|
||||||
|
/// path. For instance, for the file system provider, that path should
|
||||||
|
/// be canonicalized, syntactically verified, and ensure that the path
|
||||||
|
/// does not refer to a device.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
protected override bool IsValidPath(string path)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,369 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
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.Generic;
|
||||||
|
using System.Management.Automation;
|
||||||
|
using System.Collections;
|
||||||
|
using OpenStack.Client.Powershell.Utility;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenStack.Storage;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenStack.Client.Powershell.Providers.Storage
|
||||||
|
{
|
||||||
|
public class ObjectStoragePSDriveInfo : PSDriveInfo
|
||||||
|
{
|
||||||
|
public const string cDelimiter = "/";
|
||||||
|
|
||||||
|
private ObjectStorageDriveParameters _parameters = null;
|
||||||
|
private IStorageServiceClient _storageClient;
|
||||||
|
private List<string> _pathCache = new List<string>();
|
||||||
|
private bool _isQueueOn = false;
|
||||||
|
private Settings _settings = null;
|
||||||
|
private Context _context;
|
||||||
|
private string _sharePath;
|
||||||
|
private string _storageServiceUrl;
|
||||||
|
|
||||||
|
#region Ctors
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="driveInfo"></param>
|
||||||
|
//==================================================================================================
|
||||||
|
public ObjectStoragePSDriveInfo(PSDriveInfo driveInfo, ObjectStorageDriveParameters parameters, Context context , string storageServiceUrl): base(driveInfo)
|
||||||
|
{
|
||||||
|
_parameters = parameters;
|
||||||
|
_context = context;
|
||||||
|
_storageServiceUrl = storageServiceUrl;
|
||||||
|
|
||||||
|
if (parameters != null)
|
||||||
|
_settings = parameters.Settings;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Methods
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=======================================================================================================
|
||||||
|
private string GetFirstPathElement(string path)
|
||||||
|
{
|
||||||
|
int delimeterPosition;
|
||||||
|
|
||||||
|
if (path.StartsWith(@"\"))
|
||||||
|
{
|
||||||
|
delimeterPosition = path.IndexOf(@"\", 1, StringComparison.Ordinal);
|
||||||
|
if (delimeterPosition != -1)
|
||||||
|
return path.Substring(0, delimeterPosition);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delimeterPosition = path.IndexOf("/", 0, StringComparison.Ordinal);
|
||||||
|
if (delimeterPosition != -1)
|
||||||
|
return path.Substring(0, delimeterPosition);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delimeterPosition = path.IndexOf(@"\", 0, StringComparison.Ordinal);
|
||||||
|
if (delimeterPosition != -1)
|
||||||
|
return path.Substring(0, delimeterPosition);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=======================================================================================================
|
||||||
|
private bool IsOpenStackDrive(string name)
|
||||||
|
{
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
if (name.Contains(":"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string SharePath
|
||||||
|
{
|
||||||
|
get { return _sharePath; }
|
||||||
|
set { _sharePath = value; }
|
||||||
|
}
|
||||||
|
private IStorageServiceClient StorageClient
|
||||||
|
{
|
||||||
|
get { return _storageClient; }
|
||||||
|
set { _storageClient = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=======================================================================================================
|
||||||
|
private bool ContainsHPOSDrive(string name)
|
||||||
|
{
|
||||||
|
foreach (PSDriveInfo drive in this.Provider.Drives)
|
||||||
|
{
|
||||||
|
if (drive.Provider.Name == "Object Storage" && drive.Name.Contains(name))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
////=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=========================================================================================
|
||||||
|
private bool IsLocalPath(string path)
|
||||||
|
{
|
||||||
|
// Temporaily reverse the delimiter for this check...
|
||||||
|
|
||||||
|
string temp = path.Replace(@"/", @"\");
|
||||||
|
List<DriveInfo> drives = DriveInfo.GetDrives().ToList<DriveInfo>();
|
||||||
|
|
||||||
|
drives.DefaultIfEmpty(null);
|
||||||
|
if (drives.Where(d => temp.ToUpper().Contains(d.Name)).FirstOrDefault() == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private bool IsFullyQualifiedPath (string path)
|
||||||
|
{
|
||||||
|
string firstPathElement = GetFirstPathElement(path);
|
||||||
|
|
||||||
|
if (IsOpenStackDrive(firstPathElement))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (IsLocalPath(path))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private string FormatPath (string path)
|
||||||
|
{
|
||||||
|
string currentLocation = null;
|
||||||
|
|
||||||
|
// Strip out any leading or trailing delimiters..
|
||||||
|
|
||||||
|
if (path.StartsWith(@"\") || path.StartsWith("/"))
|
||||||
|
{
|
||||||
|
path = path.Substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse the delimiter and strip out the current location. We do this because some paths will come from the provider
|
||||||
|
// in which PS has already supplied the fully qualified path, yet some paths will come from cmdlets (like CopyItem)
|
||||||
|
// that receive paths from the user. These paths may or may not contain the current location so we strip it out reguardless
|
||||||
|
// then read it back...
|
||||||
|
|
||||||
|
path = path.Replace(@"\", "/");
|
||||||
|
currentLocation = this.CurrentLocation.Replace(@"\", "/");
|
||||||
|
|
||||||
|
if (currentLocation != "")
|
||||||
|
{
|
||||||
|
path = path.Replace(currentLocation + "/", string.Empty);
|
||||||
|
}
|
||||||
|
path = path.Replace(this.Name + "/", string.Empty);
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private StoragePath ProcessRootPath(string path)
|
||||||
|
{
|
||||||
|
path = this.FormatPath(path);
|
||||||
|
|
||||||
|
if (this.IsLocalPath(path))
|
||||||
|
{
|
||||||
|
// Nothing to do to a pure local path. Just return it wrapped up..
|
||||||
|
|
||||||
|
return new StoragePath(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string firstElement = this.GetFirstPathElement(path);
|
||||||
|
|
||||||
|
if (this.IsOpenStackDrive(firstElement))
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the path supplied lacks a storageContainer name, take the current one..
|
||||||
|
|
||||||
|
return new StoragePath(this.StorageServiceUrl, this.Name, path.Replace(@"\", "/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private StoragePath ProcessNonRootPath (string path)
|
||||||
|
{
|
||||||
|
string publicURL = this.StorageServiceUrl;
|
||||||
|
|
||||||
|
if (this.IsFullyQualifiedPath(path) == true)
|
||||||
|
{
|
||||||
|
return new StoragePath(this.StorageServiceUrl + "/" + path.Replace(@"\", "/").Replace(":", "/"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path = this.FormatPath(path);
|
||||||
|
|
||||||
|
if (path.EndsWith(cDelimiter))
|
||||||
|
{
|
||||||
|
// We're dealing with a folder path here..
|
||||||
|
|
||||||
|
return new StoragePath(publicURL, this.Name, this.CurrentLocation.Replace(@"\", "/") + cDelimiter + path);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We're dealing with an object path here..
|
||||||
|
|
||||||
|
path = (publicURL + cDelimiter + this.Name + cDelimiter + this.CurrentLocation.Replace(@"\", "/") + cDelimiter + path);
|
||||||
|
return new StoragePath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourcePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
public StoragePath CreateStoragePath(string path)
|
||||||
|
{
|
||||||
|
if (this.IsLocalPath(path))
|
||||||
|
{
|
||||||
|
return new StoragePath(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check for a root path supplied first..
|
||||||
|
|
||||||
|
if (this.CurrentLocation == string.Empty)
|
||||||
|
{
|
||||||
|
return this.ProcessRootPath(path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this.ProcessNonRootPath(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
public Hashtable GetParameters()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Properties
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private string StorageServiceUrl
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (this.SharePath == null)
|
||||||
|
{
|
||||||
|
string serviceName = this._context.CurrentServiceProvider.ServiceMaps.TranslateServiceName(CoreServices.ObjectStorage);
|
||||||
|
return this._context.ServiceCatalog.GetPublicEndpoint(serviceName, _context.CurrentRegion).ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return this.SharePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
public List<string> PathCache
|
||||||
|
{
|
||||||
|
get { return _pathCache; }
|
||||||
|
set { _pathCache = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@ -1,225 +1,211 @@
|
|||||||
//using System;
|
/* ============================================================================
|
||||||
//using System.Collections.Generic;
|
Copyright 2014 Hewlett Packard
|
||||||
//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
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
//{
|
you may not use this file except in compliance with the License.
|
||||||
// public class AccountCapabilities
|
You may obtain a copy of the License at
|
||||||
// {
|
|
||||||
// private SessionState _session;
|
|
||||||
// private Context _context;
|
|
||||||
|
|
||||||
// #region Properties
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
// public Context Context
|
|
||||||
// {
|
|
||||||
// get { return _context; }
|
|
||||||
// set { _context = value; }
|
|
||||||
// }
|
|
||||||
// public SessionState Session
|
|
||||||
// {
|
|
||||||
// get { return _session; }
|
|
||||||
// set { _session = value; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public AccountCapabilities(SessionState session, Context context)
|
Unless required by applicable law or agreed to in writing, software
|
||||||
// {
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
// _session = session;
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
// _context = context;
|
See the License for the specific language governing permissions and
|
||||||
// }
|
limitations under the License.
|
||||||
// //=======================================================================================================
|
============================================================================ */
|
||||||
// /// <summary>
|
using System;
|
||||||
// ///
|
using System.Collections.Generic;
|
||||||
// /// </summary>
|
using System.Collections.ObjectModel;
|
||||||
// //=======================================================================================================
|
using System.Management.Automation;
|
||||||
// public void WriteServices()
|
using OpenStack.Client.Powershell.Providers.Storage;
|
||||||
// {
|
using OpenStack.Identity;
|
||||||
// this.Session.InvokeCommand.InvokeScript("Hey");
|
|
||||||
|
|
||||||
// //WriteObject("");
|
namespace OpenStack.Client.Powershell.Utility
|
||||||
// //Console.ForegroundColor = ConsoleColor.DarkGray;
|
{
|
||||||
// //WriteObject("=================================================================");
|
public class AccountCapabilities
|
||||||
// //Console.ForegroundColor = ConsoleColor.Yellow;
|
{
|
||||||
// //WriteObject("Binding to new Account. New service catalog is as follows.");
|
private SessionState _session;
|
||||||
// //Console.ForegroundColor = ConsoleColor.DarkGray;
|
private Context _context;
|
||||||
// //WriteObject("=================================================================");
|
private IOpenStackClient _coreClient;
|
||||||
// //Console.ForegroundColor = ConsoleColor.Green;
|
private Cmdlet _cmdlet;
|
||||||
// //WriteObject(" ");
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
// //foreach (OpenstackServiceDefinition service in this.Context.ServiceCatalog)
|
public Cmdlet Cmdlet
|
||||||
// //{
|
{
|
||||||
// // WriteObject(service);
|
get { return _cmdlet; }
|
||||||
// //}
|
set { _cmdlet = value; }
|
||||||
// //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)
|
public IOpenStackClient CoreClient
|
||||||
// {
|
{
|
||||||
// parameters.Settings = this.Context.Settings;
|
get { return _coreClient; }
|
||||||
// }
|
set { _coreClient = value; }
|
||||||
// else
|
}
|
||||||
// {
|
|
||||||
// parameters.Settings = settings;
|
private Context Context
|
||||||
// }
|
{
|
||||||
|
get { return _context; }
|
||||||
|
set { _context = value; }
|
||||||
|
}
|
||||||
|
private SessionState SessionState
|
||||||
|
{
|
||||||
|
get { return _session; }
|
||||||
|
set { _session = value; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Methods
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="session"></param>
|
||||||
|
/// <param name="context"></param>
|
||||||
|
/// <param name="coreClient"></param>
|
||||||
|
/// <param name="cmd"></param>
|
||||||
|
//=======================================================================================================
|
||||||
|
public AccountCapabilities(SessionState session, Context context, IOpenStackClient coreClient, Cmdlet cmd)
|
||||||
|
{
|
||||||
|
_session = session;
|
||||||
|
_context = context;
|
||||||
|
_coreClient = coreClient;
|
||||||
|
_cmdlet = cmd;
|
||||||
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=========================================================================================
|
||||||
|
private void WriteHeader(string message)
|
||||||
|
{
|
||||||
|
// Write out the commands header information first..
|
||||||
|
|
||||||
// try
|
WriteObject("");
|
||||||
// {
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
// Task<IEnumerable<StorageContainer>> getContainersTask = this.CoreClient.CreateServiceClient<IStorageServiceClient>().ListStorageContainers();
|
WriteObject("===================================================================");
|
||||||
// getContainersTask.Wait();
|
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||||
// storageContainers = getContainersTask.Result.ToList<StorageContainer>();
|
WriteObject(message);
|
||||||
// }
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
// catch (Exception ex)
|
WriteObject("===================================================================");
|
||||||
// {
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
// Console.WriteLine(ex);
|
WriteObject(" ");
|
||||||
// }
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=========================================================================================
|
||||||
|
public void WriteContainers()
|
||||||
|
{
|
||||||
|
var invalidDriveNames = new List<string>();
|
||||||
|
var parameters = new ObjectStorageDriveParameters();
|
||||||
|
var provider = new ObjectStorageNavigationProvider();
|
||||||
|
var converter = new ObjectStorageDriveConverter(this.Context, _session.Drive.Current.Provider, this.CoreClient);
|
||||||
|
var drives = converter.ConvertContainers();
|
||||||
|
|
||||||
|
if (drives != null)
|
||||||
|
{
|
||||||
|
this.WriteHeader("Storage Containers available in this AZ include");
|
||||||
|
|
||||||
// Collection<PSDriveInfo> drives = new Collection<PSDriveInfo>();
|
// Remove the old Users drives first..
|
||||||
|
|
||||||
// // For every storageContainer that the User has access to, create a Drive that he can mount within Powershell..
|
Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("Object Storage");
|
||||||
|
foreach (PSDriveInfo deadDrive in deadDrives)
|
||||||
|
{
|
||||||
|
this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
|
||||||
|
}
|
||||||
|
|
||||||
// try
|
foreach (PSDriveInfo drive in drives)
|
||||||
// {
|
{
|
||||||
// string publicStoreUrl = this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", "region-a.geo-1").ToString();
|
if (drive.Name != string.Empty)
|
||||||
|
{
|
||||||
|
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||||
|
WriteObject("Storage Container : [" + drive.Name + "] now available.");
|
||||||
|
}
|
||||||
|
|
||||||
// if (storageContainers.Count > 0)
|
try
|
||||||
// {
|
{
|
||||||
// foreach (StorageContainer storageContainer in storageContainers)
|
this.SessionState.Drive.New(drive, "local");
|
||||||
// {
|
}
|
||||||
// PSDriveInfo driveInfo = new PSDriveInfo(storageContainer.Name, providerInfo, "/", "Root folder for your storageContainer", null);
|
catch (PSArgumentException ex)
|
||||||
// OpenStackPSDriveInfo kvsDriveInfo = new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl);
|
{
|
||||||
// try
|
if (drive.Name != string.Empty)
|
||||||
// {
|
invalidDriveNames.Add(drive.Name);
|
||||||
// drives.Add(kvsDriveInfo);
|
}
|
||||||
// }
|
}
|
||||||
// catch (Exception) { }
|
}
|
||||||
// }
|
else
|
||||||
// }
|
{
|
||||||
// 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);
|
|
||||||
// return new Collection<PSDriveInfo>
|
|
||||||
// {
|
|
||||||
// new OpenStackPSDriveInfo(driveInfo, parameters, this.Context, publicStoreUrl)
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// int g = 7;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return drives;
|
//PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
|
||||||
// }
|
//this.SessionState.Drive.New(new ObjectStoragePSDriveInfo(driveInfo, parameters, this.Context, this.Context.ServiceCatalog.GetPublicEndpoint("object-store", this.Context.CurrentRegion)), "local");
|
||||||
// //=======================================================================================================
|
}
|
||||||
// /// <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");
|
if (invalidDriveNames.Count > 0) {
|
||||||
// foreach (PSDriveInfo deadDrive in deadDrives)
|
ShowNameConflictError(invalidDriveNames);
|
||||||
// {
|
}
|
||||||
// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
|
}
|
||||||
// }
|
//=======================================================================================================
|
||||||
// }
|
/// <summary>
|
||||||
// //=======================================================================================================
|
///
|
||||||
// /// <summary>
|
/// </summary>
|
||||||
// ///
|
/// <param name="invalidDriveNames"></param>
|
||||||
// /// </summary>
|
//=======================================================================================================
|
||||||
// //=======================================================================================================
|
private void ShowNameConflictError(List<string> invalidDriveNames)
|
||||||
// public void WriteContainers(string configFilePath)
|
{
|
||||||
// {
|
WriteObject("");
|
||||||
// List<string> invalidDriveNames = new List<string>();
|
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||||
// OSDriveParameters parameters = new OSDriveParameters();
|
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(" ");
|
||||||
|
|
||||||
// // Write out the commands header information first..
|
foreach (string name in invalidDriveNames)
|
||||||
|
{
|
||||||
|
WriteObject(name);
|
||||||
|
WriteObject(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text"></param>
|
||||||
|
//=======================================================================================================
|
||||||
|
private void WriteObject(string text)
|
||||||
|
{
|
||||||
|
this.Cmdlet.WriteObject(text);
|
||||||
|
}
|
||||||
|
//=======================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=======================================================================================================
|
||||||
|
public 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(" ");
|
||||||
|
|
||||||
// WriteObject("");
|
foreach (OpenStackServiceDefinition service in this.Context.ServiceCatalog.GetServicesInAvailabilityZone(this.Context.CurrentRegion))
|
||||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
{
|
||||||
// WriteObject("===================================================================");
|
this.Cmdlet.WriteObject(service);
|
||||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
}
|
||||||
// WriteObject("Object Storage Service available. Remapping to the following drives.");
|
WriteObject("");
|
||||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
}
|
||||||
// WriteObject("===================================================================");
|
#endregion
|
||||||
// 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
|
|
56
Openstack.Client.Powershell/Utility/AvailabilityZone.cs
Normal file
56
Openstack.Client.Powershell/Utility/AvailabilityZone.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/* ============================================================================
|
||||||
|
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 AvailabilityZone
|
||||||
|
{
|
||||||
|
private string _name;
|
||||||
|
private bool _isDefault = false;
|
||||||
|
private string _shellForegroundColor = "Green";
|
||||||
|
private string _id;
|
||||||
|
|
||||||
|
public string Id
|
||||||
|
{
|
||||||
|
get { return _id; }
|
||||||
|
set { _id = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ShellForegroundColor
|
||||||
|
{
|
||||||
|
get { return _shellForegroundColor; }
|
||||||
|
set { _shellForegroundColor = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDefault
|
||||||
|
{
|
||||||
|
get { return _isDefault; }
|
||||||
|
set { _isDefault = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _name; }
|
||||||
|
set { _name = value; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -20,9 +20,31 @@ using System.Xml.Linq;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Xml.XPath;
|
using System.Xml.XPath;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
using System.Xml.Schema;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Utility
|
namespace OpenStack.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
|
public class ValidationResult
|
||||||
|
{
|
||||||
|
private bool _hasErrors = false;
|
||||||
|
private List<string> _errorList = new List<string>();
|
||||||
|
|
||||||
|
public List<string> Errors
|
||||||
|
{
|
||||||
|
get { return _errorList; }
|
||||||
|
set { _errorList = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasErrors
|
||||||
|
{
|
||||||
|
get { return _hasErrors; }
|
||||||
|
set { _hasErrors = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public class ConfigurationManager
|
public class ConfigurationManager
|
||||||
{
|
{
|
||||||
private bool _isLoaded = false;
|
private bool _isLoaded = false;
|
||||||
@ -114,7 +136,7 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
{
|
{
|
||||||
if (!this.IsLoaded) throw new InvalidOperationException("Instance must be Loaded first..");
|
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();
|
XElement serviceProviderNode = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("isDefault").Value == "true").FirstOrDefault();
|
||||||
return this.GetServiceProvider(serviceProviderNode.Attribute("name").Value);
|
return this.GetServiceProvider(serviceProviderNode.Attribute("name").Value);
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -122,10 +144,102 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
public void Load()
|
private ValidationResult ValidateDocument(XDocument document)
|
||||||
|
{
|
||||||
|
ValidationResult result = new ValidationResult();
|
||||||
|
|
||||||
|
// First we check the structural integrity of the document via XSD..
|
||||||
|
|
||||||
|
//string xsdMarkup = this.GetSchema();
|
||||||
|
//XmlSchemaSet schemas = new XmlSchemaSet();
|
||||||
|
//schemas.Add("", XmlReader.Create(new StringReader(xsdMarkup)));
|
||||||
|
|
||||||
|
//document.Validate(schemas, (o, e) =>
|
||||||
|
//{
|
||||||
|
// result.Errors.Add(e.Message);
|
||||||
|
// result.HasErrors = true;
|
||||||
|
//});
|
||||||
|
|
||||||
|
// Next, ensure that a default Service Provider exist..
|
||||||
|
|
||||||
|
var serviceProviders = this.Document.Descendants("ServiceProvider");
|
||||||
|
bool hasDefaultServiceProvider = serviceProviders.Where(sp => sp.Attributes("isDefault").Single().Value.ToUpper() == "TRUE").Any();
|
||||||
|
if (!hasDefaultServiceProvider) {
|
||||||
|
result.HasErrors = true;
|
||||||
|
result.Errors.Add("No Default Service Provider found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now check that each Service Provider has at least one default AZ.
|
||||||
|
|
||||||
|
foreach (XElement provider in serviceProviders) {
|
||||||
|
if (!provider.Descendants("AvailabilityZones").Descendants().Where(d => d.Attributes("isDefault").Single().Value.ToUpper() == "TRUE").Any()) {
|
||||||
|
result.HasErrors = true;
|
||||||
|
result.Errors.Add("The Service Provider " + provider.Attributes("name").Single().Value + " doesn not have a default Availability Zone/Region");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that we only have 1 default Service Provider....
|
||||||
|
|
||||||
|
if (serviceProviders.Where(d => d.Attributes("isDefault").Single().Value.ToUpper() == "TRUE").Count() > 1) {
|
||||||
|
result.HasErrors = true;
|
||||||
|
result.Errors.Add("Only one Service Provider can be marked as the default.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that each Service Provider has a unique Name. (how can we get linqs Distinct to work with XElement when we can't
|
||||||
|
// force that type to implement IComparable<T> ????
|
||||||
|
|
||||||
|
var table = new Hashtable();
|
||||||
|
foreach (XElement provider in serviceProviders)
|
||||||
|
{
|
||||||
|
string name = provider.Attributes("name").Single().Value;
|
||||||
|
try {
|
||||||
|
table.Add(name, String.Empty);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.HasErrors = true;
|
||||||
|
result.Errors.Add("Please ensure that all Service Providers have a unique name assigned to them.");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=========================================================================================
|
||||||
|
private InvalidDataException CreateLoadException(ValidationResult result)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
string msg = "The config file is invalid for the following reasons => ";
|
||||||
|
|
||||||
|
foreach (string message in result.Errors) {
|
||||||
|
msg = msg + message;
|
||||||
|
}
|
||||||
|
return new InvalidDataException(msg);
|
||||||
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//=========================================================================================
|
||||||
|
public void Load(bool requiresValidation = true)
|
||||||
{
|
{
|
||||||
_document = new XDocument(); ;
|
ValidationResult result = null;
|
||||||
_document = XDocument.Load(this.GetFullConfigPath());
|
_document = new XDocument(); ;
|
||||||
|
_document = XDocument.Load(this.GetFullConfigPath());
|
||||||
|
|
||||||
|
if (requiresValidation)
|
||||||
|
{
|
||||||
|
result = this.ValidateDocument(_document);
|
||||||
|
|
||||||
|
if (result.HasErrors) {
|
||||||
|
throw this.CreateLoadException(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -134,10 +248,21 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="configFilePath"></param>
|
/// <param name="configFilePath"></param>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
public void Load(string configFilePath)
|
public void Load(string configFilePath, bool requiresValidation = true)
|
||||||
{
|
{
|
||||||
_document = new XDocument();
|
ValidationResult result = null;
|
||||||
_document = XDocument.Load(configFilePath);
|
_document = new XDocument();
|
||||||
|
_document = XDocument.Load(configFilePath);
|
||||||
|
|
||||||
|
if (requiresValidation)
|
||||||
|
{
|
||||||
|
result = this.ValidateDocument(_document);
|
||||||
|
|
||||||
|
if (result.HasErrors){
|
||||||
|
throw this.CreateLoadException(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
@ -161,6 +286,36 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
throw new InvalidOperationException("Unable to locate OpenStack.config file.");
|
throw new InvalidOperationException("Unable to locate OpenStack.config file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceProviderNode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=========================================================================================
|
||||||
|
private IEnumerable<AvailabilityZone> GetAvailabilityZones(XElement serviceProviderNode)
|
||||||
|
{
|
||||||
|
List<AvailabilityZone> zones = new List<AvailabilityZone>();
|
||||||
|
|
||||||
|
if (serviceProviderNode.HasElements && serviceProviderNode.Element("AvailabilityZones") != null && serviceProviderNode.Element("AvailabilityZones").Descendants().Count() > 0)
|
||||||
|
{
|
||||||
|
foreach (XElement az in serviceProviderNode.Element("AvailabilityZones").Descendants()) {
|
||||||
|
|
||||||
|
AvailabilityZone zone = new AvailabilityZone();
|
||||||
|
zone.Name = az.Attribute("name").Value;
|
||||||
|
zone.ShellForegroundColor = az.Attribute("shellForegroundColor").Value;
|
||||||
|
zone.IsDefault = Convert.ToBoolean(az.Attribute("isDefault").Value);
|
||||||
|
zone.Id = az.Attribute("id").Value;
|
||||||
|
zones.Add(zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
return zones;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -176,45 +331,73 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
var provider = new ServiceProvider();
|
var provider = new ServiceProvider();
|
||||||
provider.Name = serviceProviderNode.Attribute("name").Value;
|
provider.Name = serviceProviderNode.Attribute("name").Value;
|
||||||
provider.IsDefault = Convert.ToBoolean(serviceProviderNode.Attribute("isDefault").Value);
|
provider.IsDefault = Convert.ToBoolean(serviceProviderNode.Attribute("isDefault").Value);
|
||||||
|
provider.AvailabilityZones = this.GetAvailabilityZones(serviceProviderNode);
|
||||||
|
provider.ServiceMaps = this.GetServiceMaps(serviceProviderNode);
|
||||||
|
|
||||||
// The ServiceProvider in the Primary config file is pointing to a Vender specific config so reolve that first..
|
// The ServiceProvider in the Primary config file is pointing to a Vender specific config so reolve that first..
|
||||||
|
|
||||||
foreach (XElement xElement in serviceProviderNode.Elements())
|
foreach (XElement xElement in serviceProviderNode.Elements())
|
||||||
{
|
{
|
||||||
CredentialElement element = new CredentialElement();
|
if (xElement.Name == "add")
|
||||||
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);
|
CredentialElement element = new CredentialElement();
|
||||||
element.DisplayName = xElement.Attribute("displayName").Value;
|
element.Key = xElement.Attribute("key").Value;
|
||||||
//element.HelpText = xElement.Attribute("helpText").Value;
|
element.Value = xElement.Attribute("value").Value;
|
||||||
}
|
|
||||||
catch (Exception) { }
|
|
||||||
|
|
||||||
if (element.Key == "ConfigFilePath")
|
if (xElement.Attribute("key").Value == "AuthenticationServiceURI")
|
||||||
{
|
provider.AuthenticationServiceURI = xElement.Attribute("value").Value;
|
||||||
provider.CredentialElements.Add(element);
|
|
||||||
ServiceProvider resolvedProvider = this.ResolveServiceProviderCredentials(provider);
|
if (xElement.Attribute("key").Value == "isDefault")
|
||||||
resolvedProvider.ConfigFilePath = element.Value;
|
provider.IsDefault = Convert.ToBoolean(xElement.Attribute("value").Value);
|
||||||
return resolvedProvider;
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
provider.CredentialElements.Add(element);
|
|
||||||
}
|
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="serviceProviderNode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//=========================================================================================
|
||||||
|
private ServiceMaps GetServiceMaps(XElement serviceProviderNode)
|
||||||
|
{
|
||||||
|
ServiceMaps serviceMaps = new ServiceMaps();
|
||||||
|
var serviceMapsDoc = serviceProviderNode.Descendants("ServiceMaps").Descendants("ServiceMap");
|
||||||
|
|
||||||
|
foreach (XElement map in serviceMapsDoc) {
|
||||||
|
|
||||||
|
ServiceMap newMap = new ServiceMap();
|
||||||
|
newMap.Source = map.Attributes("source").Single().Value;
|
||||||
|
newMap.Target = map.Attributes("target").Single().Value;
|
||||||
|
|
||||||
|
serviceMaps.Add(newMap);
|
||||||
|
}
|
||||||
|
return serviceMaps;
|
||||||
|
}
|
||||||
|
//=========================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
public IEnumerable<ServiceProvider> GetServiceProviders()
|
public IEnumerable<ServiceProvider> GetServiceProviders()
|
||||||
@ -268,22 +451,40 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
//=========================================================================================
|
//=========================================================================================
|
||||||
public void WriteServiceProvider(ServiceProvider serviceProvider, bool removeInitialServiceProvider = false)
|
public void WriteServiceProvider(ServiceProvider serviceProvider, bool removeInitialServiceProvider = false)
|
||||||
{
|
{
|
||||||
|
XElement oldServiceProvider = null;
|
||||||
|
|
||||||
|
if (serviceProvider.ConfigFilePath != null)
|
||||||
|
this.Load(serviceProvider.ConfigFilePath);
|
||||||
|
else
|
||||||
|
this.Load();
|
||||||
|
|
||||||
|
XElement availabilityZones = null;
|
||||||
|
XElement serviceMaps = null;
|
||||||
IEnumerable<XElement> serviceProviderNodes = this.Document.Descendants("ServiceProvider");
|
IEnumerable<XElement> serviceProviderNodes = this.Document.Descendants("ServiceProvider");
|
||||||
XElement spElement = new XElement("ServiceProvider",
|
XElement spElement = new XElement("ServiceProvider",
|
||||||
new XAttribute("name", serviceProvider.Name),
|
new XAttribute("name", serviceProvider.Name),
|
||||||
new XAttribute("isDefault", serviceProvider.IsDefault));
|
new XAttribute("isDefault", serviceProvider.IsDefault));
|
||||||
|
|
||||||
// Get rid of the old ServiceProvider first ...
|
// Get rid of the old ServiceProvider first ...
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XElement oldServiceProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == serviceProvider.Name).Single();
|
if (this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == serviceProvider.Name).Count() > 0) {
|
||||||
|
oldServiceProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == serviceProvider.Name).Single();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
oldServiceProvider = this.Document.Descendants("ServiceProvider").Where(sp => sp.Attribute("name").Value == String.Empty).Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preserve contained elements so we can place them back with the new provider..
|
||||||
|
|
||||||
|
availabilityZones = oldServiceProvider.Element("AvailabilityZones");
|
||||||
|
serviceMaps = oldServiceProvider.Element("ServiceMaps");
|
||||||
|
|
||||||
if (oldServiceProvider != null)
|
if (oldServiceProvider != null)
|
||||||
oldServiceProvider.Remove();
|
oldServiceProvider.Remove();
|
||||||
}
|
}
|
||||||
catch (InvalidOperationException ex) { }
|
catch (InvalidOperationException ex) { }
|
||||||
|
|
||||||
|
|
||||||
// If this new Provider is set = default, remove the default flag from the previous one..
|
// If this new Provider is set = default, remove the default flag from the previous one..
|
||||||
|
|
||||||
if (serviceProvider.IsDefault) {
|
if (serviceProvider.IsDefault) {
|
||||||
@ -291,7 +492,11 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create CredentialElement instances for all Key\Value (Add elements)..
|
// Create CredentialElement instances for all Key\Value (Add elements)..
|
||||||
|
|
||||||
|
spElement.Add(availabilityZones);
|
||||||
|
spElement.Add(serviceMaps);
|
||||||
|
|
||||||
|
|
||||||
foreach (CredentialElement element in serviceProvider.CredentialElements) {
|
foreach (CredentialElement element in serviceProvider.CredentialElements) {
|
||||||
spElement.Add(this.CreateAddElement(element));
|
spElement.Add(this.CreateAddElement(element));
|
||||||
}
|
}
|
||||||
@ -299,8 +504,107 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
if (removeInitialServiceProvider == true)
|
if (removeInitialServiceProvider == true)
|
||||||
this.RemoveInitialServiceProvider(ref _document);
|
this.RemoveInitialServiceProvider(ref _document);
|
||||||
|
|
||||||
this.Document.XPathSelectElement("configuration/appSettings/IdentityServices").Add(spElement);
|
if (this.Document != null)
|
||||||
this.Document.Save(this.GetFullConfigPath());
|
{
|
||||||
}
|
this.Document.XPathSelectElement("configuration/appSettings/IdentityServices").Add(spElement);
|
||||||
|
if (serviceProvider.ConfigFilePath == null)
|
||||||
|
this.Document.Save(this.GetFullConfigPath());
|
||||||
|
else
|
||||||
|
this.Document.Save(serviceProvider.ConfigFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetSchema()
|
||||||
|
{
|
||||||
|
return @"<?xml version='1.0' encoding='utf-8'?>
|
||||||
|
<xs:schema attributeFormDefault='unqualified' elementFormDefault='qualified' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
|
||||||
|
<xs:element name='configuration'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name='appSettings'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name='Testing'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element maxOccurs='unbounded' name='add'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name='key' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='value' type='xs:string' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name='StorageManagement'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element maxOccurs='unbounded' name='add'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name='key' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='value' type='xs:string' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name='IdentityServices'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name='ServiceProvider'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element minOccurs='1' maxOccurs='unbounded' name='add'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name='key' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='value' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='displayName' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='helpText' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='isMandatory' type='xs:string' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name='AvailabilityZones'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element minOccurs ='1' maxOccurs='unbounded' name='AvailabilityZone'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name='id' type='xs:unsignedByte' use='required' />
|
||||||
|
<xs:attribute name='isDefault' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='name' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='shellForegroundColor' type='xs:string' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
<xs:attribute name='name' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='isDefault' type='xs:boolean' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name='ComputeServices'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element maxOccurs='unbounded' name='add'>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:attribute name='key' type='xs:string' use='required' />
|
||||||
|
<xs:attribute name='value' type='xs:string' use='required' />
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>";
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,10 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
private string _productName = "OpenstackDotNetAPI";
|
private string _productName = "OpenstackDotNetAPI";
|
||||||
private string _version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
private string _version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
private string _forecolor = "Green";
|
private string _forecolor = "Green";
|
||||||
|
private string _currentRegion;
|
||||||
|
private ServiceProvider _currentServiceProvider;
|
||||||
|
|
||||||
|
|
||||||
#region Ctors
|
#region Ctors
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -47,6 +50,26 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
public ServiceProvider CurrentServiceProvider
|
||||||
|
{
|
||||||
|
get { return _currentServiceProvider; }
|
||||||
|
set { _currentServiceProvider = value; }
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
public string CurrentRegion
|
||||||
|
{
|
||||||
|
get { return _currentRegion; }
|
||||||
|
set { _currentRegion = value; }
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
public string Version
|
public string Version
|
||||||
{
|
{
|
||||||
get { return _version; }
|
get { return _version; }
|
||||||
|
@ -19,15 +19,16 @@ using OpenStack.Client.Powershell.Utility;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenStack.Identity;
|
using OpenStack.Identity;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Utility
|
namespace OpenStack.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
public class ExtensionManager
|
public class ExtensionManager
|
||||||
{
|
{
|
||||||
private SessionState _session;
|
private SessionState _session;
|
||||||
private Context _context;
|
private Context _context;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
public Context Context
|
public Context Context
|
||||||
{
|
{
|
||||||
get { return _context; }
|
get { return _context; }
|
||||||
@ -38,19 +39,19 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
get { return _session; }
|
get { return _session; }
|
||||||
set { _session = value; }
|
set { _session = value; }
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="session"></param>
|
/// <param name="session"></param>
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public ExtensionManager(SessionState session, Context context)
|
public ExtensionManager(SessionState session, Context context)
|
||||||
{
|
{
|
||||||
_session = session;
|
_session = session;
|
||||||
_context = context;
|
_context = context;
|
||||||
}
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -58,16 +59,18 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
/// <param name="provider"></param>
|
/// <param name="provider"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
private Settings GetSettings(ServiceProvider provider)
|
private Settings GetSettings(ServiceProvider provider)
|
||||||
{
|
{
|
||||||
if (provider.ConfigFilePath == null) {
|
if (provider.ConfigFilePath == null)
|
||||||
Settings.Default.Reset();
|
{
|
||||||
return Settings.Default;
|
Settings.Default.Reset();
|
||||||
}
|
return Settings.Default;
|
||||||
else {
|
}
|
||||||
return Settings.LoadConfig(provider.ConfigFilePath);
|
else
|
||||||
}
|
{
|
||||||
}
|
return Settings.LoadConfig(provider.ConfigFilePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -76,42 +79,87 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
/// <param name="client"></param>
|
/// <param name="client"></param>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
private void SetSessionState(IOpenStackCredential credential, IOpenStackClient client, ServiceProvider provider)
|
private void SetSessionState(IOpenStackCredential credential, IOpenStackClient client, ServiceProvider provider)
|
||||||
{
|
{
|
||||||
// Setup the environment based on what came back from Auth..
|
// Setup the environment based on what came back from Auth..
|
||||||
|
|
||||||
Context context = new Context();
|
Context context = new Context();
|
||||||
context.ServiceCatalog = credential.ServiceCatalog;
|
context.ServiceCatalog = credential.ServiceCatalog;
|
||||||
context.Settings = this.GetSettings(provider);
|
context.Settings = this.GetSettings(provider);
|
||||||
context.ProductName = "OpenStack-WinCLI";
|
context.ProductName = "OpenStack-WinCLI";
|
||||||
context.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
context.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||||
|
context.CurrentServiceProvider = provider;
|
||||||
|
context.CurrentRegion = provider.AvailabilityZones.Where(z => z.IsDefault == true).Single().Name;
|
||||||
|
|
||||||
|
this.Session.PSVariable.Set(new PSVariable("Context", context));
|
||||||
|
this.Session.PSVariable.Set(new PSVariable("CoreClient", client));
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
//==================================================================================================
|
||||||
|
private RegistrationManager GetRegistrationManager(string serviceProviderName)
|
||||||
|
{
|
||||||
|
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||||
|
|
||||||
this.Session.PSVariable.Set(new PSVariable("Context", context));
|
// Iterate through all Assemblies in Current AppDomain that contain a RegistrationManager class..
|
||||||
this.Session.PSVariable.Set(new PSVariable("CoreClient", client));
|
|
||||||
}
|
foreach (Assembly assembly in assemblies)
|
||||||
|
{
|
||||||
|
Type[] types = assembly.GetTypes().Where(b => b != null && b.BaseType != null && b.BaseType.UnderlyingSystemType.FullName == "OpenStack.Client.Powershell.Utility.RegistrationManager").ToArray<Type>();
|
||||||
|
|
||||||
|
// Now that we found one, make sure that it's the one we're looking for..
|
||||||
|
|
||||||
|
foreach (Type type in types)
|
||||||
|
{
|
||||||
|
MemberInfo info = type;
|
||||||
|
foreach (object attribute in info.GetCustomAttributes(true))
|
||||||
|
{
|
||||||
|
ServiceProviderAttribute identifier = attribute as ServiceProviderAttribute;
|
||||||
|
|
||||||
|
if (identifier != null && identifier.Name == serviceProviderName)
|
||||||
|
{
|
||||||
|
var result = (RegistrationManager)Activator.CreateInstance(type, null);
|
||||||
|
if (result == null) {
|
||||||
|
throw new NullReferenceException("Could not create a valid RegistrationManager instance for " + type.FullName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new OpenstackCoreRegistrationManager();
|
||||||
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public void LoadCore(ServiceProvider provider)
|
public void LoadCore(ServiceProvider provider)
|
||||||
{
|
{
|
||||||
OpenstackCoreRegistrationManager manager = new OpenstackCoreRegistrationManager();
|
OpenstackCoreRegistrationManager manager = new OpenstackCoreRegistrationManager();
|
||||||
RegistrationResponse response = manager.Register(provider);
|
RegistrationResponse response = manager.Register(provider);
|
||||||
|
|
||||||
// Connect to the Service Provider..
|
|
||||||
|
|
||||||
|
// Setup our shared Cancellation Token Source so that Cmdlets \ Users can abort long running operations..
|
||||||
var client = OpenStackClientFactory.CreateClient<OpenStackClient>(response.Credentials, CancellationToken.None, null);
|
|
||||||
var connectTask = client.Connect();
|
|
||||||
connectTask.Wait();
|
|
||||||
|
|
||||||
this.SetSessionState(response.Credentials, client, provider);
|
CancellationTokenSource source = new CancellationTokenSource();
|
||||||
|
CancellationToken token = source.Token;
|
||||||
|
this.Session.PSVariable.Set(new PSVariable("CancellationTokenSource", source));
|
||||||
|
|
||||||
ConfigurationManager configManager = new ConfigurationManager();
|
// Connect to the Service Provider..
|
||||||
configManager.WriteServiceProvider(response.Provider, true);
|
|
||||||
}
|
var client = OpenStackClientFactory.CreateClient<OpenStackClient>(response.Credentials, token, String.Empty);
|
||||||
|
var connectTask = client.Connect();
|
||||||
|
connectTask.Wait();
|
||||||
|
|
||||||
|
this.SetSessionState(response.Credentials, client, provider);
|
||||||
|
|
||||||
|
ConfigurationManager configManager = new ConfigurationManager();
|
||||||
|
configManager.WriteServiceProvider(response.Provider, true);
|
||||||
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@ -119,45 +167,47 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
public void LoadExtension(ServiceProvider targetProvider)
|
public void LoadExtension(ServiceProvider targetProvider)
|
||||||
{
|
{
|
||||||
string moduleName = targetProvider.Name;
|
string moduleName = targetProvider.Name;
|
||||||
AppDomain currentDomain = AppDomain.CurrentDomain;
|
AppDomain currentDomain = AppDomain.CurrentDomain;
|
||||||
Evidence asEvidence = currentDomain.Evidence;
|
Evidence asEvidence = currentDomain.Evidence;
|
||||||
|
IOpenStackClient client = null;
|
||||||
|
IOpenStackCredential credential = null;
|
||||||
|
|
||||||
|
// Load up the default config file..
|
||||||
|
|
||||||
ConfigurationManager configManager = new ConfigurationManager();
|
ConfigurationManager configManager = new ConfigurationManager();
|
||||||
configManager.Load();
|
configManager.Load(false);
|
||||||
|
|
||||||
// Load the specified module. We take a before and after snapshot of assemblies loaded in the current AppDomain.
|
// Load the specified module into the Current AppDomain...
|
||||||
// The targetList represents only what's been added...
|
|
||||||
|
|
||||||
Assembly[] originalList = currentDomain.GetAssemblies();
|
|
||||||
this.Session.InvokeCommand.InvokeScript("Import-Module " + moduleName + " -DisableNameChecking");
|
this.Session.InvokeCommand.InvokeScript("Import-Module " + moduleName + " -DisableNameChecking");
|
||||||
Assembly[] modifiedList = currentDomain.GetAssemblies();
|
|
||||||
var targetList = modifiedList.Except(originalList);
|
|
||||||
|
|
||||||
foreach (Assembly assembly in targetList)
|
// Register the Module if it isn't already and grab the resulting credentials for Auth..
|
||||||
{
|
|
||||||
// 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 = this.GetRegistrationManager(moduleName);
|
||||||
RegistrationManager manager = (RegistrationManager)Activator.CreateInstance(registrationManagerType, null);
|
RegistrationResponse response = manager.Register(configManager.GetServiceProvider(moduleName));
|
||||||
RegistrationResponse response = manager.Register(configManager.GetServiceProvider(moduleName));
|
credential = response.Credentials;
|
||||||
IOpenStackCredential credential = response.Credentials;
|
|
||||||
|
// Setup our shared Cancellation Token Source so that Cmdlets \ Users can abort long running operations..
|
||||||
// Create our Extension Client and stash it....
|
|
||||||
|
|
||||||
var client = OpenStackClientFactory.CreateClient<OpenStackClient>(credential);
|
CancellationTokenSource source = new CancellationTokenSource();
|
||||||
var connectTask = client.Connect();
|
CancellationToken token = source.Token;
|
||||||
connectTask.Wait();
|
this.Session.PSVariable.Set(new PSVariable("CancellationTokenSource", source));
|
||||||
|
|
||||||
// Save the credentials ..
|
// Authenticate and create our Extension Client and stash it....
|
||||||
|
|
||||||
|
|
||||||
configManager.WriteServiceProvider(response.Provider);
|
client = OpenStackClientFactory.CreateClient<OpenStackClient>(credential, token, String.Empty);
|
||||||
|
var connectTask = client.Connect();
|
||||||
|
connectTask.Wait();
|
||||||
|
|
||||||
// Store Context and Client so that all PS-Providers and Cmdlets have access to it..
|
// Save the credentials if there are any changes (The RegistrationManager may have prompted for missing Credentials)
|
||||||
|
|
||||||
|
configManager.WriteServiceProvider(response.Provider);
|
||||||
|
|
||||||
this.SetSessionState(credential, client, targetProvider);
|
// Store Context and Client so that all PS-Providers and Cmdlets have access to it..
|
||||||
}
|
|
||||||
|
this.SetSessionState(credential, client, targetProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,13 @@ using System.Linq;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
using OpenStack.Client.Powershell.Utility;
|
using OpenStack.Client.Powershell.Utility;
|
||||||
using OpenStack.Identity;
|
using OpenStack.Identity;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Utility
|
namespace OpenStack.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
|
[ServiceProviderAttribute("Default")]
|
||||||
public class OpenstackCoreRegistrationManager : RegistrationManager
|
public class OpenstackCoreRegistrationManager : RegistrationManager
|
||||||
{
|
{
|
||||||
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
||||||
|
@ -64,13 +64,72 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
//==================================================================================================
|
||||||
|
private string ReadPassword()
|
||||||
|
{
|
||||||
|
string password = "";
|
||||||
|
ConsoleKeyInfo info = Console.ReadKey(true);
|
||||||
|
|
||||||
|
while (info.Key != ConsoleKey.Enter)
|
||||||
|
{
|
||||||
|
if (info.Key != ConsoleKey.Backspace)
|
||||||
|
{
|
||||||
|
Console.Write("*");
|
||||||
|
password += info.KeyChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (info.Key == ConsoleKey.Backspace)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(password))
|
||||||
|
{
|
||||||
|
// remove one character from the list of password characters
|
||||||
|
|
||||||
|
password = password.Substring(0, password.Length - 1);
|
||||||
|
|
||||||
|
// get the location of the cursor
|
||||||
|
|
||||||
|
int pos = Console.CursorLeft;
|
||||||
|
|
||||||
|
// move the cursor to the left by one character
|
||||||
|
|
||||||
|
Console.SetCursorPosition(pos - 1, Console.CursorTop);
|
||||||
|
|
||||||
|
// replace it with space
|
||||||
|
|
||||||
|
Console.Write(" ");
|
||||||
|
|
||||||
|
// move the cursor to the left by one character again
|
||||||
|
|
||||||
|
Console.SetCursorPosition(pos - 1, Console.CursorTop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
info = Console.ReadKey(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add a new line because user pressed enter at the end of their password
|
||||||
|
|
||||||
|
Console.WriteLine();
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
//==================================================================================================
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
private string PromptForCredentialElement(CredentialElement element)
|
private string PromptForCredentialElement(CredentialElement element)
|
||||||
{
|
{
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
Console.WriteLine(element.DisplayName + " :");
|
Console.WriteLine(element.DisplayName + " :");
|
||||||
Console.WriteLine("");
|
Console.WriteLine("");
|
||||||
return Console.ReadLine();
|
if (element.DisplayName.ToLower() == "password")
|
||||||
|
{
|
||||||
|
return this.ReadPassword();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Console.ReadLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
38
Openstack.Client.Powershell/Utility/ServiceMap.cs
Normal file
38
Openstack.Client.Powershell/Utility/ServiceMap.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Openstack.Client.Powershell.Utility
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum CoreServices
|
||||||
|
{
|
||||||
|
Identity,
|
||||||
|
ObjectStorage,
|
||||||
|
ImageManagement,
|
||||||
|
BlockStorage,
|
||||||
|
Compute
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class ServiceMap
|
||||||
|
{
|
||||||
|
private string _source;
|
||||||
|
private string _target;
|
||||||
|
|
||||||
|
public string Target
|
||||||
|
{
|
||||||
|
get { return _target; }
|
||||||
|
set { _target = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Source
|
||||||
|
{
|
||||||
|
get { return _source; }
|
||||||
|
set { _source = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -18,9 +18,27 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
|
|
||||||
namespace OpenStack.Client.Powershell.Utility
|
namespace OpenStack.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public class ServiceMaps : List<ServiceMap>
|
||||||
|
{
|
||||||
|
|
||||||
|
//public string TranslateServiceName(string serviceContract)
|
||||||
|
//{
|
||||||
|
// return this.Where(n => n.Source == serviceContract).Single().Target;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public string TranslateServiceName(CoreServices service)
|
||||||
|
{
|
||||||
|
return this.Where(n => n.Source == service.ToString()).Single().Target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class ServiceProvider
|
public class ServiceProvider
|
||||||
{
|
{
|
||||||
private string _name;
|
private string _name;
|
||||||
@ -30,6 +48,20 @@ namespace OpenStack.Client.Powershell.Utility
|
|||||||
private bool _isDirty = false;
|
private bool _isDirty = false;
|
||||||
private List<CredentialElement> _credentialElements = new List<CredentialElement>();
|
private List<CredentialElement> _credentialElements = new List<CredentialElement>();
|
||||||
private string _configFilePath;
|
private string _configFilePath;
|
||||||
|
private IEnumerable<AvailabilityZone> _availabilityZones;
|
||||||
|
private ServiceMaps _serviceMaps;
|
||||||
|
|
||||||
|
public ServiceMaps ServiceMaps
|
||||||
|
{
|
||||||
|
get { return _serviceMaps; }
|
||||||
|
set { _serviceMaps = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<AvailabilityZone> AvailabilityZones
|
||||||
|
{
|
||||||
|
get { return _availabilityZones; }
|
||||||
|
set { _availabilityZones = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public string ConfigFilePath
|
public string ConfigFilePath
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Openstack.Client.Powershell.Utility
|
||||||
|
{
|
||||||
|
public class ServiceProviderAttribute : Attribute
|
||||||
|
{
|
||||||
|
private string _name;
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _name; }
|
||||||
|
set { _name = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServiceProviderAttribute(string name)
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configSections>
|
<configSections>
|
||||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<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>
|
</sectionGroup>
|
||||||
</configSections>
|
</configSections>
|
||||||
<userSettings>
|
<userSettings>
|
||||||
@ -12,4 +12,13 @@
|
|||||||
</setting>
|
</setting>
|
||||||
</OpenStack.Client.Powershell.Properties.Settings>
|
</OpenStack.Client.Powershell.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /></startup>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
|
Binary file not shown.
@ -1,52 +0,0 @@
|
|||||||
<?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>
|
|
||||||
<!--Pro-->
|
|
||||||
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens" />
|
|
||||||
<add key="Username" value="" />
|
|
||||||
<add key="Password" value="" />
|
|
||||||
<add key="DefaultTenantId" value="" />
|
|
||||||
</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>
|
|
@ -1,81 +0,0 @@
|
|||||||
# ---------------------------------------------------------------
|
|
||||||
# Set up support methods first..
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
|
|
||||||
function is64bit() {
|
|
||||||
return ([IntPtr]::Size -eq 8)
|
|
||||||
}
|
|
||||||
|
|
||||||
function get-programfilesdir() {
|
|
||||||
if (is64bit -eq $true) {
|
|
||||||
(Get-Item "Env:ProgramFiles(x86)").Value
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
(Get-Item "Env:ProgramFiles").Value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
# Set up the default windows size and color....
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
|
|
||||||
#$DebugPreference=$VerbosePreference="Continue"
|
|
||||||
#$DebugPreference = "Continue"
|
|
||||||
$a = (Get-Host).UI.RawUI
|
|
||||||
$b = $a.WindowSize
|
|
||||||
$b.Width = 109
|
|
||||||
$b.Height = 61
|
|
||||||
$a.WindowSize = $b
|
|
||||||
$a.BackgroundColor = "black"
|
|
||||||
$a.ForegroundColor = "green"
|
|
||||||
|
|
||||||
cls
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
# Register known providers, write out welcome and status messages..
|
|
||||||
# -----------------------------------------------------------------
|
|
||||||
|
|
||||||
$a.BackgroundColor = "black"
|
|
||||||
Echo ''
|
|
||||||
$a.ForegroundColor = "gray"
|
|
||||||
Echo '========================================================================================'
|
|
||||||
$a.ForegroundColor = "yellow"
|
|
||||||
Echo 'Welcome to the OpenStack Powershell Environment.'
|
|
||||||
$a.ForegroundColor = "gray"
|
|
||||||
Echo '========================================================================================'
|
|
||||||
Echo ''
|
|
||||||
$a.ForegroundColor = "green"
|
|
||||||
echo ' ==> Registering Providers...'
|
|
||||||
|
|
||||||
$tempvar = get-programfilesdir
|
|
||||||
$tempvar = $tempvar + "\Openstack\OpenStack-Powershell"
|
|
||||||
cd $tempvar
|
|
||||||
import-module .\CLIManifest.psd1 -DisableNameChecking
|
|
||||||
|
|
||||||
echo ' ==> Applying Command Aliases...'
|
|
||||||
echo ' ==> Registering Views...'
|
|
||||||
echo ''
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
# Reset Shell to default colors..
|
|
||||||
# ---------------------------------------------------------------
|
|
||||||
|
|
||||||
$a.ForegroundColor = "yellow"
|
|
||||||
echo 'Ready..'
|
|
||||||
$a.ForegroundColor = "green"
|
|
||||||
echo ''
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
<?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="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>
|
|
||||||
<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>
|
|
@ -1,21 +0,0 @@
|
|||||||
@{
|
|
||||||
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="OpenstackShell.format.ps1xml"
|
|
||||||
FileList='Openstack.config'
|
|
||||||
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,47 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
|
||||||
<ReleaseManifest>
|
|
||||||
<Release version="1.3.2.7" IsCurrentRelease="True" InstallPath="Builds:\1-3-2-7\WinCLI1.3.2.7.zip">
|
|
||||||
<Notes>
|
|
||||||
New Features
|
|
||||||
* Easier Zone management with Set-Zone and Get-Zones
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
<Release version="1.3.0.2">
|
|
||||||
<Notes>
|
|
||||||
|
|
||||||
New Features
|
|
||||||
* Easier Zone management with Set-Zone and Get-Zones
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
<Release version="1.3.0.2">
|
|
||||||
<Notes>
|
|
||||||
|
|
||||||
New Features
|
|
||||||
* Easier Zone management with Set-Zone and Get-Zones
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
<Release version="1.3.0.1">
|
|
||||||
<Notes>
|
|
||||||
|
|
||||||
New Features
|
|
||||||
* Support for listing, adding, attaching, detaching and removing block volumes
|
|
||||||
* Support for creating and removing block storage snapshots
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
<Release version="1.2.0.6">
|
|
||||||
<Notes>
|
|
||||||
|
|
||||||
New Features
|
|
||||||
* Migrate-Drive support for migrating full data sets from external sources
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
<Release version="1.2.0.1">
|
|
||||||
<Notes>
|
|
||||||
|
|
||||||
New Features
|
|
||||||
* Full access to the OpenStack compute infrastructure
|
|
||||||
* CDN support
|
|
||||||
</Notes>
|
|
||||||
</Release>
|
|
||||||
|
|
||||||
</ReleaseManifest>
|
|
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
|||||||
@{
|
|
||||||
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="OpenstackShell.format.ps1xml"
|
|
||||||
FileList='Openstack.config'
|
|
||||||
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,51 +0,0 @@
|
|||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\Aliases.txt
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\ScratchPad\AnotherTest.txt
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\CLI.config
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\CLI.config.example
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\OpenstackShell.format.ps1xml
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\Microsoft.PowerShell_profile.ps1
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\CLIManifest.psd1
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Deployment\ReleaseNotes.xml
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.dll.config
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\AWSSDK.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Common.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Objects.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\System.Net.Http.Formatting.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Newtonsoft.Json.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Common.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Openstack.Objects.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\AWSSDK.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\System.Net.Http.Formatting.xml
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.csprojResolveAssemblyReference.cache
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.g.resources
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\BouncyCastle.Crypto.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\OpenStack-CLI\Openstack.Client.Powershell\bin\Release\Newtonsoft.Json.xml
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.csprojResolveAssemblyReference.cache
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.g.resources
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\obj\Debug\Openstack.Client.Powershell.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\Aliases.txt
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\ScratchPad\AnotherTest.txt
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\CLI.config
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\CLI.config.example
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\OpenstackShell.format.ps1xml
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\Microsoft.PowerShell_profile.ps1
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\CLIManifest.psd1
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Deployment\ReleaseNotes.xml
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.dll.config
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Client.Powershell.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\AWSSDK.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Newtonsoft.Json.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Common.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\System.Net.Http.Formatting.dll
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.Common.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Openstack.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\AWSSDK.pdb
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\Newtonsoft.Json.xml
|
|
||||||
C:\Users\tplummer\Source\Repos\Openstack-NewCLI\Openstack.Client.Powershell\bin\Release\System.Net.Http.Formatting.xml
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
0
Openstack.Client.Powershell/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
@ -2,5 +2,9 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="AWSSDK" version="2.0.11.0" targetFramework="net45" />
|
<package id="AWSSDK" version="2.0.11.0" targetFramework="net45" />
|
||||||
<package id="BouncyCastle" version="1.7.0" targetFramework="net40" />
|
<package id="BouncyCastle" version="1.7.0" targetFramework="net40" />
|
||||||
<package id="Newtonsoft.Json" version="4.5.7" targetFramework="net45" />
|
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
|
||||||
|
<package id="OpenStack-SDK-DotNet" version="0.9.0.0" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
@ -5,7 +5,7 @@
|
|||||||
<add key="TestServerName" value="TestServer" />
|
<add key="TestServerName" value="TestServer" />
|
||||||
<add key="TestNetworkName" value="TestNetwork" />
|
<add key="TestNetworkName" value="TestNetwork" />
|
||||||
<add key="TestPortName" value="TestPort" />
|
<add key="TestPortName" value="TestPort" />
|
||||||
<add key="TestRouterName" value="TestRouter" />
|
<add key="TestRouterName" value="TestRouterOO" />
|
||||||
<add key="TestSecurityGroupName" value="TestSecurityGroup" />
|
<add key="TestSecurityGroupName" value="TestSecurityGroup" />
|
||||||
<add key="TestSnapshotName" value="TestSnapshot" />
|
<add key="TestSnapshotName" value="TestSnapshot" />
|
||||||
<add key="TestStorageContainerName" value="TestContainer" />
|
<add key="TestStorageContainerName" value="TestContainer" />
|
||||||
@ -32,10 +32,14 @@
|
|||||||
</StorageManagement>
|
</StorageManagement>
|
||||||
<IdentityServices>
|
<IdentityServices>
|
||||||
<ServiceProvider name="Rackspace" isDefault="true">
|
<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" />
|
<AvailabilityZones>
|
||||||
<add key="Username" value="" displayName="User name" isMandatory="true" />
|
<AvailabilityZone id="1" isDefault="True" name="Rregion-a.geo-1" shellForegroundColor="Green" />
|
||||||
<add key="Password" value="" displayName="Password" isMandatory="true" />
|
<AvailabilityZone id="2" isDefault="False" name="Rregion-b.geo-1" shellForegroundColor="Green" />
|
||||||
<add key="DefaultTenantId" value="" displayName="Default Tenant Id" isMandatory="true" />
|
</AvailabilityZones>
|
||||||
|
<add key="AuthenticationServiceURI" value="" 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>
|
</ServiceProvider>
|
||||||
</IdentityServices>
|
</IdentityServices>
|
||||||
<ComputeServices>
|
<ComputeServices>
|
||||||
@ -44,9 +48,9 @@
|
|||||||
<add key="EnableCredentialTracking" value="true" />
|
<add key="EnableCredentialTracking" value="true" />
|
||||||
<add key="SSHClientPath" value="C:\Users\tplummer\Desktop\Utilities\Putty.exe" />
|
<add key="SSHClientPath" value="C:\Users\tplummer\Desktop\Utilities\Putty.exe" />
|
||||||
</ComputeServices>
|
</ComputeServices>
|
||||||
<AvailabilityZones>
|
<!--<AvailabilityZones>
|
||||||
<AvailabilityZone id="1" isDefault="True" name="region-a.geo-1" shellForegroundColor="Green" />
|
<AvailabilityZone id="1" isDefault="True" name="region-a.geo-1" shellForegroundColor="Green" />
|
||||||
<AvailabilityZone id="2" isDefault="False" name="region-b.geo-1" shellForegroundColor="Green" />
|
<AvailabilityZone id="2" isDefault="False" name="region-b.geo-1" shellForegroundColor="Green" />
|
||||||
</AvailabilityZones>
|
</AvailabilityZones>-->
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
@ -8,7 +8,7 @@ ModuleVersion="1.0.0.0"
|
|||||||
PowerShellVersion="2.0"
|
PowerShellVersion="2.0"
|
||||||
CLRVersion="4.0.30319"
|
CLRVersion="4.0.30319"
|
||||||
FileList=''
|
FileList=''
|
||||||
RequiredAssemblies = 'OpenStack.dll', 'OpenStack.Common.dll'
|
RequiredAssemblies = 'OpenStack.dll'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\Rackspace\</OutputPath>
|
<OutputPath>..\..\..\..\..\Documents\WindowsPowerShell\Modules\Openstack\Rackspace\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
@ -32,6 +32,14 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.6.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="OpenStack, Version=0.9.1.0, Culture=neutral, PublicKeyToken=baf191d8aca7391c, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\packages\OpenStack-SDK-DotNet.0.9.1.0\lib\net40\OpenStack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Management" />
|
<Reference Include="System.Management" />
|
||||||
@ -39,6 +47,14 @@
|
|||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
|
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Net.Http.Extensions">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.Primitives">
|
||||||
|
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net45\System.Net.Http.Primitives.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@ -51,6 +67,7 @@
|
|||||||
<Compile Include="Utility\RackspaceRegistrationManager.cs" />
|
<Compile Include="Utility\RackspaceRegistrationManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="Deployment\Rackspace.config">
|
<None Include="Deployment\Rackspace.config">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
@ -61,10 +78,6 @@
|
|||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<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">
|
<ProjectReference Include="..\Openstack.Client.Powershell\Openstack.Client.Powershell.csproj">
|
||||||
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
|
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
|
||||||
<Name>Openstack.Client.Powershell</Name>
|
<Name>Openstack.Client.Powershell</Name>
|
||||||
@ -73,8 +86,13 @@
|
|||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>copy .\Deployment\Rackspace.psd1 C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\Rackspace</PostBuildEvent>
|
<PostBuildEvent>copy .\Deployment\Rackspace.psd1 C:\Users\tplummer\Documents\WindowsPowerShell\Modules\Openstack\Rackspace\Rackspace.psd1</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
|
||||||
|
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
|
||||||
|
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
|
||||||
|
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
|
||||||
|
</Target>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
<Target Name="BeforeBuild">
|
<Target Name="BeforeBuild">
|
||||||
|
@ -4,12 +4,13 @@ using System.Linq;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Openstack.Client.Powershell.Utility;
|
||||||
using OpenStack.Client.Powershell.Utility;
|
using OpenStack.Client.Powershell.Utility;
|
||||||
using OpenStack.Identity;
|
using OpenStack.Identity;
|
||||||
|
|
||||||
namespace Rackspace.Client.Powershell.Utility
|
namespace Rackspace.Client.Powershell.Utility
|
||||||
{
|
{
|
||||||
|
[ServiceProviderAttribute("Rackspace")]
|
||||||
public class RackspaceRegistrationManager : RegistrationManager
|
public class RackspaceRegistrationManager : RegistrationManager
|
||||||
{
|
{
|
||||||
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
@{
|
|
||||||
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"
|
|
||||||
FormatsToProcess=""
|
|
||||||
FileList=''
|
|
||||||
RequiredAssemblies = 'Openstack.dll', 'Openstack.Common.dll'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
8
Rackspace.Client.Powershell/packages.config
Normal file
8
Rackspace.Client.Powershell/packages.config
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
|
||||||
|
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net45" />
|
||||||
|
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net45" />
|
||||||
|
<package id="OpenStack-SDK-DotNet" version="0.9.0.0" targetFramework="net45" />
|
||||||
|
</packages>
|
Loading…
x
Reference in New Issue
Block a user