Retire stackforge/openstack-cli-powershell
This commit is contained in:
parent
25efa99a9c
commit
803406e7e0
165
.gitignore
vendored
165
.gitignore
vendored
@ -1,165 +0,0 @@
|
||||
## 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/
|
||||
*.nupkg
|
||||
|
||||
# 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
|
@ -1,4 +0,0 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=stackforge/openstack-cli-powershell.git
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<solution>
|
||||
<add key="disableSourceControlIntegration" value="true" />
|
||||
</solution>
|
||||
</configuration>
|
BIN
.nuget/NuGet.exe
BIN
.nuget/NuGet.exe
Binary file not shown.
@ -1,151 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||
|
||||
<!-- Property that enables building a package from a project -->
|
||||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||
|
||||
<!-- Determines if package restore consent is required to restore packages -->
|
||||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||
|
||||
<!-- Download NuGet.exe if it does not already exist -->
|
||||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||
<!--
|
||||
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||
<!-- Windows specific commands -->
|
||||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackagesProjectConfig>packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<Choose>
|
||||
<When Condition="Exists('$(PackagesProjectConfig)')">
|
||||
<PropertyGroup>
|
||||
<PackagesConfig>$(PackagesProjectConfig)</PackagesConfig>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
<When Condition="Exists('packages.config')">
|
||||
<PropertyGroup>
|
||||
<PackagesConfig>packages.config</PackagesConfig>
|
||||
</PropertyGroup>
|
||||
</When>
|
||||
</Choose>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- NuGet command -->
|
||||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
|
||||
|
||||
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||
|
||||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||
|
||||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||
RestorePackages;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
|
||||
<!-- Make the build depend on restore packages -->
|
||||
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||
$(BuildDependsOn);
|
||||
BuildPackage;
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||
<!--
|
||||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||
parallel builds will have to wait for it to complete.
|
||||
-->
|
||||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_DownloadNuGet">
|
||||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(BuildCommand)"
|
||||
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||
|
||||
<Exec Command="$(BuildCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
</Target>
|
||||
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<OutputFilename ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Core" />
|
||||
<Using Namespace="System" />
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Net" />
|
||||
<Using Namespace="Microsoft.Build.Framework" />
|
||||
<Using Namespace="Microsoft.Build.Utilities" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
try {
|
||||
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex);
|
||||
return false;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle1.7" version="1.7" />
|
||||
</packages>
|
@ -1,106 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B6C5D486-BEDE-4E4F-8035-63B72513E4BD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AcmeInc.Openstack.Client.Powershell</RootNamespace>
|
||||
<AssemblyName>AcmeInc.Openstack.Client.Powershell</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\..\..\Documents\WindowsPowerShell\Modules\AcmeInc\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Newtonsoft.Json.6.0.3\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.Core" />
|
||||
<Reference Include="System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<HintPath>..\packages\System.Management.Automation.6.1.7601.17515\lib\net45\System.Management.Automation.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.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.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Cmdlets\HelloAcmeIncCmdlet.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utility\AcmeRegistrationManager.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="Deployment\AcmeInc.nuspec" />
|
||||
<None Include="Deployment\AcmeInc.psd1">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Deployment\tools\chocolateyInstall.ps1" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Openstack.Client.Powershell\Openstack.Client.Powershell.csproj">
|
||||
<Project>{32bac168-2ec8-4074-9e6d-8c13460dcfad}</Project>
|
||||
<Name>Openstack.Client.Powershell</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Deployment\ServiceProvider.xml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>md %25USERPROFILE%25\Documents\WindowsPowerShell\Modules\AcmeInc
|
||||
copy .\Deployment\AcmeInc.psd1 %25USERPROFILE%25\Documents\WindowsPowerShell\Modules\AcmeInc</PostBuildEvent>
|
||||
</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.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,37 +0,0 @@
|
||||
//* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
|
||||
namespace AcmeInc.Client.Powershell.Cmdlets
|
||||
{
|
||||
[Cmdlet("Hello", "AcmeInc", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class HelloAcmeIncCmdlet : PSCmdlet
|
||||
{
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
Console.WriteLine("Hello World, from AcmeInc");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
|
||||
<package>
|
||||
<metadata>
|
||||
<id>acme-cli-powershell</id>
|
||||
<title>acme-cli-powershell</title>
|
||||
<version>2.0.0</version>
|
||||
<authors>L.Jenkins</authors>
|
||||
<owners>Example Inc</owners>
|
||||
<summary>Thid package allows Users to manage their Openstack environments from the Powershell command line.</summary>
|
||||
<description>Thid package allows Users to manage their Openstack environments from the Powershell command line.</description>
|
||||
<tags>Acme OpenStack Powershell CLI Windows</tags>
|
||||
<copyright>2014</copyright>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<!--<iconUrl>https://raw.github.com/__CHOCO_PKG_OWNER_REPO__/master/__NAME__/__NAME__.png</iconUrl>-->
|
||||
<releaseNotes>This first release demonstrates the Mutli-Vendor functionality as well as a Read-onoly version of the ObjectStorage Provider.</releaseNotes>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="tools\**" target="tools" />
|
||||
</files>
|
||||
</package>
|
@ -1,19 +0,0 @@
|
||||
@{
|
||||
ModuleToProcess = 'AcmeInc.OpenStack.Client.Powershell.dll'
|
||||
GUID="{847a28a4-6407-4aa6-8070-a4a51396db70}"
|
||||
Author="Lateralus"
|
||||
CompanyName="Acme Corporation"
|
||||
Copyright="DoJuJitsu"
|
||||
ModuleVersion="1.0.0.0"
|
||||
PowerShellVersion="2.0"
|
||||
CLRVersion="4.0.30319"
|
||||
FileList=''
|
||||
RequiredAssemblies = 'OpenStack.dll'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
<ServiceProvider name="AcmeInc" isDefault="false">
|
||||
<add key="AuthenticationServiceURI" value="https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/" 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"/>
|
||||
<AvailabilityZones>
|
||||
<AvailabilityZone id="1" isDefault="True" name="Acmeregion-a.geo-1" shellForegroundColor="Green" />
|
||||
<AvailabilityZone id="2" isDefault="False" name="Acmeregion-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>
|
@ -1,38 +0,0 @@
|
||||
|
||||
# Install the Extensions Package...
|
||||
|
||||
$packageName = 'acme-cli-powershell'
|
||||
$installerType = 'msi'
|
||||
$url = $env:USERPROFILE + '\Source\Builds\AcmeInc.Openstack.Deployment.msi'
|
||||
$silentArgs = '/quiet'
|
||||
$validExitCodes = @(0)
|
||||
|
||||
Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" -validExitCodes $validExitCodes
|
||||
|
||||
try
|
||||
{
|
||||
# Add the extensions location to PSModulePath for easy loading later on..
|
||||
|
||||
$p = [Environment]::GetEnvironmentVariable("PSModulePath")
|
||||
$p += ";" + $env:USERPROFILE + "\Documents\WindowsPowerShell\Modules\AcmeInc"
|
||||
[Environment]::SetEnvironmentVariable("PSModulePath", $p)
|
||||
|
||||
# Import our Openstack.Client.Powershell assembly. This has the ConfigurationMAnager type which lets you
|
||||
# register your Service Provider information.
|
||||
|
||||
$configManagerAsmPath = $env:USERPROFILE + "\Documents\WindowsPowerShell\Modules\Openstack-core\Openstack.Client.Powershell.dll"
|
||||
add-type -Path ($configManagerAsmPath)
|
||||
|
||||
# Register the Service Provider. This requires the Extension Author to have a ServiceProvider.xml definition file in the
|
||||
# Deployment Folder.
|
||||
|
||||
$serviceProviderPath = $env:USERPROFILE + "\Documents\WindowsPowerShell\Modules\AcmeInc\Deployment\ServiceProvider.xml"
|
||||
$manager = New-Object -TypeName OpenStack.Client.Powershell.Utility.ConfigurationManager
|
||||
$manager.WriteServiceProvider($serviceProviderPath)
|
||||
Write-ChocolateySuccess "$packageName"
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-ChocolateyFailure "$packageName" "$($_.Exception.Message)"
|
||||
throw
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AcmeInc.OpenStack.Client.Powershell")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("AcmeInc.OpenStack.Client.Powershell")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("3989338b-6fb6-4dc9-9982-52771596edc6")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using OpenStack.Identity;
|
||||
|
||||
namespace AcmeInc.OpenStack.Client.Powershell.Utility
|
||||
{
|
||||
[ServiceProviderAttribute("AcmeInc")]
|
||||
public class AcmeRegistrationManager : RegistrationManager
|
||||
{
|
||||
public override RegistrationResponse Register(ServiceProvider serviceProvider)
|
||||
{
|
||||
this.ValidateCredentialElements(ref serviceProvider);
|
||||
|
||||
string authenticationEndpoint = serviceProvider.CredentialElements.Where(ce => ce.Key == "AuthenticationServiceURI").Single().Value;
|
||||
string userName = serviceProvider.CredentialElements.Where(ce => ce.Key == "Username").Single().Value;
|
||||
string password = serviceProvider.CredentialElements.Where(ce => ce.Key == "Password").Single().Value;
|
||||
string tenantId = serviceProvider.CredentialElements.Where(ce => ce.Key == "DefaultTenantId").Single().Value;
|
||||
|
||||
IOpenStackCredential credential = new OpenStackCredential(new Uri (authenticationEndpoint), userName, password, tenantId);
|
||||
return new RegistrationResponse(credential, serviceProvider);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<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>
|
@ -1,9 +0,0 @@
|
||||
<?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.3" 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>
|
@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "AcmeInc.Openstack.Deployment", "AcmeInc.Openstack.Deployment\AcmeInc.Openstack.Deployment.vdproj", "{D2DB9636-72E1-47E2-98E8-E23AFD996109}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Default = Debug|Default
|
||||
Release|Default = Release|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D2DB9636-72E1-47E2-98E8-E23AFD996109}.Debug|Default.ActiveCfg = Debug
|
||||
{D2DB9636-72E1-47E2-98E8-E23AFD996109}.Debug|Default.Build.0 = Debug
|
||||
{D2DB9636-72E1-47E2-98E8-E23AFD996109}.Release|Default.ActiveCfg = Release
|
||||
{D2DB9636-72E1-47E2-98E8-E23AFD996109}.Release|Default.Build.0 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
File diff suppressed because it is too large
Load Diff
176
License.txt
176
License.txt
@ -1,176 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Openstack.Client.Powershell.Deployment", "Openstack.Client.Powershell.Deployment\Openstack.Client.Powershell.Deployment.vdproj", "{ED796A88-B8B7-49FC-9B16-2FD43492DADB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Default = Debug|Default
|
||||
Release|Default = Release|Default
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{ED796A88-B8B7-49FC-9B16-2FD43492DADB}.Debug|Default.ActiveCfg = Debug
|
||||
{ED796A88-B8B7-49FC-9B16-2FD43492DADB}.Debug|Default.Build.0 = Debug
|
||||
{ED796A88-B8B7-49FC-9B16-2FD43492DADB}.Release|Default.ActiveCfg = Release
|
||||
{ED796A88-B8B7-49FC-9B16-2FD43492DADB}.Release|Default.Build.0 = Release
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<solution>
|
||||
<add key="disableSourceControlIntegration" value="true" />
|
||||
</solution>
|
||||
</configuration>
|
Binary file not shown.
@ -1,144 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
|
||||
|
||||
<!-- Enable the restore command to run before builds -->
|
||||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages>
|
||||
|
||||
<!-- Property that enables building a package from a project -->
|
||||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
|
||||
|
||||
<!-- Determines if package restore consent is required to restore packages -->
|
||||
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
|
||||
|
||||
<!-- Download NuGet.exe if it does not already exist -->
|
||||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(PackageSources)' == '' ">
|
||||
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
|
||||
<!-- The official NuGet package source (https://www.nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
|
||||
<!--
|
||||
<PackageSource Include="https://www.nuget.org/api/v2/" />
|
||||
<PackageSource Include="https://my-nuget-source/nuget/" />
|
||||
-->
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
|
||||
<!-- Windows specific commands -->
|
||||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
|
||||
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
|
||||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackagesProjectConfig Condition=" '$(OS)' == 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config</PackagesProjectConfig>
|
||||
<PackagesProjectConfig Condition=" '$(OS)' != 'Windows_NT'">$(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config</PackagesProjectConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<PackagesConfig Condition="Exists('$(MSBuildProjectDirectory)\packages.config')">$(MSBuildProjectDirectory)\packages.config</PackagesConfig>
|
||||
<PackagesConfig Condition="Exists('$(PackagesProjectConfig)')">$(PackagesProjectConfig)</PackagesConfig>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- NuGet command -->
|
||||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
|
||||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
|
||||
|
||||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
|
||||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 "$(NuGetExePath)"</NuGetCommand>
|
||||
|
||||
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
|
||||
|
||||
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
|
||||
<NonInteractiveSwitch Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' ">-NonInteractive</NonInteractiveSwitch>
|
||||
|
||||
<PaddedSolutionDir Condition=" '$(OS)' == 'Windows_NT'">"$(SolutionDir) "</PaddedSolutionDir>
|
||||
<PaddedSolutionDir Condition=" '$(OS)' != 'Windows_NT' ">"$(SolutionDir)"</PaddedSolutionDir>
|
||||
|
||||
<!-- Commands -->
|
||||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)</RestoreCommand>
|
||||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols</BuildCommand>
|
||||
|
||||
<!-- We need to ensure packages are restored prior to assembly resolve -->
|
||||
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
|
||||
RestorePackages;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
|
||||
<!-- Make the build depend on restore packages -->
|
||||
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
|
||||
$(BuildDependsOn);
|
||||
BuildPackage;
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CheckPrerequisites">
|
||||
<!-- Raise an error if we're unable to locate nuget.exe -->
|
||||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
|
||||
<!--
|
||||
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
|
||||
This effectively acts as a lock that makes sure that the download operation will only happen once and all
|
||||
parallel builds will have to wait for it to complete.
|
||||
-->
|
||||
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT;DownloadNuGetExe=$(DownloadNuGetExe)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="_DownloadNuGet">
|
||||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
|
||||
<Exec Command="$(RestoreCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
|
||||
<Exec Command="$(BuildCommand)"
|
||||
Condition=" '$(OS)' != 'Windows_NT' " />
|
||||
|
||||
<Exec Command="$(BuildCommand)"
|
||||
LogStandardErrorAsError="true"
|
||||
Condition=" '$(OS)' == 'Windows_NT' " />
|
||||
</Target>
|
||||
|
||||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<OutputFilename ParameterType="System.String" Required="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Core" />
|
||||
<Using Namespace="System" />
|
||||
<Using Namespace="System.IO" />
|
||||
<Using Namespace="System.Net" />
|
||||
<Using Namespace="Microsoft.Build.Framework" />
|
||||
<Using Namespace="Microsoft.Build.Utilities" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
try {
|
||||
OutputFilename = Path.GetFullPath(OutputFilename);
|
||||
|
||||
Log.LogMessage("Downloading latest version of NuGet.exe...");
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.DownloadFile("https://www.nuget.org/nuget.exe", OutputFilename);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Log.LogErrorFromException(ex);
|
||||
return false;
|
||||
}
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
</Project>
|
@ -1,238 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Provider;
|
||||
using OpenStack;
|
||||
using System.Xml.Serialization;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using OpenStack.Client.Powershell.Providers.Storage;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using System.Threading;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using OpenStack.Storage;
|
||||
using System.Security;
|
||||
using System.Linq;
|
||||
using OpenStack.Identity;
|
||||
|
||||
|
||||
namespace OpenStack.Client.Powershell.Providers.Common
|
||||
{
|
||||
public class BaseNavigationCmdletProvider : NavigationCmdletProvider
|
||||
{
|
||||
OpenStackClient _client;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected OpenStackClient Client
|
||||
{
|
||||
get
|
||||
{
|
||||
return (OpenStackClient)this.SessionState.PSVariable.Get("CoreClient").Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.SessionState.PSVariable.Set(new PSVariable("CoreClient", value));
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
protected Settings Settings
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Context.Settings;
|
||||
}
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
protected Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Context)this.SessionState.PSVariable.GetValue("Context", null);
|
||||
}
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//==================================================================================================
|
||||
private bool IsContextInitialized()
|
||||
{
|
||||
if (this.SessionState.PSVariable.GetValue("Context", null) == null) {
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
protected string ConfigFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return (string)this.SessionState.PSVariable.Get("ConfigPath").Value;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
|
||||
}
|
||||
}
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
private void SetZoneColor()
|
||||
{
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
XDocument doc = XDocument.Load(configFilePath);
|
||||
XElement defaultZoneNode = doc.XPathSelectElement("//AvailabilityZone[@isDefault='True']");
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defaultZoneNode.Attribute("shellForegroundColor").Value);
|
||||
this.Host.UI.RawUI.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), defaultZoneNode.Attribute("shellForegroundColor").Value);
|
||||
this.Context.Forecolor = defaultZoneNode.Attribute("shellForegroundColor").Value;
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
protected void InitializeSession()
|
||||
{
|
||||
ConfigurationManager configManager = new ConfigurationManager();
|
||||
ExtensionManager loader = new ExtensionManager(this.SessionState, this.Context);
|
||||
configManager.Load();
|
||||
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
||||
|
||||
if (provider.Name == String.Empty && provider.IsDefault == true)
|
||||
{
|
||||
// Technically Core is already loaded (you're in it :) but this signs in for you to the ServiceProvider selected..
|
||||
// This is just used in the case where it's the Users first time loading the CLI..
|
||||
|
||||
loader.LoadCore(provider);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load any extensions that were supplied by the ServiceProvider...
|
||||
|
||||
loader.LoadExtension(provider);
|
||||
}
|
||||
|
||||
this.SetZoneColor();
|
||||
}
|
||||
#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>
|
||||
/// 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>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="returnContainers"></param>
|
||||
//==================================================================================================
|
||||
protected override void GetChildNames(string path, ReturnContainers returnContainers)
|
||||
{
|
||||
WriteItemObject(path, path, true);
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
//==================================================================================================
|
||||
protected override string GetChildName(string path)
|
||||
{
|
||||
return base.GetChildName(path);
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
//==================================================================================================
|
||||
protected override bool ItemExists(string path)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,383 +0,0 @@
|
||||
///* ============================================================================
|
||||
//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.Text;
|
||||
//using System.Management.Automation;
|
||||
//using OpenStack.Objects.DataAccess;
|
||||
//using System.IO;
|
||||
//using OpenStack.Common.Properties;
|
||||
//using System.Xml;
|
||||
//using System.Xml.Serialization;
|
||||
//using OpenStack.Client.Powershell.Providers.Storage;
|
||||
//using OpenStack.Objects.Domain;
|
||||
//using OpenStack.Objects.Utility;
|
||||
//using OpenStack.Client.Powershell.Providers.Common;
|
||||
//using System.Linq;
|
||||
//using System.Collections.ObjectModel;
|
||||
//using System.Management.Automation.Host;
|
||||
|
||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
//{
|
||||
// public class BasePSCmdlet : PSCmdlet
|
||||
// {
|
||||
// private OpenStack.Objects.DataAccess.ResponseFormat _responseFormat = ResponseFormat.none;
|
||||
// private BaseRepositoryFactory _repositoryFactory;
|
||||
|
||||
// #region Properties
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected BaseUIContainer CurrentContainer
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
// if (tempDrive != null)
|
||||
// {
|
||||
// return tempDrive.CurrentContainer as BaseUIContainer;
|
||||
// }
|
||||
// else return null;
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// Exposes the currently mapped Drive. Belongs in base class???
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected PSDriveInfo Drive
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return this.SessionState.Drive.Current;
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="message"></param>
|
||||
////=========================================================================================
|
||||
// protected void WriteHeaderSection(string headerText)
|
||||
// {
|
||||
// WriteObject(" ");
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("==============================================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
// WriteObject(headerText);
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("==============================================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Green;
|
||||
// }
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////==================================================================================================
|
||||
// protected Context Context
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return (Context)this.SessionState.PSVariable.GetValue("Context", null);
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// this.SessionState.PSVariable.Set(new PSVariable("Context", value));
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected BaseRepositoryFactory RepositoryFactory
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (_repositoryFactory == null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// _repositoryFactory = (BaseRepositoryFactory)this.SessionState.PSVariable.Get("BaseRepositoryFactory").Value;
|
||||
// }
|
||||
// catch (NullReferenceException ex)
|
||||
// {
|
||||
// throw new PSSecurityException("The Authentication process has failed for this session. Please ensure that proper credentials have been supplied before using any of these cmdlets.");
|
||||
// }
|
||||
// return _repositoryFactory;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return _repositoryFactory;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// protected string ConfigFilePath
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// return (string)this.SessionState.PSVariable.Get("ConfigPath").Value;
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// protected Settings Settings
|
||||
// {
|
||||
// set
|
||||
// {
|
||||
// this.Context.Settings = value;
|
||||
// }
|
||||
// get
|
||||
// {
|
||||
// return this.Context.Settings;
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// #region Methods
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="path"></param>
|
||||
///// <returns></returns>
|
||||
////==================================================================================================
|
||||
// protected string TranslateQuickPickNumber(string path)
|
||||
// {
|
||||
// CommonDriveInfo drive = this.Drive as CommonDriveInfo;
|
||||
// if (drive != null)
|
||||
// {
|
||||
// BaseUIContainer result = null;
|
||||
// int number = 0;
|
||||
|
||||
// if (Int32.TryParse(Path.GetFileName(path), out number))
|
||||
// {
|
||||
// if (path == "\\" + this.Drive.CurrentLocation)
|
||||
// {
|
||||
// return path.Replace(Path.GetFileName(path), drive.CurrentContainer.Entity.Id);
|
||||
// }
|
||||
// //else if (path.Length < this.Drive.CurrentLocation.Length)
|
||||
// //{
|
||||
// // result = drive.CurrentContainer.Parent;
|
||||
// //}
|
||||
// else
|
||||
// {
|
||||
// result = drive.CurrentContainer.Containers.Where(q => q.Entity.QuickPickNumber == number).FirstOrDefault<BaseUIContainer>();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return path;
|
||||
// }
|
||||
|
||||
// if (result != null)
|
||||
// return path.Replace(Path.GetFileName(path), result.Id);
|
||||
// else return null;
|
||||
// }
|
||||
// else return null;
|
||||
// }
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////==================================================================================================
|
||||
// protected override void BeginProcessing()
|
||||
// {
|
||||
// if (this.Drive.Name != "OpenStack" && this.Drive.Provider.Name != "OS-Storage")
|
||||
// {
|
||||
// ErrorRecord err = new ErrorRecord(new InvalidOperationException("You must be attached to an ObjectStorage Container or the OpenStack drive to execute an OpenStack Cloud cmdlet."), "0" , ErrorCategory.InvalidOperation, this);
|
||||
// this.ThrowTerminatingError(err);
|
||||
// }
|
||||
|
||||
// bool isAuthorized = false;
|
||||
// Type type = this.GetType();
|
||||
// object[] metadata = type.GetCustomAttributes(false);
|
||||
// bool foundattribute = false;
|
||||
|
||||
// foreach (object attribute in metadata)
|
||||
// {
|
||||
// RequiredServiceIdentifierAttribute identifier = attribute as RequiredServiceIdentifierAttribute;
|
||||
|
||||
// if (identifier != null)
|
||||
// {
|
||||
// if (this.Context.ServiceCatalog.GetService(identifier.Services) != null)
|
||||
// isAuthorized = true;
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (isAuthorized == false && foundattribute == false) return;
|
||||
|
||||
// if (!isAuthorized)
|
||||
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.OpenStack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
|
||||
// }
|
||||
////==================================================================================================
|
||||
///// <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();
|
||||
// }
|
||||
// WriteObject(builder.ToString());
|
||||
// WriteObject("");
|
||||
// }
|
||||
// #endregion
|
||||
// #region Methods
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="entity"></param>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// protected bool UserConfirmsDeleteAction(string entity)
|
||||
// {
|
||||
// Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||
// choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
// choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
// if (this.Host.UI.PromptForChoice("Confirm Action", "You are about to delete all " + entity + " in the current container. Are you sure about this?", choices, 0) == 0)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected void UpdateCache(Context context)
|
||||
// {
|
||||
// CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
// if (tempDrive != null)
|
||||
// {
|
||||
// BaseUIContainer container = tempDrive.CurrentContainer as BaseUIContainer;
|
||||
// container.Context = context;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// catch (InvalidOperationException) { }
|
||||
// if (container.Parent != null)
|
||||
// container.Parent.Load();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected void UpdateCache()
|
||||
// {
|
||||
// CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
// if (tempDrive != null)
|
||||
// {
|
||||
// BaseUIContainer container = tempDrive.CurrentContainer as BaseUIContainer;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// catch (InvalidOperationException) { }
|
||||
// if (container.Parent != null)
|
||||
// container.Parent.Load();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// Updates the cache if the current UIContainer manages the supplied type.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected void UpdateCache<T>() where T : BaseUIContainer
|
||||
// {
|
||||
// T container = ((CommonDriveInfo)this.Drive).CurrentContainer as T;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// T parentContainer = ((CommonDriveInfo)this.Drive).CurrentContainer.Parent as T;
|
||||
// if (parentContainer != null)
|
||||
// {
|
||||
// parentContainer.Load();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="path"></param>
|
||||
////=========================================================================================
|
||||
// protected StoragePath CreateStoragePath(string path)
|
||||
// {
|
||||
// return ((OSDriveInfo)this.Drive).CreateStoragePath(path);
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
@ -1,97 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet("Attach", "Volume", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.BlockStorage)]
|
||||
public class AttachVolumeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _volumeId;
|
||||
private string _device;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "AttachVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "AttachVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string VolumeId
|
||||
{
|
||||
get { return _volumeId; }
|
||||
set { _volumeId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "AttachVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Device
|
||||
{
|
||||
get { return _device; }
|
||||
set { _device = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
VolumeAttachment attachment = new VolumeAttachment();
|
||||
attachment.Device = this.Device;
|
||||
attachment.VolumeId = this.VolumeId;
|
||||
attachment.ServerId = this.ServerId;
|
||||
|
||||
this.RepositoryFactory.CreateVolumeRepository().AttachVolume(attachment, this.ServerId);
|
||||
this.UpdateCache<AttachmentsUIContainer>();
|
||||
this.UpdateCache<VolumesUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,107 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet("Backup", "Volume", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.BlockStorage)]
|
||||
public class BackupVolumeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private NewVolumeBackup _newBackup = new NewVolumeBackup();
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, ParameterSetName = "BackupVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("c")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Container
|
||||
{
|
||||
get { return _newBackup.Container; }
|
||||
set { _newBackup.Container = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "BackupVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Description
|
||||
{
|
||||
get { return _newBackup.Description; }
|
||||
set { _newBackup.Container = value; }
|
||||
}
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "BackupVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string VolumeId
|
||||
{
|
||||
get { return _newBackup.VolumeId;}
|
||||
set { _newBackup.VolumeId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "BackupVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _newBackup.Name; }
|
||||
set { _newBackup.Name = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewVolumeBackup backup = new NewVolumeBackup();
|
||||
|
||||
backup.VolumeId = this.TranslateQuickPickNumber(_newBackup.VolumeId);
|
||||
|
||||
this.RepositoryFactory.CreateVolumeRepository().SaveVolumeBackup(backup);
|
||||
this.UpdateCache<VolumesUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,78 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet("Detach", "Volume", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.BlockStorage)]
|
||||
public class DetachVolumeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _volumeId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DettachVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DettachVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string VolumeId
|
||||
{
|
||||
get { return _volumeId; }
|
||||
set { _volumeId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.RepositoryFactory.CreateVolumeRepository().DetachVolume(this.VolumeId, this.ServerId);
|
||||
this.UpdateCache<AttachmentsUIContainer>();
|
||||
this.UpdateCache<VolumesUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,132 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using System;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "Snapshot", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.BlockStorage)]
|
||||
public class NewSnapshotCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private SwitchParameter _force = false;
|
||||
private string _description;
|
||||
private string _volumeId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewSnapshot", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewSnapshot", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set { _description = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewSnapshot", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string VolumeId
|
||||
{
|
||||
get { return _volumeId; }
|
||||
set { _volumeId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 4, ParameterSetName = "NewSnapshot", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("f")]
|
||||
public SwitchParameter Force
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private bool IsVolumeAvailable(string volumeId)
|
||||
{
|
||||
Volume volume = this.RepositoryFactory.CreateVolumeRepository().GetVolume(volumeId);
|
||||
if (volume.Status == "in-use")
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.IsVolumeAvailable(this.VolumeId))
|
||||
{
|
||||
NewSnapshot snapshot = new NewSnapshot();
|
||||
snapshot.Description = this.Description;
|
||||
snapshot.Name = this.Name;
|
||||
snapshot.VolumeId = this.VolumeId;
|
||||
snapshot.Force = this.Force;
|
||||
|
||||
this.RepositoryFactory.CreateSnapshotRepository().SaveSnapshot(snapshot);
|
||||
this.UpdateCache<SnapshotsUIContainer>();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("The specified Volume is already in use.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,153 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "Volume", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.BlockStorage)]
|
||||
public class NewVolumeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _size;
|
||||
private string _description;
|
||||
private string[] _metadata;
|
||||
private NewVolume vol = new NewVolume();
|
||||
private string _availabilityZone;
|
||||
private string _sourceVolid;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 4, ParameterSetName = "NewVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("az")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string AvailabilityZone
|
||||
{
|
||||
get { return _availabilityZone; }
|
||||
set { _availabilityZone = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, ParameterSetName = "NewVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("svid")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SourceVolumeId
|
||||
{
|
||||
get { return _sourceVolid; }
|
||||
set { _sourceVolid = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewVolume", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set { _description = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Size
|
||||
{
|
||||
get { return _size; }
|
||||
set { _size = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, Mandatory = false, ParameterSetName = "NewVolume", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("md")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] MetaData
|
||||
{
|
||||
get { return _metadata; }
|
||||
set { _metadata = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewVolume volume = new NewVolume();
|
||||
volume.Description = this.Description;
|
||||
volume.Name = this.Name;
|
||||
volume.SourceVolid = this.SourceVolumeId;
|
||||
volume.AvailabilityZone = this.AvailabilityZone;
|
||||
|
||||
if (this.SourceVolumeId == null)
|
||||
volume.Size = this.Size;
|
||||
else
|
||||
volume.Size = null;
|
||||
|
||||
|
||||
if (_metadata != null && _metadata.Length > 0)
|
||||
{
|
||||
foreach (string kv in _metadata)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
volume.Metadata.Add(temp[0], temp[1]);
|
||||
}
|
||||
}
|
||||
|
||||
this.RepositoryFactory.CreateVolumeRepository().SaveVolume(volume);
|
||||
this.UpdateCache<VolumesUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Snapshot", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveSnapshotCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _snapshotId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RemoveSnapshot", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "a")]
|
||||
[Alias("s")]
|
||||
public string SnapshotId
|
||||
{
|
||||
get { return _snapshotId; }
|
||||
set { _snapshotId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.UserConfirmsDeleteAction("Snapshots"))
|
||||
{
|
||||
this.RepositoryFactory.CreateSnapshotRepository().DeleteSnapshot(this.SnapshotId);
|
||||
this.UpdateCache<SnapshotsUIContainer>();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
/* ============================================================================
|
||||
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;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
class RemoveVolumeBackupCmdlet
|
||||
{
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.Domain.BlockStorage;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.BlockStorage
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Volume", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveVolumeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _volumeId;
|
||||
private SwitchParameter _force = false;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "RemoveVolume2", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RemoveVolume", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "a")]
|
||||
[Alias("v")]
|
||||
public string VolumeId
|
||||
{
|
||||
get { return _volumeId; }
|
||||
set { _volumeId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.VolumeId);
|
||||
|
||||
if (_force == true && this.UserConfirmsDeleteAction("Volumes")) {
|
||||
this.RemoveAllVolumes();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RepositoryFactory.CreateVolumeRepository().DeleteVolume(id);
|
||||
this.UpdateCache<VolumesUIContainer>();
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllVolumes()
|
||||
{
|
||||
List<Volume> volumes = this.RepositoryFactory.CreateVolumeRepository().GetVolumes();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (Volume volume in volumes)
|
||||
{
|
||||
|
||||
Console.WriteLine("Removing Volume : " + volume.Name);
|
||||
this.RepositoryFactory.CreateVolumeRepository().DeleteVolume(volume.Id);
|
||||
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets
|
||||
{
|
||||
class OutClipboard
|
||||
{
|
||||
[STAThread]
|
||||
public static void SetText(string text)
|
||||
{
|
||||
TextBox tb = new TextBox();
|
||||
tb.Multiline = true;
|
||||
|
||||
tb.Text = text;
|
||||
tb.SelectAll();
|
||||
tb.Copy();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,263 +0,0 @@
|
||||
///* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
//using System;
|
||||
//using System.Management.Automation;
|
||||
//using System.Collections.ObjectModel;
|
||||
//using OpenStack.Client.Powershell.Providers.Storage;
|
||||
//using System.Collections.Generic;
|
||||
//using OpenStack;
|
||||
|
||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
//{
|
||||
// public class BaseAuthenticationCmdlet : BasePSCmdlet
|
||||
// {
|
||||
// private string _key;
|
||||
// private string _value;
|
||||
// private SwitchParameter _reset = false;
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////==================================================================================================
|
||||
// protected void InitializeSession(AuthenticationRequest request, Settings settings = null)
|
||||
// {
|
||||
// Context context = new Context();
|
||||
|
||||
// if (request != null)
|
||||
// {
|
||||
// KeystoneAuthProvider authProvider = new KeystoneAuthProvider();
|
||||
// AuthenticationResponse response = authProvider.Authenticate(request);
|
||||
|
||||
// context.ServiceCatalog = response.ServiceCatalog;
|
||||
// if (settings == null)
|
||||
// context.Settings = Settings.Default;
|
||||
// else
|
||||
// context.Settings = settings;
|
||||
// context.AccessToken = response.Token;
|
||||
|
||||
// this.SessionState.PSVariable.Set(new PSVariable("Context", context));
|
||||
// this.SessionState.PSVariable.Set(new PSVariable("BaseRepositoryFactory", new BaseRepositoryFactory(context)));
|
||||
// }
|
||||
// }
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////==================================================================================================
|
||||
// protected void InitializeSession(Settings settings)
|
||||
// {
|
||||
// AuthenticationRequest request = new AuthenticationRequest(new Credentials(settings.Username, settings.Password), settings.DefaultTenantId);
|
||||
// this.InitializeSession(request, settings);
|
||||
// }
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////==================================================================================================
|
||||
// private System.Collections.ObjectModel.Collection<PSDriveInfo> GetAvailableDrives(Settings settings, ProviderInfo providerInfo, string configFilePath)
|
||||
// {
|
||||
// List<StorageContainer> storageContainers = null;
|
||||
// OSDriveParameters parameters = new OSDriveParameters();
|
||||
|
||||
// if (this.Settings != null)
|
||||
// {
|
||||
// parameters.Settings = this.Settings;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// parameters.Settings = settings;
|
||||
// }
|
||||
|
||||
// try
|
||||
// {
|
||||
// IContainerRepository storageContainerRepository = this.RepositoryFactory.CreateContainerRepository();
|
||||
// storageContainers = storageContainerRepository.GetStorageContainers(configFilePath);
|
||||
// }
|
||||
// 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);
|
||||
// try
|
||||
// {
|
||||
// drives.Add(kvsDriveInfo);
|
||||
// }
|
||||
// catch (Exception) { }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// PSDriveInfo driveInfo = new PSDriveInfo("OS-Init", this.SessionState.Drive.Current.Provider, "/", "Root folder for your storageContainer", null);
|
||||
// return new Collection<PSDriveInfo>
|
||||
// {
|
||||
// new OSDriveInfo(driveInfo, parameters, this.Context)
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
|
||||
// }
|
||||
|
||||
// return drives;
|
||||
// }
|
||||
////=======================================================================================================
|
||||
///// <summary>
|
||||
///// Removes all currently registered drives..
|
||||
///// </summary>
|
||||
////=======================================================================================================
|
||||
// private void RemoveDrives()
|
||||
// {
|
||||
// // Remove the old Users drives first..
|
||||
|
||||
// Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
|
||||
// foreach (PSDriveInfo deadDrive in deadDrives)
|
||||
// {
|
||||
// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
|
||||
// }
|
||||
// }
|
||||
//////=======================================================================================================
|
||||
/////// <summary>
|
||||
/////// removes only the currently registered shared drives..
|
||||
/////// </summary>
|
||||
//////=======================================================================================================
|
||||
//// private void RemoveSharedDrives()
|
||||
//// {
|
||||
//// Collection<PSDriveInfo> deadDrives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
|
||||
//// foreach (OSDriveInfo deadDrive in deadDrives)
|
||||
//// {
|
||||
//// if (deadDrive.SharePath != null)
|
||||
//// this.SessionState.Drive.Remove(deadDrive.Name, true, "local");
|
||||
//// }
|
||||
//// }
|
||||
////=======================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=======================================================================================================
|
||||
// protected void WriteContainers(string configFilePath)
|
||||
// {
|
||||
// List<string> invalidDriveNames = new List<string>();
|
||||
// OSDriveParameters parameters = new OSDriveParameters();
|
||||
|
||||
// // Write out the commands header information first..
|
||||
|
||||
// WriteObject("");
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("===================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
// WriteObject("Object Storage Service available. Remapping to the following drives.");
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("===================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Green;
|
||||
// WriteObject(" ");
|
||||
|
||||
// HPOSNavigationProvider provider = new HPOSNavigationProvider();
|
||||
// Collection<PSDriveInfo> drives = this.GetAvailableDrives(this.Settings, this.SessionState.Provider.GetOne("OS-Storage"), configFilePath);
|
||||
|
||||
// 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>
|
||||
////=======================================================================================================
|
||||
// protected void WriteServices()
|
||||
// {
|
||||
// WriteObject("");
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("=================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
// WriteObject("Binding to new Account. New service catalog is as follows.");
|
||||
// Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
// WriteObject("=================================================================");
|
||||
// Console.ForegroundColor = ConsoleColor.Green;
|
||||
// WriteObject(" ");
|
||||
|
||||
// foreach (Service service in this.Context.ServiceCatalog)
|
||||
// {
|
||||
// WriteObject(service);
|
||||
// }
|
||||
// WriteObject("");
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -1,337 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using System.Management.Automation;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using System.IO;
|
||||
using OpenStack.Common;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using OpenStack.Client.Powershell.Providers.Storage;
|
||||
using OpenStack.Client.Powershell.Providers.Common;
|
||||
using System.Linq;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Threading;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
public class BasePSCmdlet : PSCmdlet
|
||||
{
|
||||
#region Properties
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
//protected BaseUIContainer CurrentContainer
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
// if (tempDrive != null)
|
||||
// {
|
||||
// return tempDrive.CurrentContainer as BaseUIContainer;
|
||||
// }
|
||||
// else return null;
|
||||
// }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// Exposes the currently mapped Drive. Belongs in base class???
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected PSDriveInfo Drive
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.SessionState.Drive.Current;
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
//=========================================================================================
|
||||
protected void WriteHeaderSection(string headerText)
|
||||
{
|
||||
WriteObject(" ");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
WriteObject(headerText);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <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
|
||||
{
|
||||
get
|
||||
{
|
||||
return (IOpenStackClient)this.SessionState.PSVariable.GetValue("CoreClient", null);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.SessionState.PSVariable.Set(new PSVariable("CoreClient", value));
|
||||
}
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//==================================================================================================
|
||||
protected override void StopProcessing()
|
||||
{
|
||||
CancellationTokenSource source = (CancellationTokenSource)this.SessionState.PSVariable.Get("CancellationTokenSource").Value;
|
||||
source.Cancel();
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
protected Context Context
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Context)this.SessionState.PSVariable.GetValue("Context", null);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.SessionState.PSVariable.Set(new PSVariable("Context", value));
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
protected string ConfigFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\" + @"OS\OpenStack.config";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="path"></param>
|
||||
///// <returns></returns>
|
||||
////==================================================================================================
|
||||
//protected string TranslateQuickPickNumber(string path)
|
||||
//{
|
||||
// CommonDriveInfo drive = this.Drive as CommonDriveInfo;
|
||||
// if (drive != null)
|
||||
// {
|
||||
// BaseUIContainer result = null;
|
||||
// int number = 0;
|
||||
|
||||
// if (Int32.TryParse(Path.GetFileName(path), out number))
|
||||
// {
|
||||
// if (path == "\\" + this.Drive.CurrentLocation)
|
||||
// {
|
||||
// return path.Replace(Path.GetFileName(path), drive.CurrentContainer.Entity.Id);
|
||||
// }
|
||||
// //else if (path.Length < this.Drive.CurrentLocation.Length)
|
||||
// //{
|
||||
// // result = drive.CurrentContainer.Parent;
|
||||
// //}
|
||||
// else
|
||||
// {
|
||||
// result = drive.CurrentContainer.Containers.Where(q => q.Entity.QuickPickNumber == number).FirstOrDefault<BaseUIContainer>();
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return path;
|
||||
// }
|
||||
|
||||
// if (result != null)
|
||||
// return path.Replace(Path.GetFileName(path), result.Id);
|
||||
// else return null;
|
||||
// }
|
||||
// else return null;
|
||||
//}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
protected override void BeginProcessing()
|
||||
{
|
||||
//if (this.Drive.Name != "OpenStack" && this.Drive.Provider.Name != "OS-Storage")
|
||||
//{
|
||||
// ErrorRecord err = new ErrorRecord(new InvalidOperationException("You must be attached to an ObjectStorage Container or the OpenStack drive to execute an OpenStack Cloud cmdlet."), "0", ErrorCategory.InvalidOperation, this);
|
||||
// this.ThrowTerminatingError(err);
|
||||
//}
|
||||
|
||||
//bool isAuthorized = false;
|
||||
//Type type = this.GetType();
|
||||
//object[] metadata = type.GetCustomAttributes(false);
|
||||
//bool foundattribute = false;
|
||||
|
||||
//foreach (object attribute in metadata)
|
||||
//{
|
||||
// RequiredServiceIdentifierAttribute identifier = attribute as RequiredServiceIdentifierAttribute;
|
||||
|
||||
// if (identifier != null)
|
||||
// {
|
||||
// if (this.Context.ServiceCatalog.Exists(identifier.Services) != null)
|
||||
// isAuthorized = true;
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (isAuthorized == false && foundattribute == false) return;
|
||||
|
||||
//if (!isAuthorized)
|
||||
// this.ThrowTerminatingError(new ErrorRecord(new InvalidOperationException("You're not current authorized to use this service. Please go to https://www.OpenStack.com/ for more information on signing up for this service."), "aa", ErrorCategory.InvalidOperation, this));
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
|
||||
protected bool UserConfirmsDeleteAction(string entity)
|
||||
{
|
||||
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||
choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
if (this.Host.UI.PromptForChoice("Confirm Action", "You are about to delete all " + entity + " in the current container. Are you sure about this?", choices, 0) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected void UpdateCache(Context context)
|
||||
{
|
||||
//CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
//if (tempDrive != null)
|
||||
//{
|
||||
// BaseUIContainer container = tempDrive.CurrentContainer as BaseUIContainer;
|
||||
// container.Context = context;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// catch (InvalidOperationException) { }
|
||||
// if (container.Parent != null)
|
||||
// container.Parent.Load();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected void UpdateCache()
|
||||
{
|
||||
//CommonDriveInfo tempDrive = this.Drive as CommonDriveInfo;
|
||||
//if (tempDrive != null)
|
||||
//{
|
||||
// BaseUIContainer container = tempDrive.CurrentContainer as BaseUIContainer;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// catch (InvalidOperationException) { }
|
||||
// if (container.Parent != null)
|
||||
// container.Parent.Load();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// Updates the cache if the current UIContainer manages the supplied type.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
//protected void UpdateCache<T>() where T : BaseUIContainer
|
||||
//{
|
||||
// T container = ((CommonDriveInfo)this.Drive).CurrentContainer as T;
|
||||
|
||||
// if (container != null)
|
||||
// {
|
||||
// container.Load();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// T parentContainer = ((CommonDriveInfo)this.Drive).CurrentContainer.Parent as T;
|
||||
// if (parentContainer != null)
|
||||
// {
|
||||
// parentContainer.Load();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
//=========================================================================================
|
||||
protected StoragePath CreateStoragePath(string path)
|
||||
{
|
||||
return ((ObjectStoragePSDriveInfo)this.Drive).CreateStoragePath(path);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Collections;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Linq;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Copy, "Id", SupportsShouldProcess = true)]
|
||||
public class CopyIdCmdlet : BasePSCmdlet
|
||||
{
|
||||
private int _quickPickNumber;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "CopyIdCmdlet", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("qp")]
|
||||
public int QuickPickNumber
|
||||
{
|
||||
get { return _quickPickNumber; }
|
||||
set { _quickPickNumber = value; }
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
int number = 0;
|
||||
CommonDriveInfo drive = this.Drive as CommonDriveInfo;
|
||||
BaseUIContainer result = drive.CurrentContainer.Containers.Where(q => q.Entity.QuickPickNumber == _quickPickNumber).FirstOrDefault<BaseUIContainer>();
|
||||
|
||||
WriteObject("");
|
||||
this.WriteObject("Id " + result.Entity.Id + " copied to clipboard.");
|
||||
WriteObject("");
|
||||
OutClipboard.SetText(result.Entity.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Collections;
|
||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using OpenStack.Identity;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Catalog", SupportsShouldProcess = true)]
|
||||
public class GetCatalogCmdlet : BasePSCmdlet
|
||||
{
|
||||
private SwitchParameter _verbose = false;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
//[Parameter(Mandatory = false, ParameterSetName = "gc0", ValueFromPipelineByPropertyName = true, HelpMessage = "Prints information for the current service in use.")]
|
||||
//[Alias("cs")]
|
||||
//[ValidateNotNullOrEmpty]
|
||||
//public SwitchParameter CurrentService
|
||||
//{
|
||||
// get { return _currentService; }
|
||||
// set { _currentService = value; }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Mandatory = false, ParameterSetName = "gc0", ValueFromPipelineByPropertyName = true, HelpMessage = "Prints extended information for each service.")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter Verbose2
|
||||
{
|
||||
get { return _verbose; }
|
||||
set { _verbose = value; }
|
||||
}
|
||||
#endregion
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
//=========================================================================================
|
||||
private void WriteSection(string headerText)
|
||||
{
|
||||
WriteObject(" ");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
WriteObject(headerText);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="endpoint"></param>
|
||||
//=======================================================================================================
|
||||
private void PrintEndpoint(OpenStackServiceEndpoint endpoint)
|
||||
{
|
||||
Console.WriteLine("Region : " + endpoint.Region);
|
||||
Console.WriteLine("Public URL : " + endpoint.PublicUri.ToString());
|
||||
//Console.WriteLine("Internal URL : " + endpoint..InternalURL);
|
||||
//Console.WriteLine("Admin URL : " + endpoint.AdminURL);
|
||||
Console.WriteLine("Version : " + endpoint.Version);
|
||||
//Console.WriteLine("Version Info : " + endpoint.Version.InfoURL);
|
||||
//Console.WriteLine("Version List : " + endpoint.Version.ListURL);
|
||||
Console.WriteLine();
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="service"></param>
|
||||
//=======================================================================================================
|
||||
private void PrintServiceVerbose(OpenStackServiceDefinition service)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
this.WriteSection ("Service : " + service.Name);
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("General");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("Name : " + service.Name);
|
||||
Console.WriteLine("Type : " + service.Type);
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Associated Endpoints");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
|
||||
foreach (OpenStackServiceEndpoint endpoint in service.Endpoints)
|
||||
{
|
||||
this.PrintEndpoint(endpoint);
|
||||
}
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
private void PrintServiceCatalog()
|
||||
{
|
||||
WriteObject("");
|
||||
this.WriteSection("You have access to the following Services ");
|
||||
WriteObject("");
|
||||
|
||||
foreach (OpenStackServiceDefinition service in this.Context.ServiceCatalog)
|
||||
{
|
||||
if (!_verbose)
|
||||
WriteObject(service);
|
||||
else
|
||||
PrintServiceVerbose(service);
|
||||
}
|
||||
WriteObject("");
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.PrintServiceCatalog();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Config", SupportsShouldProcess = true)]
|
||||
public class GetConfigCmdlet : BasePSCmdlet
|
||||
{
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
//=========================================================================================
|
||||
private void WriteSection(string headerText)
|
||||
{
|
||||
WriteObject(" ");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
WriteObject(headerText);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
|
||||
WriteObject("");
|
||||
this.WriteSection("Current Session Settings are as follows. ");
|
||||
WriteObject("");
|
||||
this.WriteObject("Configuration File located at " + configFilePath);
|
||||
WriteObject("");
|
||||
|
||||
foreach (DictionaryEntry setting in this.Context.Settings)
|
||||
{
|
||||
if (((string)setting.Key) == "SecretKey" || ((string)setting.Key)== "AccessKey")
|
||||
{
|
||||
var entry = new DictionaryEntry();
|
||||
entry.Value = "***********";
|
||||
entry.Key = setting.Key;
|
||||
WriteObject(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteObject(setting);
|
||||
}
|
||||
}
|
||||
WriteObject("");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,210 +0,0 @@
|
||||
/* ============================================================================
|
||||
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 Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using Openstack.Objects.Domain.Admin;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Storage.CDN
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Metadata", SupportsShouldProcess = true)]
|
||||
public class GetNMetadataCmdlet2 : BasePSCmdlet
|
||||
{
|
||||
private string _cdnContainerName;
|
||||
private string _sourcePath;
|
||||
private string _objectStorageContainerName;
|
||||
private string _serverId;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "serverMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "containerMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("cn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ObjectStorageContainerName
|
||||
{
|
||||
get { return _objectStorageContainerName; }
|
||||
set { _objectStorageContainerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0 , ParameterSetName = "objectMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("sp")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SourcePath
|
||||
{
|
||||
get { return _sourcePath; }
|
||||
set { _sourcePath = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Mandatory = false, ParameterSetName = "cdnMetadata", ValueFromPipelineByPropertyName = true, HelpMessage = "The Name of the Container to enable for CDN access.")]
|
||||
[Alias("cdn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string CDNContainerName
|
||||
{
|
||||
get { return _cdnContainerName; }
|
||||
set { _cdnContainerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
//=========================================================================================
|
||||
private void WriteSection(string headerText)
|
||||
{
|
||||
WriteObject(" ");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
WriteObject(headerText);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="kvps"></param>
|
||||
//=========================================================================================
|
||||
private void WriteKVPs(List<KeyValuePair<string, string>> kvps, string displayName)
|
||||
{
|
||||
if (kvps.Count > 0)
|
||||
{
|
||||
WriteObject("");
|
||||
this.WriteSection("Meta-Data for " + displayName + " is as follows.");
|
||||
WriteObject("");
|
||||
foreach (KeyValuePair<string, string> kvp in kvps)
|
||||
{
|
||||
WriteObject("Key = " + kvp.Key.Replace("X-", string.Empty));
|
||||
WriteObject("Value = " + Convert.ToString(kvp.Value));
|
||||
WriteObject("---------------------------------");
|
||||
}
|
||||
WriteObject("");
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteObject("");
|
||||
Console.WriteLine("No meta-data found for the supplied resource name.");
|
||||
WriteObject("");
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessCDNMetadata()
|
||||
{
|
||||
if (this.Context.ServiceCatalog.DoesServiceExist(Services.CDN) == false) {
|
||||
Console.WriteLine("You don't have access to CDN services under this account. For information on signing up for CDN access please go to http://Openstack.com/.");
|
||||
}
|
||||
WriteKVPs(RepositoryFactory.CreateCDNRepository().GetMetaData(this.CDNContainerName), this.CDNContainerName);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessObjectMetadata()
|
||||
{
|
||||
if (this.Drive.Provider.Name != "OS-Storage")
|
||||
Console.WriteLine("You must be using the Object Storage Provider to use this cmdlet with the supplied parameters. To use this provider mount to a ObjectStorage container first. To see a list of available Containers issue the Get-PSDrive command.");
|
||||
else
|
||||
WriteKVPs(RepositoryFactory.CreateStorageObjectRepository().GetMetaData(this.CreateStoragePath(this.SourcePath).AbsoluteURI), this.SourcePath);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessContainerMetadata()
|
||||
{
|
||||
if (this.Drive.Provider.Name != "OS-Storage")
|
||||
Console.WriteLine("You must be using the Object Storage Provider to use this cmdlet with the supplied parameters. To use this provider mount to a ObjectStorage container first. To see a list of available Containers issue the Get-PSDrive command.");
|
||||
else
|
||||
WriteKVPs(RepositoryFactory.CreateContainerRepository().GetMetaData(_objectStorageContainerName), _objectStorageContainerName);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessServerMetadata()
|
||||
{
|
||||
if (this.Context.ServiceCatalog.DoesServiceExist(Services.Compute) == false)
|
||||
Console.WriteLine("You don't have access to Compute services under this account. For information on signing up for this please go to http://Openstack.com/.");
|
||||
else
|
||||
{
|
||||
Server server = RepositoryFactory.CreateServerRepository().GetServer(this.ServerId);
|
||||
//WriteKVPs(server.MetaData.ToKeypairs(), server.Name);
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The main driver..
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
switch (this.ParameterSetName)
|
||||
{
|
||||
case ("serverMetadata"):
|
||||
this.ProcessServerMetadata();
|
||||
break;
|
||||
|
||||
case ("containerMetadata"):
|
||||
this.ProcessContainerMetadata();
|
||||
break;
|
||||
|
||||
case ("cdnMetadata"):
|
||||
|
||||
this.ProcessCDNMetadata();
|
||||
break;
|
||||
|
||||
case ("objectMetadata"):
|
||||
this.ProcessObjectMetadata();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,148 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Reflection;
|
||||
using System.Xml.Linq;
|
||||
using System.Linq;
|
||||
using System.Xml.XPath;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Notes", SupportsShouldProcess = true)]
|
||||
public class GetNotesCmdlet : BasePSCmdlet
|
||||
{
|
||||
private bool _showAllNotes = false;
|
||||
private string _version;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sn", ValueFromPipelineByPropertyName = true, HelpMessage = "Show all release notes for this product.")]
|
||||
[Alias("all")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter ShowAllNotes
|
||||
{
|
||||
get { return _showAllNotes; }
|
||||
set { _showAllNotes = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "sn", Position = 0, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Show release notes for a specific version of the CLI.")]
|
||||
[Alias("v")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Version
|
||||
{
|
||||
get { return _version; }
|
||||
set { _version = value; }
|
||||
}
|
||||
#endregion
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="releaseNode"></param>
|
||||
//=======================================================================================================
|
||||
private void PrintRelease (XElement releaseNode)
|
||||
{
|
||||
Console.WriteLine("-------------------------------------------------------- ");
|
||||
Console.WriteLine("Version : " + releaseNode.Attribute(XName.Get("version")).Value);
|
||||
Console.WriteLine("Notes :");
|
||||
|
||||
XElement notes = (from xml2 in releaseNode.Descendants()
|
||||
select xml2).FirstOrDefault();
|
||||
Console.WriteLine(notes.Value);
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
public void PrintVersionNotes(XDocument releaseNotes)
|
||||
{
|
||||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
XElement releaseNode = (from xml2 in releaseNotes.Descendants("Release")
|
||||
where xml2.Attribute(XName.Get("version")).Value == _version
|
||||
select xml2).FirstOrDefault();
|
||||
|
||||
this.PrintRelease(releaseNode);
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
private void PrintAllNotes(XDocument releaseNotes)
|
||||
{
|
||||
Console.WriteLine(" ");
|
||||
foreach (XElement element in releaseNotes.Descendants("Release"))
|
||||
{
|
||||
this.PrintRelease(element);
|
||||
}
|
||||
Console.WriteLine(" ");
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
private void PrintCurrentRelease(XDocument releaseNotes)
|
||||
{
|
||||
string currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
//XElement releaseNode = (from xml2 in releaseNotes.Descendants("Release")
|
||||
// where xml2.Attribute(XName.Get("version")).Value == currentVersion
|
||||
// select xml2).FirstOrDefault();
|
||||
|
||||
XElement notes = releaseNotes.XPathSelectElement("//Release[@version='" + currentVersion + "']");
|
||||
if (notes != null)
|
||||
this.PrintRelease(notes);
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("No release notes exist for the current version.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
XDocument releaseNotes = XDocument.Load(this.Settings.ReleaseNotesURI);
|
||||
|
||||
if (_version == null && _showAllNotes == false)
|
||||
{
|
||||
this.PrintCurrentRelease(releaseNotes);
|
||||
}
|
||||
else if (_showAllNotes)
|
||||
{
|
||||
this.PrintAllNotes(releaseNotes);
|
||||
}
|
||||
else if (_version != null)
|
||||
{
|
||||
this.PrintVersionNotes(releaseNotes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
///* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using OpenStack.Client.Powershell.Providers.Common;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using OpenStack;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "SP", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class GetServiceProvidersCmdlet : BasePSCmdlet
|
||||
{
|
||||
#region Methods
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
var manager = new ConfigurationManager();
|
||||
manager.Load();
|
||||
|
||||
this.WriteObject("");
|
||||
this.WriteObject("Current Service Provider : " + this.Context.CurrentServiceProvider.Name);
|
||||
this.WriteObject("-----------------------------------------");
|
||||
this.WriteObject(manager.GetServiceProviders());
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
||||
using System.Reflection;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.GroupManagement
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Version", SupportsShouldProcess = true)]
|
||||
public class GetVersionCmdlet : BasePSCmdlet
|
||||
{
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
Console.WriteLine(" ");
|
||||
Console.WriteLine("Assembly Location : " + Assembly.GetExecutingAssembly().Location);
|
||||
Console.WriteLine("Product Version : " + Assembly.GetExecutingAssembly().GetName().Version);
|
||||
Console.WriteLine("CLR Version : " + Assembly.GetExecutingAssembly().ImageRuntimeVersion);
|
||||
Console.WriteLine(" ");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using System.Linq;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet("Get", "Zone", SupportsShouldProcess = true)]
|
||||
public class GetZoneCmdlet : BasePSCmdlet
|
||||
{
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
AvailabilityZone zone = this.Context.CurrentServiceProvider.AvailabilityZones.Where(z => z.IsDefault == true).Single();
|
||||
|
||||
if (zone != null) {
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Current Availability Zone is " + zone.Name);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/* ============================================================================
|
||||
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 OpenStack.Client.Powershell.Cmdlets.Common;
|
||||
using System.Management.Automation;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet("Get", "Zones", SupportsShouldProcess = true)]
|
||||
public class GetZonesCmdlet : BasePSCmdlet
|
||||
{
|
||||
//private SwitchParameter _verbose = true;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
//[Parameter(Mandatory = false, ParameterSetName = "gz", ValueFromPipelineByPropertyName = true, HelpMessage = "Prints extended information for each service.")]
|
||||
//[Alias("v")]
|
||||
//[ValidateNotNullOrEmpty]
|
||||
//public SwitchParameter Verbose
|
||||
//{
|
||||
// get { return _verbose; }
|
||||
// set { _verbose = value; }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ShowVerboseOutput()
|
||||
{
|
||||
foreach (AvailabilityZone zone in this.Context.CurrentServiceProvider.AvailabilityZones)
|
||||
{
|
||||
this.WriteHeaderSection("Zone : " + zone.Name);
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zone.ShellForegroundColor);
|
||||
Console.WriteLine("Zone Id : " + zone.Id);
|
||||
Console.WriteLine("Zone Name : " + zone.Name);
|
||||
Console.WriteLine("Shell Foreground Color : " + zone.ShellForegroundColor);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("The following Services are available from this Availability Zone");
|
||||
Console.WriteLine("----------------------------------------------------------------");
|
||||
|
||||
this.WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(zone.Name));
|
||||
Console.WriteLine("");
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ShowNonVerboseOutput()
|
||||
{
|
||||
foreach (AvailabilityZone zone in this.Context.CurrentServiceProvider.AvailabilityZones)
|
||||
{
|
||||
this.WriteHeaderSection("Zone : " + zone.Name);
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zone.ShellForegroundColor);
|
||||
Console.WriteLine("Zone Id : " + zone.Id);
|
||||
Console.WriteLine("Zone Name : " + zone.Name);
|
||||
Console.WriteLine("Shell Foreground Color : " + zone.ShellForegroundColor);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.ShowVerboseOutput();
|
||||
|
||||
//if (_verbose)
|
||||
//{
|
||||
// this.ShowVerboseOutput();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// this.ShowNonVerboseOutput();
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,131 +0,0 @@
|
||||
//* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
using System.Xml.XPath;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "SP", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class NewServiceProvidersCmdlet : BasePSCmdlet
|
||||
{
|
||||
|
||||
private string _name = "";
|
||||
private bool _isDefault = false;
|
||||
private string _authenticationServiceURI = "";
|
||||
private string _username = "";
|
||||
private string _password = "";
|
||||
private string _defTenantId = "";
|
||||
|
||||
#region Parameters
|
||||
|
||||
[Parameter(Position = 0, ParameterSetName = "NewSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
[Parameter(Position = 1, ParameterSetName = "NewSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("url")]
|
||||
public string AuthenticationServiceURI
|
||||
{
|
||||
get { return _authenticationServiceURI; }
|
||||
set { _authenticationServiceURI = value; }
|
||||
}
|
||||
[Parameter(Position = 2, ParameterSetName = "NewSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("un")]
|
||||
public string Username
|
||||
{
|
||||
get { return _username; }
|
||||
set { _username = value; }
|
||||
}
|
||||
[Parameter(Position = 3, ParameterSetName = "NewSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("p")]
|
||||
public string Password
|
||||
{
|
||||
get { return _password; }
|
||||
set { _password = value; }
|
||||
}
|
||||
[Parameter(Position = 4, ParameterSetName = "NewSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("t")]
|
||||
public string DefTenantId
|
||||
{
|
||||
get { return _defTenantId; }
|
||||
set { _defTenantId = value; }
|
||||
}
|
||||
[Parameter(Position = 4, ParameterSetName = "NewSP", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter IsDefault
|
||||
{
|
||||
get { return _isDefault; }
|
||||
set { _isDefault = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <param name="value"></param>
|
||||
//=========================================================================================
|
||||
private XElement CreateAddElement(string name, string value)
|
||||
{
|
||||
XElement element = new XElement("add");
|
||||
element.SetAttributeValue("key", name);
|
||||
element.SetAttributeValue("value", value);
|
||||
return element;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string isDef = "False";
|
||||
if (IsDefault) {
|
||||
isDef = "True";
|
||||
}
|
||||
else {
|
||||
isDef = "False";
|
||||
}
|
||||
|
||||
List<ServiceProvider> serviceProviders = new List<ServiceProvider>();
|
||||
XDocument doc = XDocument.Load(this.ConfigFilePath);
|
||||
XElement element = new XElement("ServiceProvider", new XAttribute("name", this.Name), new XAttribute("isDefault", isDef));
|
||||
|
||||
element.Add(this.CreateAddElement("AuthenticationServiceURI", this.AuthenticationServiceURI));
|
||||
element.Add(this.CreateAddElement("Username", this.Username));
|
||||
element.Add(this.CreateAddElement("Password", this.Password));
|
||||
element.Add(this.CreateAddElement("DefaultTenantId", this.DefTenantId));
|
||||
|
||||
doc.XPathSelectElement("configuration/appSettings/IdentityServices").Add(element);
|
||||
doc.Save(this.ConfigFilePath);
|
||||
this.WriteObject("");
|
||||
this.WriteObject("New Serviced Provider " + this.Name + " created!");
|
||||
this.WriteObject("");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet("Refresh", "Cache", SupportsShouldProcess = true)]
|
||||
public class RefreshCacheCmdlet : BasePSCmdlet
|
||||
{
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.UpdateCache();
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Shell Cache Reloaded successfully.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Set, "Config", SupportsShouldProcess = true)]
|
||||
public class SetConfigCmdlet : BasePSCmdlet
|
||||
{
|
||||
//private string _configFilePath = @"C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Rackspace.Client.Powershell\Deployment\Rackspace.config";
|
||||
private string _configFilePath = null;
|
||||
private SwitchParameter _reset = false;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
//[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc3", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
//[Alias("resetcfg")]
|
||||
//[ValidateNotNullOrEmpty]
|
||||
//public SwitchParameter Reset
|
||||
//{
|
||||
// get { return _reset; }
|
||||
// set { _reset = value; }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc4", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ConfigFilePathKey
|
||||
{
|
||||
get { return _configFilePath; }
|
||||
set { _configFilePath = value; }
|
||||
}
|
||||
#endregion
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=================================================zx======================================================
|
||||
private void LoadConfigFile()
|
||||
{
|
||||
var configManager = new ConfigurationManager();
|
||||
configManager.Load(this.ConfigFilePathKey);
|
||||
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
||||
|
||||
var loader = new ExtensionManager(this.SessionState, this.Context);
|
||||
|
||||
loader.LoadCore(provider);
|
||||
loader.LoadExtension(provider);
|
||||
|
||||
// Show the User the new ServiceCatalog that we just received..
|
||||
|
||||
var capabilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient, this);
|
||||
capabilities.WriteServices();
|
||||
capabilities.WriteContainers();
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.LoadConfigFile();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Objects.Domain.Admin;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Set, "Credentials", SupportsShouldProcess = true)]
|
||||
public class SetCredentialsCmdlet : BaseAuthenticationCmdlet
|
||||
{
|
||||
private string _accessKey;
|
||||
private string _secretKey;
|
||||
private string _tenantId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, Mandatory = true, ParameterSetName = "sc5", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
[Alias("ak")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string AccessKey
|
||||
{
|
||||
get { return _accessKey; }
|
||||
set { _accessKey = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "sc5", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
[Alias("sk")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SecretKey
|
||||
{
|
||||
get { return _secretKey; }
|
||||
set { _secretKey = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, Mandatory = true, ParameterSetName = "sc5", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
[Alias("t")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string TenantId
|
||||
{
|
||||
get { return _tenantId; }
|
||||
set { _tenantId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
AuthenticationRequest request = new AuthenticationRequest(new Credentials(_accessKey, _secretKey), _tenantId);
|
||||
this.InitializeSession(request);
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,302 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using Openstack.Objects.Domain.Admin;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using System.Collections;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Collections.Generic;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Storage.CDN
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Set, "Metadata", SupportsShouldProcess = true)]
|
||||
public class SetMetadataCmdlet2 : BasePSCmdlet
|
||||
{
|
||||
private string _cdnContainerName;
|
||||
private string _sourcePath;
|
||||
private string _objectStorageContainerName;
|
||||
private string _serverId;
|
||||
private string[] _extendedProperties;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter( ParameterSetName = "containerMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("c")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ObjectStorageContainerName
|
||||
{
|
||||
get { return _objectStorageContainerName; }
|
||||
set { _objectStorageContainerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("md")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] ExtendedProperties
|
||||
{
|
||||
get { return _extendedProperties; }
|
||||
set { _extendedProperties = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "serverMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "objectMetadata", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("sp")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SourcePath
|
||||
{
|
||||
get { return _sourcePath; }
|
||||
set { _sourcePath = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Mandatory = false, ParameterSetName = "cdnMetadata", ValueFromPipelineByPropertyName = true, HelpMessage = "The Name of the Container to enable for CDN access.")]
|
||||
[Alias("cdn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string CDNContainerName
|
||||
{
|
||||
get { return _cdnContainerName; }
|
||||
set { _cdnContainerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessCDNMetadata()
|
||||
{
|
||||
if (this.Context.ServiceCatalog.DoesServiceExist(Services.CDN) == false)
|
||||
Console.WriteLine("You don't have access to CDN services under this account. For information on signing up for CDN access please go to http://Openstack.com/.");
|
||||
else
|
||||
{
|
||||
List<KeyValuePair<string, string>> metadata = new List<KeyValuePair<string, string>>();
|
||||
if (this.ExtendedProperties != null && this.ExtendedProperties.Count() > 0)
|
||||
{
|
||||
foreach (string kv in this.ExtendedProperties)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
KeyValuePair<string, string> element = new KeyValuePair<string, string>(temp[0], temp[1]);
|
||||
|
||||
metadata.Add(element);
|
||||
}
|
||||
this.RepositoryFactory.CreateCDNRepository().SetMetaData(this.CDNContainerName, metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessObjectMetadata()
|
||||
{
|
||||
IStorageObjectRepository repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
||||
StoragePath storagePath = this.CreateStoragePath(_sourcePath);
|
||||
StorageObject storageObject = new StorageObject();
|
||||
storageObject.FileName = storagePath.FileName;
|
||||
|
||||
storageObject.ExtendedProperties.AddEntries(this.ExtendedProperties);
|
||||
repository.SetMetaData(storagePath.AbsoluteURI, storageObject.ExtendedProperties);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
//=========================================================================================
|
||||
private void AddElements(MetaData metadata)
|
||||
{
|
||||
IList elements = ((CommonDriveInfo)this.Drive).CurrentContainer.Entities;
|
||||
|
||||
foreach (KeyValuePair<string, string> element in metadata)
|
||||
{
|
||||
MetaDataElement newElement = new MetaDataElement();
|
||||
newElement.Key = element.Key;
|
||||
newElement.Value = element.Value;
|
||||
|
||||
elements.Add(newElement);
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyValuePairs"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
public MetaData ReformatMetadata(string[] keyValuePairs)
|
||||
{
|
||||
MetaData metadata = new MetaData();
|
||||
|
||||
if (keyValuePairs != null && keyValuePairs.Count() > 0)
|
||||
{
|
||||
foreach (string kv in keyValuePairs)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
MetaDataElement element = new MetaDataElement();
|
||||
element.Key = temp[0];
|
||||
element.Value = temp[1];
|
||||
|
||||
metadata.Add(temp[0], temp[1]);
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ProcessServerMetadata()
|
||||
{
|
||||
if (this.Context.ServiceCatalog.DoesServiceExist(Services.Compute) == false)
|
||||
Console.WriteLine("You don't have access to Compute services under this account. For information on signing up for this please go to http://Openstack.com/.");
|
||||
else
|
||||
{
|
||||
MetaData md = null;
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
md = this.ReformatMetadata(this.ExtendedProperties);
|
||||
this.RepositoryFactory.CreateServerRepository().SetMetadata(md, this.ServerId);
|
||||
this.UpdateCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
|
||||
if (serverContainer != null)
|
||||
{
|
||||
md = this.ReformatMetadata(this.ExtendedProperties);
|
||||
this.RepositoryFactory.CreateServerRepository().SetMetadata(md, serverContainer.Entity.Id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
md = this.ReformatMetadata(this.ExtendedProperties);
|
||||
this.RepositoryFactory.CreateServerRepository().SetMetadata(md, currentContainer.Entity.Id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
private void ProcessContainerMetadata()
|
||||
{
|
||||
if (this.Context.ServiceCatalog.DoesServiceExist(Services.ObjectStorage) == false)
|
||||
Console.WriteLine("You don't have access to Object Storage services under this account. For information on signing up for this please go to http://Openstack.com/.");
|
||||
else
|
||||
{
|
||||
MetaData md = null;
|
||||
if (this.ObjectStorageContainerName != null)
|
||||
{
|
||||
List<KeyValuePair<string, string>> exProps = new List<KeyValuePair<string, string>>();
|
||||
if (this.ExtendedProperties != null && this.ExtendedProperties.Count() > 0)
|
||||
{
|
||||
foreach (string kv in this.ExtendedProperties)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
exProps.AddEntry(temp[0], temp[1]);
|
||||
}
|
||||
}
|
||||
|
||||
md = this.ReformatMetadata(this.ExtendedProperties);
|
||||
this.RepositoryFactory.CreateContainerRepository().SetMetaData(_objectStorageContainerName, exProps);
|
||||
this.UpdateCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The main driver..
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
switch (this.ParameterSetName)
|
||||
{
|
||||
case ("serverMetadata"):
|
||||
this.ProcessServerMetadata();
|
||||
break;
|
||||
|
||||
case ("cdnMetadata"):
|
||||
|
||||
this.ProcessCDNMetadata();
|
||||
break;
|
||||
|
||||
case ("objectMetadata"):
|
||||
this.ProcessObjectMetadata();
|
||||
break;
|
||||
|
||||
case ("containerMetadata"):
|
||||
this.ProcessContainerMetadata();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,121 +0,0 @@
|
||||
//* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Set, "SP", SupportsShouldProcess = true)]
|
||||
public class SetServiceProviderCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private SwitchParameter _setDefault = false;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "SetSP", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter SetDefault
|
||||
{
|
||||
get { return _setDefault; }
|
||||
set { _setDefault = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "SetSP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
var manager = new ConfigurationManager();
|
||||
manager.Load();
|
||||
|
||||
var provider = manager.GetServiceProvider(this.Name);
|
||||
provider.IsDefault = this.SetDefault;
|
||||
|
||||
this.WriteObject("");
|
||||
this.WriteObject(" - Connecting to OpenStack Provider " + this.Name);
|
||||
|
||||
this.InitialzeServiceProvider(provider);
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//==================================================================================================
|
||||
private bool DoesRequireCredentials()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//==================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//==================================================================================================
|
||||
private void InitialzeServiceProvider(ServiceProvider provider)
|
||||
{
|
||||
if (this.SetDefault)
|
||||
{
|
||||
var configManager = new ConfigurationManager();
|
||||
configManager.Load();
|
||||
configManager.SetDefaultServiceProvider(provider.Name);
|
||||
}
|
||||
|
||||
this.WriteObject(" - Loading Service Provider extensions ");
|
||||
var manager = new ExtensionManager(this.SessionState, this.Context);
|
||||
manager.LoadExtension(provider);
|
||||
this.ShowAccountState();
|
||||
}
|
||||
//=======================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=======================================================================================================
|
||||
private void ShowAccountState()
|
||||
{
|
||||
// Show the User the new ServiceCatalog that we just received..
|
||||
|
||||
this.WriteObject(" - Success!");
|
||||
this.WriteObject("");
|
||||
|
||||
// This is a hack for sure.. Need to move Zones into Vendor specific section.
|
||||
|
||||
this.Context.CurrentRegion = "region-a.geo-1";
|
||||
|
||||
var capabilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient, this);
|
||||
capabilities.WriteServices();
|
||||
capabilities.WriteContainers();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using OpenStack.Client.Powershell.Cmdlets.Common;
|
||||
using OpenStack.Client.Powershell.Utility;
|
||||
|
||||
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet("Set", "Zone", SupportsShouldProcess = true)]
|
||||
public class SetZoneCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _Zone;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "SetZone", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("z")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[ValidateSet("1", "2", "3", "4", "5")]
|
||||
public string Zone
|
||||
{
|
||||
get { return _Zone; }
|
||||
set { _Zone = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.Drive.Provider.Name != "OpenStack-Cloud" && this.Drive.Provider.Name != "Object Storage") {
|
||||
ShowError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mark down the new default Region and reload the config file..
|
||||
|
||||
XElement zoneKeyNode = SaveZone();
|
||||
this.Context.CurrentRegion = zoneKeyNode.Attribute("name").Value;
|
||||
this.Context.Settings.Load(this.ConfigFilePath);
|
||||
|
||||
ConfigurationManager manager = new ConfigurationManager();
|
||||
manager.Load();
|
||||
|
||||
this.SetUI(zoneKeyNode);
|
||||
this.ChanegDirectory();
|
||||
this.UpdateCache();
|
||||
|
||||
// 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>
|
||||
//=======================================================================================================
|
||||
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)
|
||||
{
|
||||
this.WriteHeader("This Availability Zone has the following services available.");
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||
WriteObject(this.Context.ServiceCatalog.GetServicesInAvailabilityZone(availabilityZone));
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void WriteHeader(string message)
|
||||
{
|
||||
// Write out the commands header information first..
|
||||
|
||||
WriteObject("");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("===================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
WriteObject(message);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
WriteObject("===================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
WriteObject(" ");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/* ============================================================================
|
||||
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 Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System.Management.Automation;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Common
|
||||
{
|
||||
[Cmdlet("Set", "ZoneColor", SupportsShouldProcess = true)]
|
||||
public class SetZoneColorCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _zone;
|
||||
private string _color;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "SetZoneColor", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("c")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[ValidateSet("Black", "Blue", "Cyan", "DarkBlue", "DarkCyan", "DarkGray", "DarkGreen", "DarkMagenta", "DarkRed", "DarkYellow", "Gray", "Green", "Magenta", "Red", "White", "Yellow")]
|
||||
public string Color
|
||||
{
|
||||
get { return _color; }
|
||||
set { _color = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "SetZoneColor", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("z")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[ValidateSet("1", "2", "3", "4")]
|
||||
public string Zone
|
||||
{
|
||||
get { return _zone; }
|
||||
set { _zone = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
XDocument doc = XDocument.Load(configFilePath);
|
||||
XElement zoneKeyNode = doc.XPathSelectElement("//AvailabilityZone[@id='" + _zone + "']");
|
||||
|
||||
zoneKeyNode.SetAttributeValue("shellForegroundColor", _color);
|
||||
doc.Save(configFilePath);
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.Write(zoneKeyNode.Attribute("name").Value + " now assigned to ");
|
||||
|
||||
ConsoleColor currentColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), zoneKeyNode.Attribute("shellForegroundColor").Value);
|
||||
|
||||
Console.Write(_color + ".");
|
||||
Console.ForegroundColor = currentColor;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Security;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using Openstack.Objects.DataAccess.Compute;
|
||||
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Security
|
||||
{
|
||||
[Cmdlet("Get", "Limits", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class GetLimitsCmdlet : BasePSCmdlet
|
||||
{
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
Limits limits = this.RepositoryFactory.CreateServerRepository().GetLimits();
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("The following Limits are in place for this account.");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Limit Category : Absolute");
|
||||
Console.WriteLine("-------------------------------------------------");
|
||||
Console.WriteLine("Max Server Metadata Elements : " + limits.limits.AbsoluteLimits.maxServerMeta);
|
||||
Console.WriteLine("Max Personality : " + limits.limits.AbsoluteLimits.maxPersonality);
|
||||
Console.WriteLine("Max Image Metadata Elements : " + limits.limits.AbsoluteLimits.maxImageMeta);
|
||||
Console.WriteLine("Max Personality Size : " + limits.limits.AbsoluteLimits.maxPersonalitySize);
|
||||
Console.WriteLine("Max Security Group Rules : " + limits.limits.AbsoluteLimits.maxSecurityGroupRules);
|
||||
Console.WriteLine("Max Security Groups : " + limits.limits.AbsoluteLimits.maxSecurityGroups);
|
||||
Console.WriteLine("Max Total Instances : " + limits.limits.AbsoluteLimits.maxTotalInstances);
|
||||
Console.WriteLine("Max Total RAM Size : " + limits.limits.AbsoluteLimits.maxTotalRAMSize);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,129 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.DataAccess.Security;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain.Compute.Servers.Actions;
|
||||
using System;
|
||||
using Openstack.Objects.DataAccess.Compute;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "Password", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class GetPasswordCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _administratorPassword;
|
||||
private string _serverId;
|
||||
private string _keyName;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "GetPassword", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("k")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string KeyName
|
||||
{
|
||||
get { return _keyName; }
|
||||
set { _keyName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "GetPassword", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private string GetServerId()
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
if (serverContainer != null)
|
||||
return serverContainer.Entity.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return currentContainer.Entity.Id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.ServerId == null)
|
||||
this.ServerId = this.GetServerId();
|
||||
|
||||
IServerRepository repository = this.RepositoryFactory.CreateServerRepository();
|
||||
GetServerLogAction action = new GetServerLogAction();
|
||||
action.ServerId = this.ServerId;
|
||||
Log log = repository.GetServerLog(action);
|
||||
|
||||
if (log != null && log.Content.Length > 14)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Log detected!");
|
||||
string pw = log.ExtractAdminPassword(this.Settings.KeyStoragePath + @"\OS\" + _keyName + ".pem");
|
||||
Console.WriteLine("Administrator Password : " + pw);
|
||||
Console.WriteLine("");
|
||||
|
||||
if (this.Settings.EnableCredentialTracking == true)
|
||||
{
|
||||
CredentialListManager manager = new CredentialListManager(this.Settings);
|
||||
manager.SetPassword(this.ServerId, pw);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Unfortunately we couldn't retrieve the Instance Log. If this situation persist, we recommend that you delete and recreate the instance.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.Security;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using Openstack.Objects.Domain.Server;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Network
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "KeyPair", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class NewKeyPairCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _filename = null;
|
||||
private SwitchParameter _copyToClipboard = false;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
//[Parameter(Position = 2, ParameterSetName = "NewKeypair", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "a")]
|
||||
//[Alias("c")]
|
||||
//public SwitchParameter CopyToClipboard
|
||||
//{
|
||||
// get { return _copyToClipboard; }
|
||||
// set { _copyToClipboard = value; }
|
||||
//}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewKeypair", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "a")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void StoreKey(string privateKey)
|
||||
{
|
||||
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ExportKey(string privateKey, string filename)
|
||||
{
|
||||
// Save the key locally first..
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.AppendLine(privateKey);
|
||||
|
||||
using (StreamWriter outfile = new StreamWriter(this.Settings.KeyStoragePath + @"\OS\" + filename, false))
|
||||
{
|
||||
outfile.Write(builder.ToString());
|
||||
}
|
||||
|
||||
// Now export with PuttyGen
|
||||
|
||||
//Process.Start(this.Settings.PuttuGenPath, this.Settings.KeyStoragePath + @"\TempKey.key -O private -o " + this.Settings.KeyStoragePath + "testKey.ppk" + "-q");
|
||||
//int y = 9;
|
||||
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewKeyPair nkp = new NewKeyPair();
|
||||
nkp.Name = this.Name;
|
||||
KeyPair keypair = this.RepositoryFactory.CreateKeyPairRepository().SaveKeyPair(nkp);
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("New keypair created.");
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("User Id : " + keypair.UserId);
|
||||
Console.WriteLine("Name : " + keypair.Name);
|
||||
Console.WriteLine("Private Key : ");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine(keypair.PrivateKey);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Public Key : ");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine(keypair.PublicKey);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Fingerprint : " + keypair.Fingerprint);
|
||||
Console.WriteLine("");
|
||||
|
||||
this.ExportKey(keypair.PrivateKey, keypair.Name + ".pem");
|
||||
|
||||
if (_copyToClipboard)
|
||||
{
|
||||
OutClipboard.SetText(keypair.PrivateKey);
|
||||
}
|
||||
|
||||
Console.WriteLine("Exporting Private Key.");
|
||||
Console.WriteLine("Storing Key.");
|
||||
Console.WriteLine("Key Generation and storage complete.");
|
||||
Console.WriteLine("");
|
||||
this.UpdateCache<KeyPairsUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Network
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "KeyPair", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveKeyPairCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RemoveKeyPair", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "a")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.RepositoryFactory.CreateKeyPairRepository().DeleteKeyPair(this.Name);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Keypair " + this.Name + " removed.");
|
||||
Console.WriteLine("");
|
||||
this.UpdateCache<KeyPairsUIContainer>();
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Error : Keypair " + this.Name + " not found.");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.DataAccess.Security;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Reset, "Password", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class ResetPasswordCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _administratorPassword;
|
||||
private string _serverId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "ResetPassword", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "ResetPassword", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("p")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string AdministratorPassword
|
||||
{
|
||||
get { return _administratorPassword; }
|
||||
set { _administratorPassword = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ChangeWindowsImagePW()
|
||||
{
|
||||
CredentialListManager manager = new CredentialListManager(this.Settings);
|
||||
if (this.Settings.EnableCredentialTracking == true)
|
||||
{
|
||||
manager.SetPassword(this.ServerId, this.AdministratorPassword);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Password Updated.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("You're attempting to update the password for a Windows Image but EnableCredentialTracking is currently turned off. To turn this on please use the Get-config and Set-config cmdlets. Operation failed.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ChangeNonWindowsImagePW()
|
||||
{
|
||||
ChangePasswordAction action = new ChangePasswordAction();
|
||||
action.AdministratorPassword = this.AdministratorPassword;
|
||||
action.ServerId = this.ServerId;
|
||||
|
||||
this.RepositoryFactory.CreateServerRepository().ChangePassword(action);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Password Changed.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private string GetServerId()
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
if (serverContainer != null)
|
||||
return serverContainer.Entity.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
return currentContainer.Entity.Id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private bool IsWindowsImage(string imageId)
|
||||
{
|
||||
Image image = this.RepositoryFactory.CreateImageRepository().GetImage(imageId);
|
||||
return image.IsWindowsImage;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.ServerId == null)
|
||||
this.ServerId = this.GetServerId();
|
||||
|
||||
Openstack.Objects.Domain.Compute.Server server = this.RepositoryFactory.CreateServerRepository().GetServer(this.ServerId);
|
||||
|
||||
if (this.IsWindowsImage(server.Image.Id)) {
|
||||
ChangeWindowsImagePW();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Invalid Server : The Server you supplied is not a based on a Windows image. We currently only support key based authentication for non-Windows images.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,316 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using Openstack.Objects.DataAccess.Compute;
|
||||
using Openstack.Objects.DataAccess.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.Domain.Compute.Servers.Actions;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet("Connect", "Server", SupportsShouldProcess = true)]
|
||||
public class ConnectServerCmdletd : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _keypairName = null;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "ConnectServerPS", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("s")]
|
||||
public string ServerId
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_serverId != null)
|
||||
return _serverId;
|
||||
else
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
ServerUIContainer serverContainer = currentContainer as ServerUIContainer;
|
||||
|
||||
if (serverContainer != null) {
|
||||
return serverContainer.Entity.Id;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
set { _serverId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private bool IsWindowsImage(string imageId)
|
||||
{
|
||||
Image image = this.RepositoryFactory.CreateImageRepository().GetImage(imageId);
|
||||
return image.IsWindowsImage;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private string GetAdminPassword(string keyname)
|
||||
{
|
||||
GetServerLogAction action = new GetServerLogAction();
|
||||
action.ServerId = this.ServerId;
|
||||
Log log = this.RepositoryFactory.CreateServerRepository().GetServerLog(action);
|
||||
|
||||
if (log != null)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
string pw = log.ExtractAdminPassword(this.Settings.KeyStoragePath + keyname + ".pem");
|
||||
Console.WriteLine("Administrator Password : " + pw);
|
||||
return pw;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ShowCredentialsNotFoundMsg()
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Credentials not found. You'll have to manually enter your Administrator credentials for this instance.");
|
||||
Console.WriteLine("If you want to continue to use Automatic Credential Tracking for this instance make sure that you update");
|
||||
Console.WriteLine("our records with the new password. To do this, use the Reset-Password cmdlet.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
//=========================================================================================
|
||||
private void WriteSection(string headerText)
|
||||
{
|
||||
ConsoleColor oldColor = Console.ForegroundColor;
|
||||
Console.WriteLine(" ");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("==============================================================================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine(headerText);
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("==============================================================================================================================================");
|
||||
Console.ForegroundColor = oldColor;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//===================================================================================K=====
|
||||
private void ShowKeyBasedLoginInstructions(string keyname)
|
||||
{
|
||||
if (keyname == null) keyname = "YourKeyfile";
|
||||
|
||||
this.WriteSection("Unable to find a suitable Putty key file!");
|
||||
Console.WriteLine("1. Make sure that you have downloaded the latest version of Putty and PuttyGen for Windows.");
|
||||
Console.WriteLine("2. Tell us where Putty.exe exist by setting the Config file entry SSHClientPath (use Set-Config)");
|
||||
Console.WriteLine("3. Tell PuttyGen to Load an existing key file. This file will be located at " + this.Settings.KeyStoragePath + @"\OS\" + keyname + ".pem");
|
||||
Console.WriteLine("4. Convert the .pem file to the .ppk format that Putty.exe understands by clicking the Save Private Key button.");
|
||||
Console.WriteLine("5. Save the .ppk file as " + keyname + ".ppk");
|
||||
Console.WriteLine("6. Launch the SSH session with the Connect-Server cmdlet");
|
||||
Console.WriteLine("7. HINT : If you use the same keypair name for each Server you create you can skip steps 1-5 after the steps have been completed once.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private bool LaunchPasswordBasedSSHSession(Openstack.Objects.Domain.Compute.Server server)
|
||||
{
|
||||
CredentialListManager manager = new CredentialListManager(this.Settings);
|
||||
SSHClient sshClient = new SSHClient(this.Settings);
|
||||
sshClient.Username = "ubuntu";
|
||||
sshClient.Address = server.Addresses.Private[1].Addr;
|
||||
sshClient.Password = manager.GetPassword(server.Id);
|
||||
|
||||
if (sshClient.Password == null) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
sshClient.LaunchClient();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private bool IsSSHClientConfigured()
|
||||
{
|
||||
if (this.Settings.SSHClientPath == string.Empty)
|
||||
return false;
|
||||
else
|
||||
return File.Exists(this.Settings.SSHClientPath);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private bool DoesPPKExist(string keyName)
|
||||
{
|
||||
return File.Exists(this.Settings.KeyStoragePath + @"\OS\" + keyName + ".ppk");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void SaveSSHClientLocation(string path)
|
||||
{
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
XDocument doc = XDocument.Load(configFilePath);
|
||||
XElement clientPathNode = doc.XPathSelectElement("//add[@key='SSHClientPath']");
|
||||
|
||||
clientPathNode.SetAttributeValue("value", path);
|
||||
doc.Save(configFilePath);
|
||||
this.Settings.SSHClientPath = path;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ConfigureSSHClient()
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("You're trying to establish a remote session with a non-Windows based server. This requires a fully qualified path to the SSH client (putty.exe)");
|
||||
Console.Write("SSH Client Path : ");
|
||||
string path = Console.ReadLine();
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Putty.exe found! Saving location for future sessions..");
|
||||
Console.WriteLine("");
|
||||
this.SaveSSHClientLocation(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Putty.exe not found! Invalid path supplied.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void LaunchSSHSession(Openstack.Objects.Domain.Compute.Server server)
|
||||
{
|
||||
if (!IsSSHClientConfigured()) {
|
||||
this.ConfigureSSHClient();
|
||||
}
|
||||
|
||||
if (server.KeyName != null && this.DoesPPKExist(server.KeyName))
|
||||
{
|
||||
SSHClient sshClient = new SSHClient(this.Settings);
|
||||
sshClient.Username = "ubuntu";
|
||||
sshClient.KeypairName = server.KeyName;
|
||||
sshClient.Address = server.Addresses.Private[1].Addr;
|
||||
|
||||
sshClient.LaunchClient();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ShowKeyBasedLoginInstructions(server.KeyName);
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void LaunchWindowsSession(Openstack.Objects.Domain.Compute.Server server)
|
||||
{
|
||||
CredentialListManager manager = new CredentialListManager(this.Settings);
|
||||
RDPClient client = new RDPClient();
|
||||
client.Address = server.Addresses.Private[1].Addr;
|
||||
client.Username = "Administrator";
|
||||
|
||||
if (this.Settings.EnableCredentialTracking == true)
|
||||
{
|
||||
client.Password = manager.GetPassword(server.Id);
|
||||
if (client.Password == null)
|
||||
{
|
||||
this.ShowCredentialsNotFoundMsg();
|
||||
return;
|
||||
}
|
||||
}
|
||||
client.LaunchClient();
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.ServerId);
|
||||
if (id != null)
|
||||
{
|
||||
Openstack.Objects.Domain.Compute.Server server = this.RepositoryFactory.CreateServerRepository().GetServer(id);
|
||||
if (server != null)
|
||||
{
|
||||
if (IsWindowsImage(server.Image.Id))
|
||||
{
|
||||
this.LaunchWindowsSession(server);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.LaunchSSHSession(server);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Server not found.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,176 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "Image", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class NewImageCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string[] _metadata;
|
||||
private string _serverId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "NewImage", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewImage", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "NewImage", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("md")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] MetaData
|
||||
{
|
||||
get { return _metadata; }
|
||||
set { _metadata = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyValuePairs"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
public MetaData AddEntries(string[] keyValuePairs)
|
||||
{
|
||||
MetaData metadata = new MetaData();
|
||||
|
||||
if (keyValuePairs != null && keyValuePairs.Count() > 0)
|
||||
{
|
||||
foreach (string kv in keyValuePairs)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
MetaDataElement element = new MetaDataElement();
|
||||
element.Key = temp[0];
|
||||
element.Value = temp[1];
|
||||
|
||||
metadata.Add(temp[0], temp[1]);
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyValuePairs"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
public MetaData ReformatMetadata(string[] keyValuePairs)
|
||||
{
|
||||
MetaData metadata = new MetaData();
|
||||
|
||||
if (keyValuePairs != null && keyValuePairs.Count() > 0)
|
||||
{
|
||||
foreach (string kv in keyValuePairs)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
MetaDataElement element = new MetaDataElement();
|
||||
element.Key = temp[0];
|
||||
element.Value = temp[1];
|
||||
|
||||
metadata.Add(temp[0], temp[1]);
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
MetaData md = null;
|
||||
md = this.ReformatMetadata(this.MetaData);
|
||||
NewImage image = new NewImage();
|
||||
image.MetaData = md;
|
||||
image.Name = this.Name;
|
||||
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
image.ServerId = this.ServerId;
|
||||
this.RepositoryFactory.CreateImageRepository().SaveImage(image);
|
||||
this.UpdateCache<ImageUIContainer>();
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
|
||||
if (serverContainer != null)
|
||||
{
|
||||
image.ServerId = serverContainer.Entity.Id;
|
||||
this.RepositoryFactory.CreateImageRepository().SaveImage(image);
|
||||
this.UpdateCache<ImagesUIContainer>();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
image.ServerId = currentContainer.Entity.Id;
|
||||
this.RepositoryFactory.CreateImageRepository().SaveImage(image);
|
||||
this.UpdateCache<ImagesUIContainer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,323 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.Security;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using Openstack.Objects.DataAccess.Compute;
|
||||
using System.Threading;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "Server", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class NewServerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _imageId;
|
||||
private string _flavorId;
|
||||
private string _password;
|
||||
private string _accessIPv4;
|
||||
private string _accessIPv6;
|
||||
private string _keyName;
|
||||
private string[] _metadata;
|
||||
private string[] _securityGroups;
|
||||
private bool _useWizard = false;
|
||||
private string[] _networksIds;
|
||||
private string _availabilityZone;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewServerPS", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewServerPS", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A valid reference to an Image.")]
|
||||
[Alias("i")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ImageRef
|
||||
{
|
||||
get { return _imageId; }
|
||||
set { _imageId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewServerPS", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "A reference to a valid Flavor.Image")]
|
||||
[Alias("f")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string FlavorRef
|
||||
{
|
||||
get { return _flavorId; }
|
||||
set { _flavorId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, ParameterSetName = "NewServerPS", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "ipv4 address for remote access.")]
|
||||
[Alias("ip4")]
|
||||
public string AccessIPv4
|
||||
{
|
||||
get { return _accessIPv4; }
|
||||
set { _accessIPv4 = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 4, ParameterSetName = "NewServerPS", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "ipv6 address for remote access.")]
|
||||
[Alias("ip6")]
|
||||
public string AccessIPv6
|
||||
{
|
||||
get { return _accessIPv6; }
|
||||
set { _accessIPv6 = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, Mandatory = false, ParameterSetName = "NewServerPS", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("md")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] MetaData
|
||||
{
|
||||
get { return _metadata; }
|
||||
set { _metadata = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 6, ParameterSetName = "NewServerPS", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("k")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string KeyName
|
||||
{
|
||||
get { return _keyName; }
|
||||
set { _keyName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 7, Mandatory = false, ParameterSetName = "NewServerPS", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("sg")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] SecurityGroups
|
||||
{
|
||||
get { return _securityGroups; }
|
||||
set { _securityGroups = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 8, Mandatory = true, ParameterSetName = "NewServerPS", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("nid")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] NetworksIds
|
||||
{
|
||||
get { return _networksIds; }
|
||||
set { _networksIds = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 9, ParameterSetName = "NewServerPS", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("az")]
|
||||
public string AvailabilityZone
|
||||
{
|
||||
get { return _availabilityZone; }
|
||||
set { _availabilityZone = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyValuePairs"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
public MetaData AddEntries(string[] keyValuePairs)
|
||||
{
|
||||
MetaData metadata = new MetaData();
|
||||
|
||||
if (keyValuePairs != null && keyValuePairs.Count() > 0)
|
||||
{
|
||||
foreach (string kv in keyValuePairs)
|
||||
{
|
||||
char[] seperator = { '|' };
|
||||
string[] temp = kv.Split(seperator);
|
||||
MetaDataElement element = new MetaDataElement();
|
||||
element.Key = temp[0];
|
||||
element.Value = temp[1];
|
||||
|
||||
metadata.Add(temp[0], temp[1]);
|
||||
}
|
||||
return metadata;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private List<SecurityGroupAssignment> GetSecurityGroups()
|
||||
{
|
||||
List<SecurityGroupAssignment> assignments = new List<SecurityGroupAssignment>();
|
||||
|
||||
if (_securityGroups != null)
|
||||
{
|
||||
foreach (string sg in _securityGroups)
|
||||
{
|
||||
assignments.Add(new SecurityGroupAssignment(sg));
|
||||
}
|
||||
}
|
||||
|
||||
return assignments;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private bool IsWindowsImage(string imageId)
|
||||
{
|
||||
Image image = this.RepositoryFactory.CreateImageRepository().GetImage(imageId);
|
||||
return image.IsWindowsImage;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private List<NetworkId> GetNetworkIDs()
|
||||
{
|
||||
if (this.NetworksIds != null)
|
||||
{
|
||||
List<NetworkId> ids = new List<NetworkId>();
|
||||
foreach (string id in this.NetworksIds)
|
||||
{
|
||||
NetworkId uuid = new NetworkId(id);
|
||||
ids.Add(uuid);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void SaveServer()
|
||||
{
|
||||
NewServer server = new NewServer();
|
||||
server.Name = this.Name;
|
||||
server.ImageRef = this.ImageRef;
|
||||
server.FlavorRef = this.FlavorRef;
|
||||
server.AccessIPv6 = this.AccessIPv6;
|
||||
server.AccessIPv4 = this.AccessIPv4;
|
||||
server.MetaData = this.AddEntries(this.MetaData);
|
||||
server.KeyName = this.KeyName;
|
||||
server.SecurityGroups = this.GetSecurityGroups();
|
||||
server.Networks = this.GetNetworkIDs();
|
||||
server.AvailabilityZone = this.AvailabilityZone;
|
||||
|
||||
if (IsWindowsImage(this.ImageRef))
|
||||
{
|
||||
WindowsInstanceBuilder builder = new WindowsInstanceBuilder(this.RepositoryFactory, this.Settings);
|
||||
builder.Changed += new Openstack.Objects.DataAccess.Compute.WindowsInstanceBuilder.CreateInstanceEventHandler(BuilderEvent);
|
||||
builder.CreateInstance(server);
|
||||
builder.Changed -= new Openstack.Objects.DataAccess.Compute.WindowsInstanceBuilder.CreateInstanceEventHandler(BuilderEvent);
|
||||
this.UpdateCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
NonWindowsInstanceBuilder nonWIBuilder = new NonWindowsInstanceBuilder(this.RepositoryFactory, this.Settings);
|
||||
nonWIBuilder.Changed += new Openstack.Objects.DataAccess.Compute.NonWindowsInstanceBuilder.CreateInstanceEventHandler(BuilderEvent);
|
||||
nonWIBuilder.CreateInstance(server, _keyName);
|
||||
nonWIBuilder.Changed -= new Openstack.Objects.DataAccess.Compute.NonWindowsInstanceBuilder.CreateInstanceEventHandler(BuilderEvent);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//=========================================================================================
|
||||
private void BuilderEvent(object sender, CreateInstanceEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private NewServer ShowNewServerWizard()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.SaveServer();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,180 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet("Ping", "Server", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class PingServerCmdletd : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "PingwServerPS", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("s")]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
//=========================================================================================
|
||||
private void PingServer(string address)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Pinging Server : " + address);
|
||||
AutoResetEvent waiter = new AutoResetEvent(false);
|
||||
|
||||
Ping pingSender = new Ping();
|
||||
|
||||
// When the PingCompleted event is raised,
|
||||
// the PingCompletedCallback method is called.
|
||||
pingSender.PingCompleted += new PingCompletedEventHandler(PingCompletedCallback);
|
||||
|
||||
// Create a buffer of 32 bytes of data to be transmitted.
|
||||
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
byte[] buffer = Encoding.ASCII.GetBytes(data);
|
||||
|
||||
// Wait 12 seconds for a reply.
|
||||
int timeout = 12000;
|
||||
|
||||
// Set options for transmission:
|
||||
// The data can go through 64 gateways or routers
|
||||
// before it is destroyed, and the data packet
|
||||
// cannot be fragmented.
|
||||
PingOptions options = new PingOptions(64, true);
|
||||
|
||||
Console.WriteLine("Time to live : {0}", options.Ttl);
|
||||
Console.WriteLine("Don't fragment : {0}", options.DontFragment);
|
||||
|
||||
// Send the ping asynchronously.
|
||||
// Use the waiter as the user token.
|
||||
// When the callback completes, it can wake up this thread.
|
||||
pingSender.SendAsync(address, timeout, buffer, options, waiter);
|
||||
|
||||
// Prevent this example application from ending.
|
||||
// A real application should do something useful
|
||||
// when possible.
|
||||
waiter.WaitOne();
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private IList<IPAddress> GetServerIPAddresses(string serverId)
|
||||
{
|
||||
Openstack.Objects.Domain.Compute.Server server = this.RepositoryFactory.CreateServerRepository().GetServer(serverId);
|
||||
return server.Addresses.Private;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
IList<IPAddress> addresses = this.GetServerIPAddresses(this.ServerId);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine(addresses.Count + " assigned IP addresses found. Ping results are as follows.");
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (IPAddress address in addresses)
|
||||
{
|
||||
this.PingServer(address.Addr);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private static void PingCompletedCallback(object sender, PingCompletedEventArgs e)
|
||||
{
|
||||
// If the operation was canceled, display a message to the user.
|
||||
if (e.Cancelled)
|
||||
{
|
||||
Console.WriteLine("Ping canceled.");
|
||||
|
||||
// Let the main thread resume.
|
||||
// UserToken is the AutoResetEvent object that the main thread
|
||||
// is waiting for.
|
||||
((AutoResetEvent)e.UserState).Set();
|
||||
}
|
||||
|
||||
// If an error occurred, display the exception to the user.
|
||||
if (e.Error != null)
|
||||
{
|
||||
Console.WriteLine("Ping failed:");
|
||||
Console.WriteLine(e.Error.ToString());
|
||||
|
||||
// Let the main thread resume.
|
||||
((AutoResetEvent)e.UserState).Set();
|
||||
}
|
||||
|
||||
PingReply reply = e.Reply;
|
||||
|
||||
DisplayReply(reply);
|
||||
|
||||
// Let the main thread resume.
|
||||
((AutoResetEvent)e.UserState).Set();
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
public static void DisplayReply(PingReply reply)
|
||||
{
|
||||
if (reply == null)
|
||||
return;
|
||||
|
||||
Console.WriteLine("ping status : {0}", reply.Status);
|
||||
if (reply.Status == IPStatus.Success)
|
||||
{
|
||||
Console.WriteLine("Address : {0}", reply.Address.ToString());
|
||||
Console.WriteLine("RoundTrip time : {0}", reply.RoundtripTime);
|
||||
Console.WriteLine("Time to live : {0}", reply.Options.Ttl);
|
||||
Console.WriteLine("Don't fragment : {0}", reply.Options.DontFragment);
|
||||
Console.WriteLine("Buffer size : {0}", reply.Buffer.Length);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,112 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
using System;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet("Reboot", "Server", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RebootServerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private ServerRebootType _type = ServerRebootType.SOFT;
|
||||
private string _serverId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RebootServer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "RebootServer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[Alias("t")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
[ValidateSet("SOFT", "HARD")]
|
||||
public ServerRebootType Type
|
||||
{
|
||||
get { return _type; }
|
||||
set { _type = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.ServerId);
|
||||
|
||||
RebootAction action = new RebootAction();
|
||||
action.RebootType = this.Type;
|
||||
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
action.ServerId = id;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Rebooting Server " + id);
|
||||
Console.WriteLine("");
|
||||
this.RepositoryFactory.CreateServerRepository().Reboot(action);
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
|
||||
if (serverContainer != null)
|
||||
{
|
||||
action.ServerId = serverContainer.Entity.Id;
|
||||
this.RepositoryFactory.CreateServerRepository().Reboot(action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer as ServerUIContainer;
|
||||
if (serverContainer != null)
|
||||
{
|
||||
action.ServerId = serverContainer.Entity.Id;
|
||||
this.RepositoryFactory.CreateServerRepository().Reboot(action);
|
||||
this.UpdateCache<ServerUIContainer>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Metadata", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveMetadataCmdletd : BasePSCmdlet
|
||||
{
|
||||
private string _key;
|
||||
private string _serverId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "RemoveMetadata", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, Mandatory = true, ParameterSetName = "RemoveMetadata", ValueFromPipelineByPropertyName = true, HelpMessage = "sdfgh")]
|
||||
[Alias("k")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Key
|
||||
{
|
||||
get { return _key; }
|
||||
set { _key = value; }
|
||||
}
|
||||
#endregion
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
//=========================================================================================
|
||||
private void RemoveElement(string key)
|
||||
{
|
||||
IList elements = ((CommonDriveInfo)this.Drive).CurrentContainer.Entities;
|
||||
MetaDataElement mdElement = null;
|
||||
|
||||
foreach (MetaDataElement element in elements)
|
||||
{
|
||||
if (element.Key == this.Key)
|
||||
{
|
||||
mdElement = element;
|
||||
}
|
||||
}
|
||||
|
||||
elements.Remove(mdElement);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
this.RepositoryFactory.CreateServerRepository().DeleteMetadata(this.ServerId, this.Key);
|
||||
this.RemoveElement(this.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseUIContainer currentContainer = this.SessionState.PSVariable.Get("CurrentContainer").Value as BaseUIContainer;
|
||||
|
||||
if (currentContainer.Name == "Metadata")
|
||||
{
|
||||
ServerUIContainer serverContainer = currentContainer.Parent as ServerUIContainer;
|
||||
|
||||
if (serverContainer != null) {
|
||||
this.RepositoryFactory.CreateServerRepository().DeleteMetadata(serverContainer.Entity.Id, this.Key);
|
||||
this.RemoveElement(this.Key);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.RepositoryFactory.CreateServerRepository().DeleteMetadata(currentContainer.Entity.Id, this.Key);
|
||||
this.RemoveElement(this.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Management.Automation.Host;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Server", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveServerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private SwitchParameter _force = false;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "RemoveServer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RemoveServer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllServers()
|
||||
{
|
||||
List<Openstack.Objects.Domain.Compute.Server> servers = this.RepositoryFactory.CreateServerRepository().GetServers();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach(Openstack.Objects.Domain.Compute.Server server in servers)
|
||||
{
|
||||
if (server.Name != "RGWinLarge")
|
||||
{
|
||||
Console.WriteLine("Removing Server : " + server.Name);
|
||||
this.RepositoryFactory.CreateServerRepository().DeleteServer(server.Id);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.ServerId);
|
||||
|
||||
if (_force)
|
||||
{
|
||||
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||
choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
Console.WriteLine("");
|
||||
if (this.Host.UI.PromptForChoice("Confirm Action", "You are about to remove all active Server instances. Are you sure about this?", choices, 0) == 0)
|
||||
this.RemoveAllServers();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
this.RepositoryFactory.CreateServerRepository().DeleteServer(id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,96 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Objects.Domain.Compute.Servers;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Server
|
||||
{
|
||||
[Cmdlet("Update", "Server", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class UpdateServerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _name;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdateServer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdateServer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void UpdateName(string name)
|
||||
{
|
||||
BaseUIContainer server = ((CommonDriveInfo)this.Drive).CurrentContainer;
|
||||
server.Name = name;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
Openstack.Objects.Domain.Compute.Server server = new Openstack.Objects.Domain.Compute.Server();
|
||||
if (this.ServerId != null)
|
||||
{
|
||||
server.Id = this.ServerId;
|
||||
server.Name = this.Name;
|
||||
|
||||
this.RepositoryFactory.CreateServerRepository().UpdateServer(server);
|
||||
this.UpdateName(this.Name);
|
||||
this.UpdateCache<ServersUIContainer>();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,93 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Assign", "IP", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class AssignIPCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _ip;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("ip")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string IpAddress
|
||||
{
|
||||
get { return _ip; }
|
||||
set { _ip = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (!this.ServerId.Contains("."))
|
||||
{
|
||||
IFloatingIPRepository repository = new FloatingIPRepository(this.Context.GetRepositoryContext("compute"));
|
||||
|
||||
AssignIPAction assignment = new AssignIPAction();
|
||||
assignment.ServerId = this.ServerId;
|
||||
assignment.Ip = this.IpAddress;
|
||||
|
||||
repository.AssignIP(assignment);
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Floating IP Address " + this.IpAddress + " now assigned to Server : " + assignment.ServerId);
|
||||
Console.WriteLine("");
|
||||
this.UpdateCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
InvalidOperationException ex = new InvalidOperationException("Please check the supplied parameters. IP addresses are not allowed in place of Server IDs.", null);
|
||||
WriteError(new ErrorRecord(ex, "0", ErrorCategory.InvalidArgument, null));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,107 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "FloatingIP", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class DeleteFloatingIPCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _floatingIPId;
|
||||
private SwitchParameter _force = false;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeleteFloatingIP", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeleteFloatingIP2", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("id")]
|
||||
public string FloatingIP
|
||||
{
|
||||
get { return _floatingIPId; }
|
||||
set { _floatingIPId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllFloatingIPs()
|
||||
{
|
||||
IFloatingIPRepository repository = this.RepositoryFactory.CreateFloatingIPRepository();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (BaseEntity entity in this.CurrentContainer.Entities)
|
||||
{
|
||||
if (entity.Name != null)
|
||||
Console.WriteLine("Removing Floating IP : " + entity.Name);
|
||||
else
|
||||
Console.WriteLine("Removing Floating IP : " + entity.Id);
|
||||
|
||||
repository.DeleteFloatingIP(entity.Id);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (_force)
|
||||
{
|
||||
if (this.UserConfirmsDeleteAction("Floating IP Addresses"))
|
||||
{
|
||||
this.RemoveAllFloatingIPs();
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.FloatingIP);
|
||||
this.RepositoryFactory.CreateFloatingIPRepository().DeleteFloatingIP(id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Network", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.)]
|
||||
public class DeleteNetworkCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _networkId;
|
||||
private SwitchParameter _removeAll = false;
|
||||
private SwitchParameter _force = true;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeleteNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("id")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeleteNetwork2", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _removeAll; }
|
||||
set { _removeAll = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "DeleteNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("f")]
|
||||
public SwitchParameter Force
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//=========================================================================================
|
||||
private void BuilderEvent(object sender, CreateNetworkEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllNetworks()
|
||||
{
|
||||
INetworkRepository repository = this.RepositoryFactory.CreateNetworkRepository();
|
||||
List<Network> networks = repository.GetNetworks();
|
||||
|
||||
repository.Changed += new Openstack.Objects.DataAccess.Networking.NetworkRepository.CreateNetworkEventHandler(BuilderEvent);
|
||||
foreach (BaseEntity entity in this.CurrentContainer.Entities)
|
||||
{
|
||||
if (entity.Name != "Ext-Net")
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Removing Network : " + entity.Name);
|
||||
Console.WriteLine("");
|
||||
repository.DeleteNetwork(entity.Id, _force);
|
||||
}
|
||||
}
|
||||
Console.WriteLine("");
|
||||
repository.Changed -= new Openstack.Objects.DataAccess.Networking.NetworkRepository.CreateNetworkEventHandler(BuilderEvent);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
|
||||
if (_networkId == null && _removeAll == false)
|
||||
{
|
||||
Console.WriteLine("Error : ");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_removeAll)
|
||||
{
|
||||
if (this.UserConfirmsDeleteAction("Networks"))
|
||||
{
|
||||
this.RemoveAllNetworks();
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.NetworkId);
|
||||
this.RepositoryFactory.CreateNetworkRepository().DeleteNetwork(id, _force);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Port", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class DeletePortCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _floatingIPId;
|
||||
private SwitchParameter _force = false;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeletePort", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("id")]
|
||||
public string PortId
|
||||
{
|
||||
get { return _floatingIPId; }
|
||||
set { _floatingIPId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeletePort2", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllPorts()
|
||||
{
|
||||
IPortRepository repository = this.RepositoryFactory.CreatePortRepository();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (BaseEntity entity in this.CurrentContainer.Entities)
|
||||
{
|
||||
if (entity.Name != null)
|
||||
Console.WriteLine("Removing Port : " + entity.Name);
|
||||
else
|
||||
Console.WriteLine("Removing Port : " + entity.Id);
|
||||
|
||||
repository.DeletePort(entity.Id);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.PortId);
|
||||
|
||||
if (_force)
|
||||
{
|
||||
if (this.UserConfirmsDeleteAction("Ports"))
|
||||
{
|
||||
this.RemoveAllPorts();
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RepositoryFactory.CreatePortRepository().DeletePort(id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Router", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class DeleteRouterCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _routerId;
|
||||
private SwitchParameter _force = false;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeleteRouter", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("rid")]
|
||||
public string RouterId
|
||||
{
|
||||
get { return _routerId; }
|
||||
set { _routerId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeleteRouter2", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllRouters()
|
||||
{
|
||||
IRouterRepository repository = this.RepositoryFactory.CreateRouterRepository();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (BaseEntity entity in this.CurrentContainer.Entities)
|
||||
{
|
||||
if (entity.Name != null)
|
||||
Console.WriteLine("Removing Router : " + entity.Name);
|
||||
else
|
||||
Console.WriteLine("Removing Router : " + entity.Id);
|
||||
|
||||
repository.DeleteRouter(entity.Id);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.RouterId);
|
||||
|
||||
if (_force)
|
||||
{
|
||||
if (this.UserConfirmsDeleteAction("Routers"))
|
||||
{
|
||||
this.RemoveAllRouters();
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RepositoryFactory.CreateRouterRepository().DeleteRouter(id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "RouterInterface", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class DeleteRouterInterfaceCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _routerId;
|
||||
private string _subnetId;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeleteRouterInterface", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("id")]
|
||||
public string RouterId
|
||||
{
|
||||
get { return _routerId; }
|
||||
set { _routerId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeleteRouterInterface", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("sid")]
|
||||
public string SubnetId
|
||||
{
|
||||
get { return _subnetId; }
|
||||
set { _subnetId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.RepositoryFactory.CreateRouterRepository().DeleteInterfaceByRouter(this.RouterId, this.SubnetId);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Management.Automation;
|
||||
using System.Management.Automation.Host;
|
||||
using System.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Subnet", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class DeleteSubnetCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _subnetId;
|
||||
private SwitchParameter _force = false;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "DeleteSubnet", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("id")]
|
||||
public string SubnetId
|
||||
{
|
||||
get { return _subnetId; }
|
||||
set { _subnetId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "DeleteSubnet2", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("all")]
|
||||
public SwitchParameter RemoveAll
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void RemoveAllSubnets()
|
||||
{
|
||||
ISubnetRepository repository = this.RepositoryFactory.CreateSubnetRepository();
|
||||
Console.WriteLine("");
|
||||
|
||||
foreach (BaseEntity entity in this.CurrentContainer.Entities)
|
||||
{
|
||||
if (entity.Name != null)
|
||||
Console.WriteLine("Removing Subnet : " + entity.Name);
|
||||
else
|
||||
Console.WriteLine("Removing Subnet : " + entity.Id);
|
||||
|
||||
repository.DeleteSubnet(entity.Id);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.SubnetId);
|
||||
|
||||
if (_force && this.UserConfirmsDeleteAction("Subnets"))
|
||||
{
|
||||
this.RemoveAllSubnets();
|
||||
this.UpdateCache();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RepositoryFactory.CreateSubnetRepository().DeleteSubnet(id);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "FloatingIP", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class NewFloatingIPCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _networkId;
|
||||
private string _portId;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewFloatingIP", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("pid")]
|
||||
public string PortId
|
||||
{
|
||||
get { return _portId; }
|
||||
set { _portId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewFloatingIP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The name of the Server.")]
|
||||
[Alias("nid")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewFloatingIP newFloatingIP = new NewFloatingIP();
|
||||
newFloatingIP.FloatingNetworkId = this.NetworkId;
|
||||
newFloatingIP.PortId = this.PortId;
|
||||
|
||||
this.RepositoryFactory.CreateFloatingIPRepository().SaveFloatingIP(newFloatingIP);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("New", "Network", SupportsShouldProcess = true)]
|
||||
public class NewNetworkCmdlet : BasePSCmdlet
|
||||
{
|
||||
private bool _adminStateUp = true;
|
||||
private bool _force = true;
|
||||
private string _name;
|
||||
private string _cidr = "11.0.3.0/24";
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, ParameterSetName = "NewNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("cidr")]
|
||||
public string CidrValue
|
||||
{
|
||||
get { return _cidr; }
|
||||
set { _cidr = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("asu")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter AdminStateUp
|
||||
{
|
||||
get { return _adminStateUp; }
|
||||
set { _adminStateUp = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewNetwork", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("f")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter Force
|
||||
{
|
||||
get { return _force; }
|
||||
set { _force = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//=========================================================================================
|
||||
private void BuilderEvent(object sender, CreateNetworkEventArgs e)
|
||||
{
|
||||
Console.WriteLine("- " + e.Message);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
Console.WriteLine("");
|
||||
NewNetwork newNetwork = new NewNetwork();
|
||||
newNetwork.AdminStateUp = _adminStateUp;
|
||||
newNetwork.Name = _name;
|
||||
|
||||
if (this.CidrValue == null) {
|
||||
newNetwork.Cidr = "11.0.3.0/24";
|
||||
}
|
||||
else{
|
||||
newNetwork.Cidr = this.CidrValue;
|
||||
}
|
||||
|
||||
INetworkRepository repository = this.RepositoryFactory.CreateNetworkRepository();
|
||||
repository.Changed += new Openstack.Objects.DataAccess.Networking.NetworkRepository.CreateNetworkEventHandler(BuilderEvent);
|
||||
repository.SaveNetwork(newNetwork, this.Force);
|
||||
repository.Changed -= new Openstack.Objects.DataAccess.Networking.NetworkRepository.CreateNetworkEventHandler(BuilderEvent);
|
||||
Console.WriteLine(" Network Build Complete!");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("New", "Port", SupportsShouldProcess = true)]
|
||||
public class NewPortCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private SwitchParameter _admin_state_up = true;
|
||||
private string _networkId;
|
||||
private string _deviceId;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewPort", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewPort", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("nid")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, ParameterSetName = "NewPort", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("asu")]
|
||||
|
||||
public SwitchParameter AdminStateUp
|
||||
{
|
||||
get { return _admin_state_up; }
|
||||
set { _admin_state_up = value; }
|
||||
}
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewPort", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("did")]
|
||||
public string DeviceId
|
||||
{
|
||||
get { return _deviceId; }
|
||||
set { _deviceId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewPort newPort = new NewPort();
|
||||
newPort.AdminStateUp = this.AdminStateUp;
|
||||
newPort.DeviceId = this.DeviceId;
|
||||
newPort.Name = this.Name;
|
||||
newPort.NetworkId = this.NetworkId;
|
||||
|
||||
this.RepositoryFactory.CreatePortRepository().SavePort(newPort);
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("New", "Router", SupportsShouldProcess = true)]
|
||||
public class NewRouterCmdlet : BasePSCmdlet
|
||||
{
|
||||
private bool _adminStateUp = true;
|
||||
private string _name;
|
||||
private string _extGatewayNetworkId;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewRouter", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("egw")]
|
||||
public string ExternalGateway
|
||||
{
|
||||
get { return _extGatewayNetworkId; }
|
||||
set { _extGatewayNetworkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewRouter", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewRouter", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("asu")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter AdminStateUp
|
||||
{
|
||||
get { return _adminStateUp; }
|
||||
set { _adminStateUp = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewRouter newRouter = new NewRouter();
|
||||
newRouter.Name = this.Name;
|
||||
newRouter.AdminStateUp = this.AdminStateUp;
|
||||
|
||||
if (this.ExternalGateway != null) {
|
||||
newRouter.ExternalGateway.NetworkId = this.ExternalGateway;
|
||||
}
|
||||
|
||||
this.RepositoryFactory.CreateRouterRepository().SaveRouter(newRouter);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("New", "RouterInterface", SupportsShouldProcess = true)]
|
||||
public class NewRouterInterfaceCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _subnetId;
|
||||
private string _portId;
|
||||
private string _routerId;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewRouterInterface", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("rid")]
|
||||
public string RouterId
|
||||
{
|
||||
get { return _routerId; }
|
||||
set { _routerId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewRouterInterface", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("sid")]
|
||||
public string SubnetId
|
||||
{
|
||||
get { return _subnetId; }
|
||||
set { _subnetId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewRouterInterface", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("pid")]
|
||||
public string PortId
|
||||
{
|
||||
get { return _portId; }
|
||||
set { _portId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewRouterInterface newRouterInterface = new NewRouterInterface();
|
||||
newRouterInterface.PortId = this.PortId;
|
||||
newRouterInterface.SubnetId = this._subnetId;
|
||||
newRouterInterface.RouterId = this.RouterId;
|
||||
|
||||
NewRouterInterface response = this.RepositoryFactory.CreateRouterRepository().SaveRouterInterface(newRouterInterface);
|
||||
if (response.SubnetId != null)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("New Router Interface created for Subnet Id " + response.SubnetId);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
else if (response.PortId != null)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("New Router Interface created for Port Id " + response.PortId);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -1,136 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("New", "Subnet", SupportsShouldProcess = true)]
|
||||
public class NewSubnetCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _networkId;
|
||||
private int _IPVersion;
|
||||
private string _cidr;
|
||||
private string[] _allocationPools;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewSubnet", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("nid")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "NewSubnet", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("ipv")]
|
||||
public int IPVersion
|
||||
{
|
||||
get { return _IPVersion; }
|
||||
set { _IPVersion = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "NewSubnet", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("c")]
|
||||
public string Cidr
|
||||
{
|
||||
get { return _cidr; }
|
||||
set { _cidr = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, Mandatory = false, ParameterSetName = "NewSubnet", ValueFromPipelineByPropertyName = true, HelpMessage = "Valid values include")]
|
||||
[Alias("a")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] AllocationPools
|
||||
{
|
||||
get { return _allocationPools; }
|
||||
set { _allocationPools = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewSubnet newSubnet = new NewSubnet();
|
||||
//newSubnet.AllocationPools = this.FormatAllocationPools();
|
||||
newSubnet.Cidr = this.Cidr;
|
||||
newSubnet.IPversion = this.IPVersion;
|
||||
newSubnet.NetworkId = this.NetworkId;
|
||||
|
||||
Subnet subnet = this.RepositoryFactory.CreateSubnetRepository().SaveSubnet(newSubnet);
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("New Subnet " + subnet.Id + " created.");
|
||||
Console.WriteLine("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="keyValuePairs"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
public List<AllocationPool> FormatAllocationPools()
|
||||
{
|
||||
if (_allocationPools != null)
|
||||
{
|
||||
List<AllocationPool> allocationPools = new List<AllocationPool>();
|
||||
char[] seperator = { '|' };
|
||||
|
||||
foreach (string ap in _allocationPools)
|
||||
{
|
||||
string[] temp = ap.Split(seperator);
|
||||
AllocationPool allocationPool = new AllocationPool();
|
||||
allocationPool.Start = temp[0];
|
||||
allocationPool.End = temp[1];
|
||||
|
||||
allocationPools.Add(allocationPool);
|
||||
}
|
||||
return allocationPools;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Objects.DataAccess.Networking;
|
||||
using Openstack.Client.Powershell.Providers.Compute;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Compute.Security
|
||||
{
|
||||
[Cmdlet("UnAssign", "IP", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class UnAssignIPCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _serverId;
|
||||
private string _ip;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("ip")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string IpAddress
|
||||
{
|
||||
get { return _ip; }
|
||||
set { _ip = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("sid")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ServerId
|
||||
{
|
||||
get { return _serverId; }
|
||||
set { _serverId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
IFloatingIPRepository repository = new FloatingIPRepository(this.Context.GetRepositoryContext("compute"));
|
||||
UnAssignIPAction assignment = new UnAssignIPAction();
|
||||
assignment.ServerId = this.ServerId;
|
||||
assignment.Ip = this.IpAddress;
|
||||
|
||||
repository.UnAssignIP(assignment);
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Floating IP Address " + this.IpAddress + " has been disassociated with Server : " + assignment.ServerId);
|
||||
Console.WriteLine("");
|
||||
this.UpdateCache<ServerUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Update", "FloatingIP", SupportsShouldProcess = true)]
|
||||
//[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class UpdateFloatingIPCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _portId;
|
||||
private string _floatingIPId;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdateFloatingIP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("fid")]
|
||||
public string FloatingIPId
|
||||
{
|
||||
get { return _floatingIPId; }
|
||||
set { _floatingIPId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdateFloatingIP", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("pid")]
|
||||
public string PortId
|
||||
{
|
||||
get { return _portId; }
|
||||
set { _portId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
UpdateFloatingIP updateIP = new UpdateFloatingIP();
|
||||
updateIP.PortId = this.PortId;
|
||||
|
||||
this.RepositoryFactory.CreateFloatingIPRepository().UpdateFloatingIP(this.FloatingIPId, updateIP);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Update", "Network", SupportsShouldProcess = true)]
|
||||
public class UpdateNetworkCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _networkId;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdateNetwork", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("id")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdateNetwork", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.NetworkId);
|
||||
UpdateNetwork updateNetwork = new UpdateNetwork();
|
||||
updateNetwork.Name = this.Name;
|
||||
|
||||
this.RepositoryFactory.CreateNetworkRepository().UpdateNetwork(id, updateNetwork);
|
||||
this.UpdateCache();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Update", "Port", SupportsShouldProcess = true)]
|
||||
public class UpdatePortCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _deviceId;
|
||||
private string _portId;
|
||||
|
||||
#region Properties
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdatePort", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("id")]
|
||||
public string PortId
|
||||
{
|
||||
get { return _portId; }
|
||||
set { _portId = value; }
|
||||
}
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdatePort", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("did")]
|
||||
public string DeviceId
|
||||
{
|
||||
get { return _deviceId; }
|
||||
set { _deviceId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
UpdatePort updatePort = new UpdatePort();
|
||||
updatePort.DeviceId = this.DeviceId;
|
||||
|
||||
this.RepositoryFactory.CreatePortRepository().UpdatePort(this.PortId, updatePort);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Update", "Router", SupportsShouldProcess = true)]
|
||||
public class UpdateRouterCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _networkId;
|
||||
private string _routerId;
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdateRouter", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("id")]
|
||||
public string RouterId
|
||||
{
|
||||
get { return _routerId; }
|
||||
set { _routerId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdateRouter", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("nid")]
|
||||
public string NetworkId
|
||||
{
|
||||
get { return _networkId; }
|
||||
set { _networkId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
string id = this.TranslateQuickPickNumber(this.RouterId);
|
||||
UpdateRouter updateRouter = new UpdateRouter();
|
||||
//updateRouter.ExternalGatewayInfo.NetworkId = this.NetworkId;
|
||||
|
||||
this.RepositoryFactory.CreateRouterRepository().UpdateRouter(id, updateRouter);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,83 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Text;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Networking;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Networking
|
||||
{
|
||||
[Cmdlet("Update", "Subnet", SupportsShouldProcess = true)]
|
||||
public class UpdateSubnetCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _gatewayIP;
|
||||
private string _name;
|
||||
private string _subnetId;
|
||||
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "UpdateSubnet", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("id")]
|
||||
public string SubnetId
|
||||
{
|
||||
get { return _subnetId; }
|
||||
set { _subnetId = value; }
|
||||
}
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "UpdateSubnet", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("egw")]
|
||||
public string GatewayId
|
||||
{
|
||||
get { return _gatewayIP; }
|
||||
set { _gatewayIP = value; }
|
||||
}
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "UpdateSubnet", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The Id of the Server.")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//============================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//============================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
UpdateSubnet updateSubnet = new UpdateSubnet();
|
||||
updateSubnet.Name = this.Name;
|
||||
updateSubnet.GatewayIP = this.GatewayId;
|
||||
|
||||
this.RepositoryFactory.CreateSubnetRepository().UpdateSubnet(_subnetId, updateSubnet);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
Volume in drive C has no label.
|
||||
Volume Serial Number is EE3F-CECC
|
||||
|
||||
Directory of C:\Projects\HPCloud\CLI\HPCloud.Client.Powershell\Cmdlets\Networking
|
||||
|
||||
08/23/2013 02:45 PM <DIR> .
|
||||
08/23/2013 02:45 PM <DIR> ..
|
||||
07/19/2013 04:04 PM 1,386 AllocateIPCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,351 AssignIPCmdlet.cs
|
||||
07/19/2013 04:04 PM 2,484 DeallocateIPCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,871 DeleteFloatingIPCmdlet.cs
|
||||
08/13/2013 11:01 AM 6,478 DeleteNetworkCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,771 DeletePortCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,786 DeleteRouterCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,491 DeleteRouterInterfaceCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,745 DeleteSubnetCmdlet.cs
|
||||
08/23/2013 02:45 PM 0 newclasses
|
||||
07/30/2013 08:06 PM 3,607 NewFloatingIPCmdlet.cs
|
||||
07/30/2013 08:06 PM 5,864 NewNetworkCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,717 NewPortCmdlet.cs
|
||||
08/10/2013 07:02 PM 4,297 NewRouterCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,797 NewRouterInterfaceCmdlet.cs
|
||||
07/30/2013 08:06 PM 6,609 NewSubnetCmdlet.cs
|
||||
07/30/2013 08:06 PM 4,043 UnAssignIPCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,507 UpdateFloatingIPCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,486 UpdateNetworkCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,370 UpdatePortCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,512 UpdateRouterCmdlet.cs
|
||||
07/30/2013 08:06 PM 3,879 UpdateSubnetCmdlet.cs
|
||||
22 File(s) 89,051 bytes
|
||||
2 Dir(s) 6,555,230,208 bytes free
|
@ -1,54 +0,0 @@
|
||||
/* ============================================================================
|
||||
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 Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System.Management.Automation;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Storage.CDN
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Get, "CDN", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.CDN)]
|
||||
public class GetCDNCmdlet : BasePSCmdlet
|
||||
{
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The main driver..
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
List<StorageContainer> containers = this.RepositoryFactory.CreateCDNRepository().GetContainers();
|
||||
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("The following Storage Containers are CDN enabled");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("==============================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("");
|
||||
|
||||
|
||||
this.WriteObject(containers);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using System.IO;
|
||||
using Openstack.Client.Powershell.Providers.Storage;
|
||||
using System.Diagnostics;
|
||||
using Openstack.Common;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Storage.CDN
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "CDN", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.CDN)]
|
||||
public class NewCDNCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _containerName;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, Mandatory = true, ParameterSetName = "EnableCDN", ValueFromPipelineByPropertyName = true, HelpMessage = "The Name of the Container to enable for CDN access.")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ContainerName
|
||||
{
|
||||
get { return _containerName; }
|
||||
set { _containerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The main driver..
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
List<StorageContainer> containers = this.RepositoryFactory.CreateContainerRepository().GetStorageContainers();
|
||||
if (!containers.Any(c => c.Name == this.ContainerName))
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine ("Storage Container not found. Please specify an existing Storage Container name to pair with this CDN entry.");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
}
|
||||
else
|
||||
{
|
||||
string url = this.RepositoryFactory.CreateCDNRepository().SaveContainer(this.ContainerName);
|
||||
if (url != null)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("================================================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("CDN entry created successfully. The URL below can be combined with object names to serve objects through the CDN.");
|
||||
Console.ForegroundColor = ConsoleColor.DarkGray;
|
||||
Console.WriteLine("================================================================================================================");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine(url);
|
||||
Console.WriteLine("");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,62 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using System.IO;
|
||||
using Openstack.Client.Powershell.Providers.Storage;
|
||||
using System.Diagnostics;
|
||||
using Openstack.Common;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Storage.CDN
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "CDN", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.CDN)]
|
||||
public class RemoveCDNCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _containerName;
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Mandatory = true, ParameterSetName = "EnableCDN", ValueFromPipelineByPropertyName = true, HelpMessage = "The Name of the Container to enable for CDN access.")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ContainerName
|
||||
{
|
||||
get { return _containerName; }
|
||||
set { _containerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The main driver..
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().DeleteContainer(this.ContainerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,265 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.DataAccess.Storage;
|
||||
using Openstack.Migrations;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Storage;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Containers
|
||||
{
|
||||
[Cmdlet("Migrate", "Drive", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class MigrateDriveCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _accessKeyID;
|
||||
private string _secretAccessKeyID;
|
||||
private long _bytesCopied = 0;
|
||||
private int _filesCopied = 0;
|
||||
private long _totalBytesCopied = 0;
|
||||
private int _totalFilesCopied = 0;
|
||||
private string[] _buckets;
|
||||
private string _provider;
|
||||
|
||||
#region Parameters
|
||||
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "localStore", Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = " ")]
|
||||
[ValidateSet("Skydrive", "Dropbox", "S3")]
|
||||
[Alias("p")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Provider
|
||||
{
|
||||
get { return _provider; }
|
||||
set { _provider = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, Mandatory = false, ParameterSetName = "localStore", ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("ak")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string AccessKeyId
|
||||
{
|
||||
get { return _accessKeyID; }
|
||||
set { _accessKeyID = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, ParameterSetName = "localStore", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("sk")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SecretAccessKeyId
|
||||
{
|
||||
get { return _secretAccessKeyID; }
|
||||
set { _secretAccessKeyID = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "localStore", ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("b")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] Buckets
|
||||
{
|
||||
get { return _buckets; }
|
||||
set { _buckets = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void PrintTotals()
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Operation Summary");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Total Files Copied : " + Convert.ToString(_totalFilesCopied));
|
||||
Console.WriteLine("Total Bytes Copied : " + Convert.ToString(_totalBytesCopied));
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void MigrateS3Drive()
|
||||
{
|
||||
//AWSMigration migration = new AWSMigration("AKIAJ6SAONGOGCUKSONA", "0Hi00F7zlFwGi8a45qRhGfW2Btf+FAioZhfD+99K");
|
||||
AWSMigration migration = new AWSMigration(_accessKeyID, _secretAccessKeyID);
|
||||
if (_buckets == null) _buckets = migration.GetBuckets();
|
||||
|
||||
migration.Changed += new Openstack.Migrations.AWSMigration.CopyOperationEventHandler(ListChanged);
|
||||
migration.ContainerCreated += new Openstack.Migrations.AWSMigration.CreateContainerOperationEventHandler(OnCreateContainer);
|
||||
|
||||
Console.WriteLine("");
|
||||
foreach (string bucketName in _buckets)
|
||||
{
|
||||
_bytesCopied = 0;
|
||||
_filesCopied = 0;
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Processing Bucket : " + bucketName);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
migration.MigrateBucket(bucketName);
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Files Copied : " + Convert.ToString(_filesCopied));
|
||||
Console.WriteLine("Bytes Copied : " + Convert.ToString(_bytesCopied));
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("");
|
||||
}
|
||||
|
||||
this.PrintTotals();
|
||||
migration.Changed -= new Openstack.Migrations.AWSMigration.CopyOperationEventHandler(ListChanged);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void MigrateLocalDrive()
|
||||
{
|
||||
LocalStoreMigration migration = new LocalStoreMigration();
|
||||
|
||||
migration.Changed += new Openstack.Migrations.LocalStoreMigration.CopyOperationEventHandler(ListChanged);
|
||||
Console.WriteLine("");
|
||||
|
||||
_bytesCopied = 0;
|
||||
_filesCopied = 0;
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.WriteLine("Migrating local " + _provider + " store.");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
Console.WriteLine("--------------------------------------");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
|
||||
if (_provider == "Dropbox")
|
||||
migration.MigrateLocalStore(StorageProvider.DropBox);
|
||||
else
|
||||
migration.MigrateLocalStore(StorageProvider.SkyDrive);
|
||||
|
||||
this.PrintTotals();
|
||||
migration.Changed -= new Openstack.Migrations.LocalStoreMigration.CopyOperationEventHandler(ListChanged);
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//=========================================================================================
|
||||
private void OnCreateContainer(object sender, CreateContainerOperationInfoEventArgs e)
|
||||
{
|
||||
PSDriveInfo psDriveInfo = new PSDriveInfo(e.ContainerName, this.Drive.Provider, "/", "", null);
|
||||
OSDriveParameters driveParameters = new OSDriveParameters();
|
||||
driveParameters.Settings = this.Settings;
|
||||
try
|
||||
{
|
||||
this.SessionState.Drive.New(new OSDriveInfo(psDriveInfo, driveParameters, this.Context), "local");
|
||||
}
|
||||
catch (SessionStateException ex) { }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
//=========================================================================================
|
||||
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>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (_provider == "S3")
|
||||
{
|
||||
if (_accessKeyID == null || _secretAccessKeyID == null)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("Please supply both Secret key and Access key parameters to migrate your S3 Buckets.");
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
this.MigrateS3Drive();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MigrateS3Drive();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.MigrateLocalDrive();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,306 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Client.Powershell.Providers.Storage;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Management.Automation.Host;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using System;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Xml.Linq;
|
||||
using System.IO;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Containers
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "Container", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class NewContainerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _sharedContainerURL = null;
|
||||
private bool _forceSave = false;
|
||||
private bool _createCDN = false;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "SaveSharedStorageContainer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("url")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SharedContainerURL
|
||||
{
|
||||
get { return _sharedContainerURL; }
|
||||
set { _sharedContainerURL = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "SavestorageContainer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "SavestorageContainer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("cdn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter CreateCDN
|
||||
{
|
||||
get { return _createCDN; }
|
||||
set { _createCDN = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, ParameterSetName = "SavestorageContainer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("f")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter Force
|
||||
{
|
||||
get { return _forceSave; }
|
||||
set { _forceSave = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void CreateStorageContainer(StorageContainer storageContainer)
|
||||
{
|
||||
IContainerRepository repository = this.RepositoryFactory.CreateContainerRepository();
|
||||
bool skipAdd = false;
|
||||
|
||||
// These should be transacted somehow..
|
||||
|
||||
repository.SaveContainer(storageContainer);
|
||||
|
||||
Collection<PSDriveInfo> drives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
|
||||
foreach (PSDriveInfo drive in drives)
|
||||
{
|
||||
if (drive.Name == storageContainer.Name)
|
||||
{
|
||||
skipAdd = true;
|
||||
}
|
||||
}
|
||||
if (!skipAdd)
|
||||
{
|
||||
PSDriveInfo psDriveInfo = new PSDriveInfo(storageContainer.Name, this.GetStorageProvider(drives), "/", "", null);
|
||||
OSDriveParameters driveParameters = new OSDriveParameters();
|
||||
driveParameters.Settings = this.Settings;
|
||||
|
||||
this.SessionState.Drive.New(new OSDriveInfo(psDriveInfo, driveParameters, this.Context), "local");
|
||||
}
|
||||
|
||||
this.WriteObject(" ");
|
||||
this.WriteObject("Storage Container " + _name + " created successfully.");
|
||||
this.WriteObject(" ");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private bool IsDuplicateContainer(string container)
|
||||
{
|
||||
List<StorageContainer> containers = this.RepositoryFactory.CreateContainerRepository().GetStorageContainers();
|
||||
return containers.Where(cn => cn.Name == container).Any();
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void SaveNewContainer()
|
||||
{
|
||||
StorageContainer storageContainer = new StorageContainer();
|
||||
storageContainer.Name = _name;
|
||||
|
||||
if (IsDuplicateContainer(this.Name))
|
||||
{
|
||||
this.WriteObject(" ");
|
||||
Console.ForegroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), this.Context.Forecolor);
|
||||
Console.WriteLine("Storage Container " + _name + " already exist.");
|
||||
Console.WriteLine("");
|
||||
return;
|
||||
}
|
||||
|
||||
if (storageContainer.ValidateBasicRequirements() == false)
|
||||
{
|
||||
this.WriteObject(" ");
|
||||
this.WriteObject("Storage Container " + _name + " has failed basic validation rules. Please ensure that the name doesn't include a forward slash, single or double quote character and is less than 255 characters in length.");
|
||||
return;
|
||||
}
|
||||
else if (storageContainer.ValidateExtendedRequirements() == false)
|
||||
{
|
||||
|
||||
// Check to see if the Container already exist.. Or not maybe it does z
|
||||
|
||||
if (_forceSave)
|
||||
{
|
||||
this.CreateStorageContainer(storageContainer);
|
||||
if (_createCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().SaveContainer(_name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||
choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
if (this.Host.UI.PromptForChoice("Confirm Action", "Specified Storage Container name is not a valid virtalhost name, continue anyway?", choices, 0) == 0)
|
||||
{
|
||||
this.CreateStorageContainer(storageContainer);
|
||||
if (_createCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().SaveContainer(_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CreateStorageContainer(storageContainer);
|
||||
if (_createCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().SaveContainer(_name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void CreateSharedDrive(string drivePath)
|
||||
{
|
||||
string driveName = Path.GetFileName(drivePath);
|
||||
Collection<PSDriveInfo> drives = this.SessionState.Drive.GetAllForProvider("OS-Storage");
|
||||
PSDriveInfo psDriveInfo = new PSDriveInfo(driveName, this.GetStorageProvider(drives), "/", "", null);
|
||||
OSDriveParameters driveParameters = new OSDriveParameters();
|
||||
driveParameters.Settings = this.Settings;
|
||||
OSDriveInfo newDrive = new OSDriveInfo(psDriveInfo, driveParameters, this.Context);
|
||||
newDrive.SharePath = drivePath;
|
||||
|
||||
this.SessionState.Drive.New(newDrive, "local");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void SaveSharedContainer()
|
||||
{
|
||||
if (this.IsUrlValid(this.SharedContainerURL))
|
||||
{
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
XDocument doc = XDocument.Load(configFilePath);
|
||||
XElement newDrive = new XElement("SharedContainer");
|
||||
newDrive.Add(new XAttribute("url", this.SharedContainerURL));
|
||||
|
||||
doc.Element("configuration").Element("appSettings").Element("StorageManagement").Element("SharedContainers").Add(newDrive);
|
||||
doc.Save(configFilePath);
|
||||
this.CreateSharedDrive(this.SharedContainerURL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Invalid URL supplied");
|
||||
}
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private ProviderInfo GetStorageProvider(Collection<PSDriveInfo> drives)
|
||||
{
|
||||
foreach (PSDriveInfo drive in drives)
|
||||
{
|
||||
if (drive.Provider.Name == "OS-Storage")
|
||||
{
|
||||
return drive.Provider;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="smtpHost"></param>
|
||||
/// <returns></returns>
|
||||
//=========================================================================================
|
||||
private bool IsUrlValid(string smtpHost)
|
||||
{
|
||||
return true;
|
||||
bool br = false;
|
||||
try
|
||||
{
|
||||
IPHostEntry ipHost = Dns.GetHostEntry(smtpHost);
|
||||
br = true;
|
||||
}
|
||||
catch (SocketException se)
|
||||
{
|
||||
br = false;
|
||||
}
|
||||
return br;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// qqqqqqqqqqq
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (_sharedContainerURL != null)
|
||||
{
|
||||
this.SaveSharedContainer();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SaveNewContainer();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,274 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Management.Automation.Host;
|
||||
using Openstack.Common.Properties;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.XPath;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Containers
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Container", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class RemoveContainerCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private SwitchParameter _forceDelete = false;
|
||||
private SwitchParameter _reset = false;
|
||||
private bool _removeCDN = false;
|
||||
|
||||
#region Properties
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "RemoveContainer", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("cdn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter RemoveCDN
|
||||
{
|
||||
get { return _removeCDN; }
|
||||
set { _removeCDN = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "RemoveContainer", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
[Alias("n")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "RemoveContainer", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
||||
[Alias("fd")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public SwitchParameter ForceDelete
|
||||
{
|
||||
get { return _forceDelete; }
|
||||
set { _forceDelete = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//======================================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the Container to trash</param>
|
||||
//======================================================================================================================
|
||||
private bool DeleteContainerContents(StorageContainer storageContainer)
|
||||
{
|
||||
List<StorageObject> containerItems = null;
|
||||
IStorageObjectRepository repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
||||
|
||||
try
|
||||
{
|
||||
containerItems = repository.GetStorageObjects(storageContainer.Name, true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Define our Action delegate which will delete the element in the list..
|
||||
|
||||
if (containerItems != null)
|
||||
{
|
||||
Action<StorageObject> deleteStorageObjectAction = delegate(StorageObject storageObject)
|
||||
{
|
||||
StoragePath targetPath = this.CreateStoragePath(storageObject.Key);
|
||||
repository.DeleteStorageObject(targetPath.AbsoluteURI);
|
||||
};
|
||||
|
||||
// Remove all Files contained within the storageContainer...
|
||||
|
||||
if (containerItems != null)
|
||||
{
|
||||
containerItems.ForEach(deleteStorageObjectAction);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void DeleteAllContainers()
|
||||
{
|
||||
IContainerRepository repository = this.RepositoryFactory.CreateContainerRepository();
|
||||
List<StorageContainer> containers = repository.GetStorageContainers();
|
||||
|
||||
foreach (StorageContainer container in containers)
|
||||
{
|
||||
try
|
||||
{
|
||||
// repository.DeleteContainer(container);
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
}
|
||||
//======================================================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="address"></param>
|
||||
/// <returns></returns>
|
||||
//======================================================================================================================
|
||||
private string GetContainerName(string url)
|
||||
{
|
||||
string[] elements = url.Split('/');
|
||||
return elements[elements.Length - 1];
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private bool RemoveSharedContainer()
|
||||
{
|
||||
bool entryRemoved = false;
|
||||
List<StorageContainer> results = new List<StorageContainer>();
|
||||
string configFilePath = this.ConfigFilePath;
|
||||
XDocument doc = XDocument.Load(configFilePath);
|
||||
IEnumerable<XElement> containers = doc.XPathSelectElements("//SharedContainer");
|
||||
|
||||
foreach (XElement element in containers)
|
||||
{
|
||||
string sharedPath = (string)element.Attribute("url");
|
||||
if (this.GetContainerName(sharedPath) == this.Name)
|
||||
{
|
||||
element.Remove();
|
||||
entryRemoved = true;
|
||||
}
|
||||
}
|
||||
doc.Save(configFilePath);
|
||||
this.SessionState.Drive.Remove(this.Name, true, "local");
|
||||
if (this.Name == this.SessionState.Drive.Current.Name)
|
||||
this.SessionState.InvokeCommand.InvokeScript("cd c:");
|
||||
|
||||
return entryRemoved;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
if (RemoveSharedContainer() == true) return;
|
||||
|
||||
Collection<ChoiceDescription> choices = new Collection<ChoiceDescription>();
|
||||
choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
if (_forceDelete == false)
|
||||
{
|
||||
if (this.Host.UI.PromptForChoice("Confirm Action", "You are about to delete an entire Container. Are you sure about this?", choices, 0) == 0)
|
||||
{
|
||||
IContainerRepository repository = this.RepositoryFactory.CreateContainerRepository();
|
||||
StorageContainer storageContainer = new StorageContainer();
|
||||
storageContainer.Name = _name;
|
||||
|
||||
try
|
||||
{
|
||||
repository.DeleteContainer(storageContainer);
|
||||
if (_removeCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().DeleteContainer(_name);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// The container has content and the operation is in conflict. Destroy all contents then retry (the User knows what's up).
|
||||
|
||||
if (ex.Message == "Unknown Repository Error")
|
||||
{
|
||||
if (DeleteContainerContents(storageContainer))
|
||||
{
|
||||
repository.DeleteContainer(storageContainer);
|
||||
if (_removeCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().DeleteContainer(_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
this.SessionState.Drive.Remove(storageContainer.Name, true, "local");
|
||||
if (storageContainer.Name == this.SessionState.Drive.Current.Name)
|
||||
this.SessionState.InvokeCommand.InvokeScript("cd c:");
|
||||
}
|
||||
catch (DriveNotFoundException ex) { }
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IContainerRepository repository = this.RepositoryFactory.CreateContainerRepository();
|
||||
StorageContainer storageContainer = new StorageContainer();
|
||||
storageContainer.Name = _name;
|
||||
|
||||
try
|
||||
{
|
||||
repository.DeleteContainer(storageContainer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// The container has content and the operation is in conflict. Destroy all contents then retry (the User knows what's up).
|
||||
|
||||
if (ex.Message == "Unknown Repository Error")
|
||||
{
|
||||
if (DeleteContainerContents(storageContainer))
|
||||
{
|
||||
repository.DeleteContainer(storageContainer);
|
||||
if (_removeCDN)
|
||||
{
|
||||
this.RepositoryFactory.CreateCDNRepository().DeleteContainer(_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System;
|
||||
using System.Management.Automation;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.DataAccess;
|
||||
using Openstack.Objects.Domain;
|
||||
using System.IO;
|
||||
using Openstack.Client.Powershell.Providers.Storage;
|
||||
using Openstack.Common;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Objects.Domain.Storage;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Containers
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Set, "Scope", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
public class SetScopeCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _containerName;
|
||||
private ContainerScope _scope;
|
||||
private string _permission;
|
||||
private string[] _users;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The Container name.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "scp1", Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = @"The Container name.")]
|
||||
[Alias("cn")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string ContainerName
|
||||
{
|
||||
get { return _containerName; }
|
||||
set { _containerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The Container name.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "scp2", Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = @"The Container name.")]
|
||||
[Alias("c")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Name
|
||||
{
|
||||
get { return _containerName; }
|
||||
set { _containerName = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "scp2", Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The Containers Scope.")]
|
||||
[ValidateSet("Public", "Private")]
|
||||
[Alias("s")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public ContainerScope Scope
|
||||
{
|
||||
get { return _scope; }
|
||||
set { _scope = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "scp1", Position = 2, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "c")]
|
||||
[Alias("u")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string[] Users
|
||||
{
|
||||
get { return _users; }
|
||||
set { _users = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// The location of the file to set permissions on.
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(ParameterSetName = "scp1", Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "v")]
|
||||
[ValidateSet("Read", "Write", "ReadWrite")]
|
||||
[Alias("p")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Permission
|
||||
{
|
||||
get { return _permission; }
|
||||
set { _permission = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="permission"></param>
|
||||
/// <returns></returns>
|
||||
//========================================================================================
|
||||
private ContainerPermissions GetPermission(string permission)
|
||||
{
|
||||
switch (permission)
|
||||
{
|
||||
case ("Read") :
|
||||
return ContainerPermissions.PublicRead;
|
||||
|
||||
case ("ReadWrite"):
|
||||
return ContainerPermissions.PublicReadWrite;
|
||||
|
||||
case ("Write"):
|
||||
return ContainerPermissions.PublicWrite;
|
||||
|
||||
default :
|
||||
return ContainerPermissions.PublicRead;
|
||||
}
|
||||
}
|
||||
//========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="users"></param>
|
||||
/// <returns></returns>
|
||||
//========================================================================================
|
||||
private List<string> GetUsers(string[] users)
|
||||
{
|
||||
List<string> userList = new List<string>();
|
||||
foreach (string user in users) {
|
||||
userList.Add("*:" + user);
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
private void ShowUrl()
|
||||
{
|
||||
StoragePath path = this.CreateStoragePath(String.Empty);
|
||||
path.Volume = _containerName;
|
||||
string uri = path.AbsoluteURI.Remove(path.AbsoluteURI.LastIndexOf('/'));
|
||||
|
||||
if (this.Settings.PasteGetURIResultsToClipboard)
|
||||
OutClipboard.SetText(uri);
|
||||
|
||||
WriteObject("");
|
||||
WriteObject("Shared Container located at : " + uri);
|
||||
WriteObject("");
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
IContainerRepository repository = this.RepositoryFactory.CreateContainerRepository();
|
||||
|
||||
if (this.ParameterSetName == "scp2")
|
||||
{
|
||||
repository.SetScope(_containerName, _scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContainerACL acl = new ContainerACL();
|
||||
acl.Permission = this.GetPermission(_permission);
|
||||
acl.Users = this.GetUsers(_users);
|
||||
repository.SetScope(_containerName, acl);
|
||||
this.ShowUrl();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,291 +0,0 @@
|
||||
///* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
//using System.Management.Automation;
|
||||
//using OpenStack;
|
||||
//using OpenStack.Client.Powershell.Providers.Storage;
|
||||
//using System;
|
||||
//using OpenStack.Client.Powershell.Providers.Common;
|
||||
//using System.IO;
|
||||
//using OpenStack.Client.Powershell.Utility;
|
||||
//using OpenStack.Storage;
|
||||
//using System.Net.Http;
|
||||
|
||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
//{
|
||||
// [Cmdlet(VerbsCommon.Copy, "Item", SupportsShouldProcess = true)]
|
||||
// //[RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
// public class CopyItemCmdlet : BasePSCmdlet
|
||||
// {
|
||||
// public const string cDelimiter = "/";
|
||||
// const string cFolderMarker = "folder.txt";
|
||||
// private string _sourcePath;
|
||||
// private string _targetPath;
|
||||
// private SwitchParameter _recursive;
|
||||
// private long _bytesCopied = 0;
|
||||
// private int _filesCopied = 0;
|
||||
// private long _totalBytesCopied = 0;
|
||||
// private int _totalFilesCopied = 0;
|
||||
|
||||
// #region Ctors
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// public CopyItemCmdlet()
|
||||
// { }
|
||||
// #endregion
|
||||
// #region Parameters
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Mandatory = false, ParameterSetName = "aa", ValueFromPipelineByPropertyName = true, HelpMessage = "oih")]
|
||||
// [Alias("recurse")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public SwitchParameter Recursive
|
||||
// {
|
||||
// get { return _recursive; }
|
||||
// set { _recursive = value; }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// The location of the file to copy.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 1, Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = "aa", ValueFromPipeline = true, HelpMessage = "Help Text")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public string SourcePath
|
||||
// {
|
||||
// get { return _sourcePath; }
|
||||
// set { _sourcePath = value; }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// The destination of the file to copy.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 2, Mandatory = false, ValueFromPipeline = true, ParameterSetName = "aa", ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public string TargetPath
|
||||
// {
|
||||
// get { return _targetPath; }
|
||||
// set
|
||||
// {
|
||||
// if (value.StartsWith(@"/") || value.StartsWith(@"\"))
|
||||
// {
|
||||
// _targetPath = value.Substring(1, _targetPath.Length - 1);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _targetPath = value;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// #region Properties
|
||||
////==================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////==================================================================================================
|
||||
// private string StorageServiceURL
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// if (((ObjectStoragePSDriveInfo)this.Drive).SharePath == null)
|
||||
// return this.Context.ServiceCatalog.GetPublicEndpoint("Object Storage", String.Empty);
|
||||
// else
|
||||
// //return ((OSDriveInfo)this.Drive).SharePath;
|
||||
// return ((ObjectStoragePSDriveInfo)this.Drive).SharePath.Replace(this.Drive.Name, string.Empty);
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// #region Methods
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// private void PrintTotals()
|
||||
// {
|
||||
// Console.ForegroundColor = ConsoleColor.Gray;
|
||||
// Console.WriteLine("");
|
||||
// Console.WriteLine("--------------------------------------");
|
||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
// Console.WriteLine("Operation Summary");
|
||||
// Console.ForegroundColor = ConsoleColor.Gray;
|
||||
// Console.WriteLine("--------------------------------------");
|
||||
// Console.WriteLine("");
|
||||
// Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
// Console.WriteLine("Total Files Copied : " + Convert.ToString(_totalFilesCopied));
|
||||
// Console.WriteLine("Total Bytes Copied : " + Convert.ToString(_totalBytesCopied));
|
||||
// Console.WriteLine("");
|
||||
// Console.ForegroundColor = ConsoleColor.Green;
|
||||
|
||||
// }
|
||||
////=================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param ---name="path"></param>
|
||||
///// <returns></returns>
|
||||
////=================================================================================================
|
||||
// private bool IsFolderPath(string path)
|
||||
// {
|
||||
// if (path.EndsWith(@"\") || path.EndsWith("/"))
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
////=================================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="sourcePath"></param>
|
||||
///// <param name="targetPath"></param>
|
||||
///// <returns></returns>
|
||||
////=================================================================================================
|
||||
// private StoragePath CreateValidTargetPath(StoragePath sourcePath, string targetPath)
|
||||
// {
|
||||
// if (targetPath == null && sourcePath != null)
|
||||
// {
|
||||
// // The user has supplied a source but no target at all (we should use the current folder)
|
||||
|
||||
// return new StoragePath(this.StorageServiceURL + cDelimiter + this.Drive.Name + cDelimiter + this.Drive.CurrentLocation + cDelimiter + sourcePath.FileName);
|
||||
// }
|
||||
// else if (System.IO.Path.GetFileName(targetPath) == "" && this.IsFolderPath(targetPath) == true)
|
||||
// {
|
||||
// // The user supplied a target path but no filename (we will use the Source filename)
|
||||
|
||||
// return this.CreateStoragePath(targetPath + sourcePath.FileName);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // The user has supplied a target path and target filename so create the StoragePath against that...
|
||||
|
||||
// return this.CreateStoragePath(targetPath);
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <param name="sender"></param>
|
||||
///// <param name="e"></param>
|
||||
////=========================================================================================
|
||||
// //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 (!path.Volume.EndsWith(@"\") && !path.Path.StartsWith(@"\"))
|
||||
// {
|
||||
// return new FileStream(path.Volume + @"\" + path.Path, FileMode.Open);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return new FileStream(path.Volume + path.Path, FileMode.Open);
|
||||
// }
|
||||
// }
|
||||
////=================================================================================================
|
||||
///// <summary>
|
||||
///// Direct the operation based on the types of paths supplied for both target and source locations.
|
||||
///// </summary>
|
||||
////=================================================================================================
|
||||
// private void ProcessNonQueuedCopy()
|
||||
// {
|
||||
// StoragePath sourcePath = this.CreateStoragePath(this.SourcePath);
|
||||
// StoragePath targetPath = this.CreateValidTargetPath(sourcePath, this.TargetPath);
|
||||
// IStorageServiceClient service = this.CoreClient.CreateServiceClient<IStorageServiceClient>();
|
||||
// string containerName = Path.GetFileNameWithoutExtension(this.SourcePath);
|
||||
|
||||
|
||||
// if (sourcePath.PathType == PathType.Local && targetPath.PathType == PathType.Remote) {
|
||||
// service.CreateStorageObject(containerName, targetPath.ResourcePath, null, this.GetFileStream(sourcePath));
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// //StoragePath sourcePath = this.CreateStoragePath(this.SourcePath);
|
||||
// //StoragePath targetPath = this.CreateValidTargetPath(sourcePath, this.TargetPath);
|
||||
// //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>
|
||||
///// The main driver..
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected override void ProcessRecord()
|
||||
// {
|
||||
// ObjectStoragePSDriveInfo drive = this.SessionState.Drive.Current as ObjectStoragePSDriveInfo;
|
||||
// this.ProcessNonQueuedCopy();
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
@ -1,194 +0,0 @@
|
||||
///* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
//using System;
|
||||
//using System.Management.Automation;
|
||||
//using OpenStack.Client.Powershell.Providers.Common;
|
||||
//using System.Security.Cryptography;
|
||||
//using System.Text;
|
||||
//using System.Web;
|
||||
//using OpenStack.Objects.Domain;
|
||||
|
||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
//{
|
||||
// [Cmdlet(VerbsCommon.Get, "URI", SupportsShouldProcess = true)]
|
||||
// [RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
// public class GetURICmdlet : BasePSCmdlet
|
||||
// {
|
||||
// private string _sourcePath;
|
||||
// private int _daysValid = 0;
|
||||
// private int _secondsValid = 0;
|
||||
|
||||
// #region Parameters
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// The location of the file to set permissions on.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 0, ParameterSetName = "qA", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text is here")]
|
||||
// [Alias("s")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public string SourcePath
|
||||
// {
|
||||
// get { return _sourcePath; }
|
||||
// set { _sourcePath = value; }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// The location of the file to set permissions on.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 1, ParameterSetName = "qA", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text is here")]
|
||||
// [Alias("dv")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public int DaysValid
|
||||
// {
|
||||
// get { return _daysValid; }
|
||||
// set { _daysValid = value; }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// The location of the file to set permissions on.
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 2, ParameterSetName = "qA", Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text is here")]
|
||||
// [Alias("sv")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// public int SecondsValid
|
||||
// {
|
||||
// get { return _secondsValid; }
|
||||
// set { _secondsValid = value; }
|
||||
// }
|
||||
// #endregion
|
||||
// #region Methods
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// private string ConvertSignatureToHex(string signature)
|
||||
// {
|
||||
// string hexaHash = "";
|
||||
// foreach (byte b in signature)
|
||||
// {
|
||||
// hexaHash += String.Format("{0:x2}", b);
|
||||
// }
|
||||
// return hexaHash;
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// private string GenerateTempUrl(string signatureString)
|
||||
// {
|
||||
// var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(this.Settings.Username));
|
||||
// var hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(signatureString));
|
||||
// return BitConverter.ToString(hash).Replace("-", "").ToLower();
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// private string GetFormattedUri(StoragePath path)
|
||||
// {
|
||||
// string[] elements = this.CreateStoragePath(this.SourcePath).ToString().Split('/');
|
||||
// return String.Join("/", elements).Replace(elements[0] + "/" + elements[1] + "/" + elements[2], string.Empty);
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// public long GetEpochTime()
|
||||
// {
|
||||
// long baseTicks = 621355968000000000;
|
||||
// long tickResolution = 10000000;
|
||||
// long epoch = (DateTime.Now.ToUniversalTime().Ticks - baseTicks) / tickResolution;
|
||||
|
||||
// return epoch;
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
////=========================================================================================
|
||||
// private long GetExpirationInSeconds()
|
||||
// {
|
||||
// if (_daysValid != 0)
|
||||
// {
|
||||
// return GetEpochTime() + (86400 * _daysValid);
|
||||
// }
|
||||
// else if (_secondsValid != 0)
|
||||
// {
|
||||
// return GetEpochTime() + _secondsValid;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// private void GetTempUrl()
|
||||
// {
|
||||
// string uri = null;
|
||||
// long expiration = this.GetExpirationInSeconds();
|
||||
// string totalSeconds = Convert.ToString(expiration);
|
||||
// StoragePath fullPath = this.CreateStoragePath(this.SourcePath);
|
||||
// uri = this.GetFormattedUri(fullPath);
|
||||
// string signedString = this.GenerateTempUrl("GET" + "\n" + totalSeconds + "\n" + uri);
|
||||
// string signature = HttpUtility.UrlEncode(this.Settings.DefaultTenantId + ":" + this.Settings.Username + ":" + signedString);
|
||||
// string tempUrl = fullPath.BasePath + "?temp_url_sig=" + signature + "&temp_url_expires=" + totalSeconds;
|
||||
|
||||
// WriteObject("");
|
||||
// WriteObject("Object located at : " + tempUrl);
|
||||
// WriteObject("Url Expiration Date : " + DateTime.Now.AddDays(_daysValid).ToShortDateString() + ". [" + _daysValid + @" day(s) \ " + expiration + " seconds.]");
|
||||
// WriteObject("");
|
||||
|
||||
// if (this.Settings.PasteGetURIResultsToClipboard)
|
||||
// OutClipboard.SetText(tempUrl);
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
///// 1347472640
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected override void ProcessRecord()
|
||||
// {
|
||||
// if (_daysValid != 0 || _secondsValid != 0)
|
||||
// {
|
||||
// this.GetTempUrl();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// string uri = this.CreateStoragePath(this.SourcePath).ToString();
|
||||
|
||||
// if (this.Settings.PasteGetURIResultsToClipboard)
|
||||
// OutClipboard.SetText(uri);
|
||||
|
||||
// WriteObject("");
|
||||
// WriteObject("Object located at : " + uri);
|
||||
// WriteObject("");
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
//}
|
@ -1,133 +0,0 @@
|
||||
///* ============================================================================
|
||||
//Copyright 2014 Hewlett Packard
|
||||
|
||||
//Licensed under the Apache License, Version 2.0 (the "License");
|
||||
//you may not use this file except in compliance with the License.
|
||||
//You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
//Unless required by applicable law or agreed to in writing, software
|
||||
//distributed under the License is distributed on an "AS IS" BASIS,
|
||||
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//See the License for the specific language governing permissions and
|
||||
//limitations under the License.
|
||||
//============================================================================ */
|
||||
//using System;
|
||||
//using System.Management.Automation;
|
||||
//using OpenStack.Objects.DataAccess;
|
||||
//using OpenStack.Objects.Domain;
|
||||
//using OpenStack.Client.Powershell.Providers.Storage;
|
||||
//using OpenStack.Common;
|
||||
//using System.Management.Automation.Host;
|
||||
//using System.Collections.ObjectModel;
|
||||
//using System.Diagnostics.Contracts;
|
||||
//using OpenStack.Client.Powershell.Providers.Common;
|
||||
|
||||
//namespace OpenStack.Client.Powershell.Cmdlets.Common
|
||||
//{
|
||||
// [Cmdlet(VerbsCommon.Remove, "Item", SupportsShouldProcess = true)]
|
||||
// [RequiredServiceIdentifierAttribute(OpenStack.Objects.Domain.Admin.Services.ObjectStorage)]
|
||||
// public class RemoveItemCmdlet : BasePSCmdlet
|
||||
// {
|
||||
// public const string cDelimiter = "/";
|
||||
// private string _targetPath;
|
||||
|
||||
// #region Parameters
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// [Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Help Text")]
|
||||
// [ValidateNotNullOrEmpty]
|
||||
// [Alias("t")]
|
||||
// public string TargetPath
|
||||
// {
|
||||
// get { return _targetPath; }
|
||||
// set { _targetPath = value; }
|
||||
// }
|
||||
// #endregion
|
||||
// #region Methods
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// private void DeleteFolder(StoragePath targetPath, bool recurse)
|
||||
// {
|
||||
// Contract.Requires(targetPath.IsFolderPathOnly);
|
||||
|
||||
// string confirmationMsg;
|
||||
// IStorageObjectRepository repository = null;
|
||||
// OSDriveInfo kvsDrive = null;
|
||||
// Collection<ChoiceDescription> choices;
|
||||
|
||||
// #if (DEBUG)
|
||||
|
||||
// // We can't prompt for confirmation as this jacks up the unit test..
|
||||
|
||||
// repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
||||
// repository.DeleteFolder(targetPath.AbsoluteURI + "/");
|
||||
// kvsDrive = (OSDriveInfo)this.SessionState.Drive.Current;
|
||||
|
||||
// if (kvsDrive.PathCache.Exists(p => p == targetPath.Path))
|
||||
// {
|
||||
// kvsDrive.PathCache.Remove(targetPath.Path);
|
||||
// }
|
||||
// return;
|
||||
|
||||
// #endif
|
||||
|
||||
// choices = new Collection<ChoiceDescription>();
|
||||
// choices.Add(new ChoiceDescription("Y", "Yes"));
|
||||
// choices.Add(new ChoiceDescription("N", "No"));
|
||||
|
||||
// if (recurse) confirmationMsg = "You are about to delete an entire folder and all of its decendant folders. Are you sure about this?";
|
||||
// else confirmationMsg = "You are about to delete a folder and its Storage Objects Are you sure about this?";
|
||||
|
||||
// if (this.Host.UI.PromptForChoice("Confirmation Required." , confirmationMsg, choices, 0) == 0)
|
||||
// {
|
||||
// repository = this.RepositoryFactory.CreateStorageObjectRepository();
|
||||
// repository.DeleteFolder(targetPath.AbsoluteURI);
|
||||
|
||||
// kvsDrive = (OSDriveInfo)this.SessionState.Drive.Current;
|
||||
|
||||
// if (kvsDrive.PathCache.Exists(p => p == targetPath.Path))
|
||||
// {
|
||||
// kvsDrive.PathCache.Remove(targetPath.Path);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
////=========================================================================================
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
////=========================================================================================
|
||||
// protected override void ProcessRecord()
|
||||
// {
|
||||
// Contract.Requires(this.Drive != null);
|
||||
// StoragePath targetPath = this.CreateStoragePath(this.TargetPath);
|
||||
|
||||
// if (targetPath.IsFolderPathOnly)
|
||||
// {
|
||||
// this.DeleteFolder(targetPath, true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// this.RepositoryFactory.CreateStorageObjectRepository().DeleteStorageObject(targetPath.AbsoluteURI);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine("");
|
||||
// Console.WriteLine(ex.Message);
|
||||
// Console.WriteLine("");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// #endregion
|
||||
// }
|
||||
|
@ -1,176 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Collections;
|
||||
using Openstack.Objects.Domain.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Security
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Add, "Rule", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class AddRuleCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _direction;
|
||||
private string _etherType;
|
||||
private string _portRangeMax;
|
||||
private string _portRangeMin;
|
||||
private string _protocol;
|
||||
private string _remoteGroupId;
|
||||
private string _remoteIPPrefix;
|
||||
private string _securityGroupId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
//add-rule -ipr "iprTest" -IP "100.0.0.0" -tp "80" -fp "81" -sg "2302"
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, Mandatory = true, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Direction
|
||||
{
|
||||
get { return _direction; }
|
||||
set { _direction = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
// add-rule -ipr "iprTest" -IP "tcp" -tp "81" -fp "80"
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 4, Mandatory = false, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("et")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string EtherType
|
||||
{
|
||||
get { return _etherType; }
|
||||
set { _etherType = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 2, Mandatory = true, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("max")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string PortRangeMax
|
||||
{
|
||||
get { return _portRangeMax; }
|
||||
set { _portRangeMax = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("min")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string PortRangeMin
|
||||
{
|
||||
get { return _portRangeMin; }
|
||||
set { _portRangeMin = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 3, Mandatory = true, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("p")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Protocol
|
||||
{
|
||||
get { return _protocol; }
|
||||
set { _protocol = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
//add-rule -ipr "iprTest" -IP "100.0.0.0" -tp "80" -fp "81" -sg "2302"
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, Mandatory = true, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("sid")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SecurityGroupId
|
||||
{
|
||||
get { return _securityGroupId; }
|
||||
set { _securityGroupId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
//add-rule -ipr "iprTest" -IP "100.0.0.0" -tp "80" -fp "81" -sg "2302"
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, Mandatory = false, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("rgid")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string RemoteGroupId
|
||||
{
|
||||
get { return _remoteGroupId; }
|
||||
set { _remoteGroupId = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
//add-rule -ipr "iprTest" -IP "100.0.0.0" -tp "80" -fp "81" -sg "2302"
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 5, Mandatory = false, ParameterSetName = "AddRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("ripp")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string RemoteIPPrefix
|
||||
{
|
||||
get { return _remoteIPPrefix; }
|
||||
set { _remoteIPPrefix = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewSecurityGroupRule rule = new NewSecurityGroupRule();
|
||||
rule.PortRangeMin = this.PortRangeMin;
|
||||
rule.PortRangeMax = this.PortRangeMax;
|
||||
rule.Protocol = this.Protocol;
|
||||
rule.SecurityGroupId = this.SecurityGroupId;
|
||||
rule.RemoteGroupId = this.RemoteGroupId;
|
||||
rule.RemoteIPPrefix = this.RemoteIPPrefix;
|
||||
rule.EtherType = this.EtherType;
|
||||
rule.Direction = this.Direction;
|
||||
|
||||
SecurityGroupRule result = this.RepositoryFactory.CreateSecurityRepository().SaveSecurityRule(rule);
|
||||
this.UpdateCache<SecurityGroupUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -1,80 +0,0 @@
|
||||
/* ============================================================================
|
||||
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.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Security
|
||||
{
|
||||
[Cmdlet(VerbsCommon.New, "SecurityGroup", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class NewSecurityGroupCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _name;
|
||||
private string _description;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "NewSecurityGroup", ValueFromPipelineByPropertyName = true, HelpMessage = "ww")]
|
||||
[Alias("d")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string Description
|
||||
{
|
||||
get { return _description; }
|
||||
set { _description = value; }
|
||||
}
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 0, ParameterSetName = "NewSecurityGroup", Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "www")]
|
||||
[Alias("n")]
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
NewSecurityGroup newGroup = new NewSecurityGroup();
|
||||
newGroup.Description = this.Description;
|
||||
newGroup.Name = this.Name;
|
||||
|
||||
SecurityGroup securityGroup = this.RepositoryFactory.CreateSecurityRepository().SaveSecurityGroup(newGroup);
|
||||
this.UpdateCache<SecurityGroupsUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
/* ============================================================================
|
||||
Copyright 2014 Hewlett Packard
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
============================================================================ */
|
||||
using System.Management.Automation;
|
||||
using Openstack.Client.Powershell.Cmdlets.Common;
|
||||
using Openstack.Objects.Domain.Compute;
|
||||
using System.Linq;
|
||||
using Openstack.Client.Powershell.Providers.Security;
|
||||
using Openstack.Client.Powershell.Providers.Common;
|
||||
using System.Collections;
|
||||
using Openstack.Objects.Domain.Security;
|
||||
|
||||
namespace Openstack.Client.Powershell.Cmdlets.Security
|
||||
{
|
||||
[Cmdlet(VerbsCommon.Remove, "Rule", SupportsShouldProcess = true)]
|
||||
[RequiredServiceIdentifierAttribute(Openstack.Objects.Domain.Admin.Services.Compute)]
|
||||
public class RemoveRuleCmdlet : BasePSCmdlet
|
||||
{
|
||||
private string _securityGroupRuleId;
|
||||
|
||||
#region Parameters
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
[Parameter(Position = 1, Mandatory = true, ParameterSetName = "RemoveRule", ValueFromPipelineByPropertyName = true, HelpMessage = "cfgn")]
|
||||
[Alias("id")]
|
||||
[ValidateNotNullOrEmpty]
|
||||
public string SecurityGroupRuleId
|
||||
{
|
||||
get { return _securityGroupRuleId; }
|
||||
set { _securityGroupRuleId = value; }
|
||||
}
|
||||
#endregion
|
||||
#region Methods
|
||||
//=========================================================================================
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
//=========================================================================================
|
||||
protected override void ProcessRecord()
|
||||
{
|
||||
this.RepositoryFactory.CreateSecurityRepository().DeleteSecurityRule(this.SecurityGroupRuleId);
|
||||
this.UpdateCache<SecurityGroupUIContainer>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user