2014-04-07 15:46:20 -05:00
|
|
|
|
/* ============================================================================
|
|
|
|
|
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;
|
2014-05-02 12:30:21 -05:00
|
|
|
|
using OpenStack.Client.Powershell.Utility;
|
2014-04-07 15:46:20 -05:00
|
|
|
|
|
2014-05-02 12:30:21 -05:00
|
|
|
|
namespace OpenStack.Client.Powershell.Cmdlets.Common
|
2014-04-07 15:46:20 -05:00
|
|
|
|
{
|
|
|
|
|
[Cmdlet(VerbsCommon.Set, "Config", SupportsShouldProcess = true)]
|
2014-05-02 12:30:21 -05:00
|
|
|
|
public class SetConfigCmdlet : BasePSCmdlet
|
2014-04-07 15:46:20 -05:00
|
|
|
|
{
|
2014-06-04 13:31:52 -05:00
|
|
|
|
//private string _configFilePath = @"C:\Users\tplummer\Source\Repos\OpenStack-NewCLI\Rackspace.Client.Powershell\Deployment\Rackspace.config";
|
|
|
|
|
private string _configFilePath = null;
|
2014-04-07 15:46:20 -05:00
|
|
|
|
private SwitchParameter _reset = false;
|
|
|
|
|
|
|
|
|
|
#region Parameters
|
|
|
|
|
//=========================================================================================
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
//=========================================================================================
|
2014-05-02 12:30:21 -05:00
|
|
|
|
//[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc3", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
|
|
|
|
//[Alias("resetcfg")]
|
|
|
|
|
//[ValidateNotNullOrEmpty]
|
|
|
|
|
//public SwitchParameter Reset
|
|
|
|
|
//{
|
|
|
|
|
// get { return _reset; }
|
|
|
|
|
// set { _reset = value; }
|
|
|
|
|
//}
|
2014-04-07 15:46:20 -05:00
|
|
|
|
//=========================================================================================
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
//=========================================================================================
|
2014-05-02 12:30:21 -05:00
|
|
|
|
[Parameter(Position = 1, Mandatory = false, ParameterSetName = "sc4", ValueFromPipelineByPropertyName = true, HelpMessage = "s")]
|
2014-04-07 15:46:20 -05:00
|
|
|
|
[Alias("s")]
|
|
|
|
|
[ValidateNotNullOrEmpty]
|
|
|
|
|
public string ConfigFilePathKey
|
|
|
|
|
{
|
|
|
|
|
get { return _configFilePath; }
|
|
|
|
|
set { _configFilePath = value; }
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//=======================================================================================================
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
2014-05-02 12:30:21 -05:00
|
|
|
|
//=================================================zx======================================================
|
2014-04-07 15:46:20 -05:00
|
|
|
|
private void LoadConfigFile()
|
2014-05-02 12:30:21 -05:00
|
|
|
|
{
|
2014-06-04 13:31:52 -05:00
|
|
|
|
var configManager = new ConfigurationManager();
|
2014-05-02 12:30:21 -05:00
|
|
|
|
configManager.Load(this.ConfigFilePathKey);
|
|
|
|
|
ServiceProvider provider = configManager.GetDefaultServiceProvider();
|
|
|
|
|
|
2014-06-04 13:31:52 -05:00
|
|
|
|
var loader = new ExtensionManager(this.SessionState, this.Context);
|
2014-05-02 12:30:21 -05:00
|
|
|
|
|
|
|
|
|
loader.LoadCore(provider);
|
|
|
|
|
loader.LoadExtension(provider);
|
2014-04-07 15:46:20 -05:00
|
|
|
|
|
|
|
|
|
// Show the User the new ServiceCatalog that we just received..
|
|
|
|
|
|
2014-06-04 13:31:52 -05:00
|
|
|
|
var capabilities = new AccountCapabilities(this.SessionState, this.Context, this.CoreClient, this);
|
|
|
|
|
capabilities.WriteServices();
|
|
|
|
|
capabilities.WriteContainers();
|
2014-04-07 15:46:20 -05:00
|
|
|
|
}
|
|
|
|
|
//=======================================================================================================
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
//=======================================================================================================
|
|
|
|
|
protected override void ProcessRecord()
|
|
|
|
|
{
|
2014-05-02 12:30:21 -05:00
|
|
|
|
this.LoadConfigFile();
|
2014-04-07 15:46:20 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|