~travis-plummer/openstack-cli-powershell/master

« back to all changes in this revision

Viewing changes to Openstack.Client.Powershell/Deployment/Examples/readme.txt

  • Committer: Monty Taylor
  • Date: 2015-10-17 20:03:56 UTC
  • Revision ID: git-v1:803406e7e09f6f4199f7a92f11f2904ad1d6cc15
Retire stackforge/openstack-cli-powershell

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
OpenStack Powershell CLI - Getting Set up to Contribute
2
 
 
3
 
I - Pre-requisits
4
 
  
5
 
 Before we get started we need to make sure that our Development environment reflects what a machine looks like when we install the CLI. The following steps should get the job done.
6
 
 
7
 
 A. Set the Required Execution Policy
8
 
 
9
 
    To use the OpenStack CLI Software for Windows PowerShell, you must make sure that your Powershell environment is capable of executing 3rd party modules.
10
 
    Note: If you are performing a re-installation of the software package, you can skip this step. This step is applicable only for a fresh installation.
11
 
    Open a PowerShell window as the administrator and issue the command set-executionpolicy -ExecutionPolicy Unrestricted:
12
 
 
13
 
        -------------------------------------------------------------------------------------------------------------------
14
 
    PS C:\Projects\Outgoing\OS> set-executionpolicy -ExecutionPolicy Unrestricted
15
 
 
16
 
    Execution policy change
17
 
 
18
 
    The execution policy helps protect you from scripts that you do not trust. Changing the execution policy
19
 
    might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to
20
 
    change the execution policy?
21
 
    [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
22
 
    PS C:\Projects\Outgoing\OS> 
23
 
        -------------------------------------------------------------------------------------------------------------------
24
 
        Close the Powershell window and reopen as administrator for the policy changes to take effect.
25
 
 
26
 
 B. A Quick Setting in Visual Studio
27
 
  
28
 
   After Cloning the repo and loading the solution within Visual Studio, ensure that the "Enable Nuget Package Restore"  option has been turned 
29
 
   on at the Solution level. This will retreive all of the neccessary external dependencies for the Solution to build properly. 
30
 
   
31
 
C. - Supplying your Credentials
32
 
 
33
 
Our next step is to make sure that we supply the proper credentials when logging on to the system. If you ran the CLI after your initial
34
 
install, you'll have noticed that you were prompted for this information. The result is stored in the OpenStack.config file located within the Users Personal Data Folder
35
 
under the OS directory. With each Build we must update that file with the version in our solution. This is so that when new config file changes are introduced, you 
36
 
have the CLI picking them up at runtime from the expected location (instead of residing in just your project directory). Complete these steps to supply this information.
37
 
 
38
 
1. Navigate to the OpenStack.Client.Powershell project and look into the Deployment folder.
39
 
2. Within that folder you will see a file called OpenStack.config.example
40
 
3. Copy the example file into the same folder but remove the .example on the filename.
41
 
4. Open up the OpenStack.config file that you just created.
42
 
5. Find the config section entitled "IdentityServices".
43
 
6. Within this section supply values for Username, Password, and Default Tenenat Id. All of this can be found within your account information on you providers portal.
44
 
 
45
 
Each time that we build, this OpenStack.config file will be moved to the correct runtime location via Post-Build Scripts outlined in the next section.
46
 
 
47
 
D. - Edit Post Build Scripts
48
 
 
49
 
Within the OpenStack.Client.Powershell projects Post-Build Event you'll notice that we call a PostBuild.bat file. This
50
 
batch file will move important run-time files required by the CLI to their proper locations if you decide to edit them.
51
 
Without this, all changes to important files (like OpenStack.config) would go unnoticed because they would sit in our project
52
 
folders on disk (rather than the location the CLI expects). To create tis batch file, follow these steps.
53
 
 
54
 
1. Navigate to the OpenStack.Client.Powershell project and look into the Deployment folder.
55
 
2. Within that folder you will see a file called PostBuild.example
56
 
3. Open up that file and copy the contents to the clipboard. 
57
 
4. Within that same folder create a file called PostBuild.bat
58
 
5. Paste the script on the clipboard into that file. 
59
 
6. Notice the Action Required section of the file. Modify the path you see there to reflect your development machine.
60
 
7. Save your Project and do a test build (Rebuild All). The Output Window will show any Echo results from the script and show any script errors that may break the build.
61
 
 
62
 
E. - Modifying you Developer Profile 
63
 
 
64
 
 When the Powershell runtime starts it looks for a file called Microsoft.PowerShell_profile.ps1. This script gets executed right after
65
 
Powershell loads. Here we can set up the look of the environment, issue some default commands (useful for testing!) 
66
 
and loading Powershell Modules. The Powershell module is where all of our CLI code resides and must get loaded by this script. 
67
 
The only problem here is that the path to that module is specific to your machine. To address this follow these steps
68
 
 
69
 
 1. Open up the DevProfile.ps1.example file within the Solutions [OpenStack.Client.Powershell]\Deployment folder.
70
 
 2. Copy the contents of this file into a new text file called DevProfile.ps1
71
 
 3. Search this document for "ACTION REQUIRED" and follow the instructions given.   
72
 
 
73
 
II - Debugging 
74
 
 
75
 
Debugging the CLI is a bit more challenging than with say a normal executable. In this case the entry point or main process is the Powershell runtime itself.
76
 
This requires us to load our work into that environment and attach the VS debugger to the Powershell host at runtime. Follow these steps to get the debugger running.
77
 
 
78
 
        1. Set your breakpoint.
79
 
        2. Compile the Solution. 
80
 
        3. Load Powershell. With everything in place this should automatically Import the module you just compiled. 
81
 
        3. From within VS select Debug\Attach To Process
82
 
        4. Attach to the Powershell.exe process.
83
 
        5. Issue a command in the CLI that triggers your breakpoint.
84
 
 
85
 
A. Debugging Provider Code
86
 
 
87
 
When Powershell modules get Imported, any providers found in that Module will be executed first. This leaves us with a problem in that 
88
 
any code that we need to debug in the provider during startup needs to be paused until we have time to actually set a break point properly.
89
 
To do this complete the following actions.
90
 
                 
91
 
        1. Set you breakpoint in the providers InitializeDefaultDrives() method. This is the first stage in the Providers Life-Cycle.
92
 
        2. Open the DevProfile.ps1 file.
93
 
        3. Comment out the Import-Module statement (Copy it to the clipboard for your convience).
94
 
        2. Compile the Solution. 
95
 
        3. Load Powershell.  
96
 
        3. From within VS select Debug\Attach To Process
97
 
        4. Attach to the Powershell.exe process.
98
 
        5. From the command line paste the Import-Module statement into the CLI. This will trigger the breakpoint that you set in step 1.
99
 
 
100
 
B. Getting to the Action - A Quick Tip
101
 
        
102
 
Sometimes we're trying to debug something in the CLI and we need to get to a certain location quickly. For example if you are testing the 
103
 
list view for Servers and your sick of typing this after you restart each time
104
 
        
105
 
        cd\
106
 
        cd Servers
107
 
        ls
108
 
        cd 1
109
 
        ls
110
 
        
111
 
Just remember that this can be placed in your Devprofile.ps1 file and Powershell will issue those commands for you. This makes debugging a specific 
112
 
section of the CLI much easier.. 
113
 
 
114
 
III. Testing 
115
 
 
116
 
  Object Storage Integration Test Notes
117
 
 
118
 
   These unit test require a particular directory structure to be present on your machine to complete the test cases where we copy files and or folders to the server. 
119
 
   Make sure that you have something like the following on your machine.
120
 
 
121
 
   Folder1 (contains files)
122
 
       ->  Folder2 (contains files)
123
 
                -> Folder3 (contains NO files)
124
 
 
125
 
   Note : Go to the Testing section in the OpenStack.config file. Make sure that LocalTestDirectory 
126
 
   element points to the root of the test folder hierarchy (Folder1 in the example above).        
 
 
b'\\ No newline at end of file'