|
1 <?php |
|
2 /** |
|
3 * Zend Framework |
|
4 * |
|
5 * LICENSE |
|
6 * |
|
7 * This source file is subject to the new BSD license that is bundled |
|
8 * with this package in the file LICENSE.txt. |
|
9 * It is also available through the world-wide-web at this URL: |
|
10 * http://framework.zend.com/license/new-bsd |
|
11 * If you did not receive a copy of the license and are unable to |
|
12 * obtain it through the world-wide-web, please send an email |
|
13 * to license@zend.com so we can send you a copy immediately. |
|
14 * |
|
15 * @category Zend |
|
16 * @package Zend_Service_Console |
|
17 * @subpackage Exception |
|
18 * @version $Id$ |
|
19 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Service_Console_Command |
|
25 */ |
|
26 require_once 'Zend/Service/Console/Command.php'; |
|
27 |
|
28 /** |
|
29 * Deployment commands |
|
30 * |
|
31 * @category Zend |
|
32 * @package Zend_Service_WindowsAzure_CommandLine |
|
33 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
|
34 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
35 * |
|
36 * @command-handler deployment |
|
37 * @command-handler-description Windows Azure Deployment commands |
|
38 * @command-handler-header Windows Azure SDK for PHP |
|
39 * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com) |
|
40 * @command-handler-footer Note: Parameters that are common across all commands can be stored |
|
41 * @command-handler-footer in two dedicated environment variables. |
|
42 * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on. |
|
43 * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate. |
|
44 * @command-handler-footer |
|
45 * @command-handler-footer All commands support the --ConfigurationFile or -F parameter. |
|
46 * @command-handler-footer The parameter file is a simple INI file carrying one parameter |
|
47 * @command-handler-footer value per line. It accepts the same parameters as one can |
|
48 * @command-handler-footer use from the command line command. |
|
49 */ |
|
50 class Zend_Service_WindowsAzure_CommandLine_Deployment |
|
51 extends Zend_Service_Console_Command |
|
52 { |
|
53 /** |
|
54 * Creates a deployment from a remote package file and service configuration. |
|
55 * |
|
56 * @command-name CreateFromStorage |
|
57 * @command-description Creates a deployment from a remote package file and service configuration. |
|
58 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
59 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
60 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
61 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
62 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment. |
|
63 * @command-parameter-for $label Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment. |
|
64 * @command-parameter-for $staging Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Staging Host the service in the staging slot. |
|
65 * @command-parameter-for $production Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Production Host the service in the staging slot. |
|
66 * @command-parameter-for $packageUrl Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --PackageUrl Required. The remote location of the .cspkg file. |
|
67 * @command-parameter-for $serviceConfigurationLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. |
|
68 * @command-parameter-for $startImmediately Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation. |
|
69 * @command-parameter-for $warningsAsErrors Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors. |
|
70 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
71 * @command-example Create a deployment from a remote .cspkg: |
|
72 * @command-example CreateFromStorage -sid:"<your_subscription_id>" -cert:"mycert.pem" --Name:"hostedservicename" --DeploymentName:"deploymentname" |
|
73 * @command-example --Label:"deploymentlabel" --Production |
|
74 * @command-example --PackageUrl:"http://acct.blob.core.windows.net/pkgs/service.cspkg" |
|
75 * @command-example --ServiceConfigLocation:".\ServiceConfiguration.cscfg" --StartImmediately --WaitFor |
|
76 */ |
|
77 public function createFromStorageCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $staging = false, $production = false, $packageUrl, $serviceConfigurationLocation, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false) |
|
78 { |
|
79 $deploymentSlot = 'staging'; |
|
80 if (!$staging && !$production) { |
|
81 require_once 'Zend/Service/Console/Exception.php'; |
|
82 throw new Zend_Service_Console_Exception('Either --Staging or --Production should be specified.'); |
|
83 } |
|
84 if ($production) { |
|
85 $deploymentSlot = 'production'; |
|
86 } |
|
87 |
|
88 $client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors); |
|
89 |
|
90 if ($waitForOperation) { |
|
91 $client->waitForOperation(); |
|
92 } |
|
93 echo $client->getLastRequestId(); |
|
94 } |
|
95 |
|
96 /** |
|
97 * Creates a deployment from a local package file and service configuration. |
|
98 * |
|
99 * @command-name CreateFromLocal |
|
100 * @command-description Creates a deployment from a local package file and service configuration. |
|
101 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
102 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
103 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
104 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
105 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --DeploymentName Required. The name for the deployment. |
|
106 * @command-parameter-for $label Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment. |
|
107 * @command-parameter-for $staging Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Staging Host the service in the staging slot. |
|
108 * @command-parameter-for $production Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Production Host the service in the staging slot. |
|
109 * @command-parameter-for $packageLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --PackageLocation Required. The location of the .cspkg file. |
|
110 * @command-parameter-for $serviceConfigurationLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. |
|
111 * @command-parameter-for $storageAccount Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --StorageAccount Required. Storage account to use when creating the deployment. |
|
112 * @command-parameter-for $startImmediately Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --StartImmediately Optional. Start the deployment after creation. |
|
113 * @command-parameter-for $warningsAsErrors Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WarningsAsErrors Optional. Treat warnings as errors. |
|
114 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
115 * @command-example Create a deployment from a local .cspkg: |
|
116 * @command-example CreateFromLocal -sid:"<your_subscription_id>" -cert:"mycert.pem" --Name:"hostedservicename" --DeploymentName:"deploymentname" |
|
117 * @command-example --Label:"deploymentlabel" --Production --PackageLocation:".\service.cspkg" |
|
118 * @command-example --ServiceConfigLocation:".\ServiceConfiguration.cscfg" --StorageAccount:"mystorage" |
|
119 * @command-example --StartImmediately --WaitFor |
|
120 */ |
|
121 public function createFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentName, $label, $staging = false, $production = false, $packageLocation, $serviceConfigurationLocation, $storageAccount, $startImmediately = true, $warningsAsErrors = false, $waitForOperation = false) |
|
122 { |
|
123 $deploymentSlot = 'staging'; |
|
124 if (!$staging && !$production) { |
|
125 require_once 'Zend/Service/Console/Exception.php'; |
|
126 throw new Zend_Service_Console_Exception('Either --Staging or --Production should be specified.'); |
|
127 } |
|
128 if ($production) { |
|
129 $deploymentSlot = 'production'; |
|
130 } |
|
131 |
|
132 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
133 $blobClient = $client->createBlobClientForService($storageAccount); |
|
134 $blobClient->createContainerIfNotExists('phpazuredeployments'); |
|
135 $blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation); |
|
136 $package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation)); |
|
137 |
|
138 $client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors); |
|
139 |
|
140 $client->waitForOperation(); |
|
141 $blobClient->deleteBlob('phpazuredeployments', basename($packageLocation)); |
|
142 |
|
143 if ($waitForOperation) { |
|
144 $client->waitForOperation(); |
|
145 } |
|
146 echo $client->getLastRequestId(); |
|
147 } |
|
148 |
|
149 /** |
|
150 * Get deployment properties. |
|
151 * |
|
152 * @command-name GetProperties |
|
153 * @command-description Get deployment properties. |
|
154 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
155 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
156 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
157 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
158 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
159 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
160 * @command-example Get deployment properties for service "phptest" (production slot): |
|
161 * @command-example GetProperties -sid:"<your_subscription_id>" -cert:"mycert.pem" --Name:"servicename" --BySlot:"production" |
|
162 */ |
|
163 public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName) |
|
164 { |
|
165 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
166 |
|
167 $result = null; |
|
168 |
|
169 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
170 $deploymentSlot = strtolower($deploymentSlot); |
|
171 |
|
172 $result = $client->getDeploymentBySlot($serviceName, $deploymentSlot); |
|
173 } else { |
|
174 $result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName); |
|
175 } |
|
176 |
|
177 $this->_displayObjectInformation($result, array('Name', 'DeploymentSlot', 'Label', 'Url', 'Status')); |
|
178 } |
|
179 |
|
180 /** |
|
181 * Get hosted service account property. |
|
182 * |
|
183 * @command-name GetProperty |
|
184 * @command-description Get deployment property. |
|
185 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
186 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
187 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
188 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
189 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
190 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
191 * @command-parameter-for $property Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Property|-prop Required. The property to retrieve for the hosted service account. |
|
192 * @command-example Get deployment property "Name" for service "phptest" (production slot): |
|
193 * @command-example GetProperties -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
194 * @command-example --Name:"servicename" --BySlot:"production" --Property:"Name" |
|
195 */ |
|
196 public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $property) |
|
197 { |
|
198 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
199 |
|
200 $result = null; |
|
201 |
|
202 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
203 $deploymentSlot = strtolower($deploymentSlot); |
|
204 |
|
205 $result = $client->getDeploymentBySlot($serviceName, $deploymentSlot); |
|
206 } else { |
|
207 $result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName); |
|
208 } |
|
209 |
|
210 printf("%s\r\n", $result->$property); |
|
211 } |
|
212 |
|
213 /** |
|
214 * Swap deployment slots (perform VIP swap). |
|
215 * |
|
216 * @command-name Swap |
|
217 * @command-description Swap deployment slots (perform VIP swap). |
|
218 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
219 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
220 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
221 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
222 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
223 * @command-example Swap deployment slots: |
|
224 * @command-example Swap -sid:"<your_subscription_id>" -cert:"mycert.pem" --Name:"servicename" |
|
225 */ |
|
226 public function swapCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $waitForOperation = false) |
|
227 { |
|
228 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
229 |
|
230 $productionDeploymentName = null; |
|
231 try { $productionDeploymentName = $client->getDeploymentBySlot($serviceName, 'production')->Name; } catch (Exception $ex) {} |
|
232 |
|
233 $stagingDeploymentName = null; |
|
234 try { $stagingDeploymentName = $client->getDeploymentBySlot($serviceName, 'staging')->Name; } catch (Exception $ex) {} |
|
235 |
|
236 if (is_null($productionDeploymentName)) { |
|
237 $productionDeploymentName = $stagingDeploymentName; |
|
238 } |
|
239 if (is_null($stagingDeploymentName)) { |
|
240 require_once 'Zend/Service/Console/Exception.php'; |
|
241 throw new Zend_Service_Console_Exception('Swapping deployment slots is only possible when both slots have an active deployment or when production slot is empty.'); |
|
242 } |
|
243 |
|
244 $client->swapDeployment($serviceName, $productionDeploymentName, $stagingDeploymentName); |
|
245 |
|
246 if ($waitForOperation) { |
|
247 $client->waitForOperation(); |
|
248 } |
|
249 echo $client->getLastRequestId(); |
|
250 } |
|
251 |
|
252 /** |
|
253 * Deletes a deployment. |
|
254 * |
|
255 * @command-name Delete |
|
256 * @command-description Deletes a deployment. |
|
257 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
258 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
259 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
260 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
261 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
262 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
263 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
264 * @command-example Delete a deployment: |
|
265 * @command-example Delete -sid:"<your_subscription_id>" -cert:"mycert.pem" --Name:"hostedservicename" --DeploymentName:"deploymentname" |
|
266 */ |
|
267 public function deleteCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $waitForOperation = false) |
|
268 { |
|
269 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
270 |
|
271 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
272 $deploymentSlot = strtolower($deploymentSlot); |
|
273 |
|
274 $client->deleteDeploymentBySlot($serviceName, $deploymentSlot); |
|
275 } else { |
|
276 $client->deleteDeploymentByDeploymentId($serviceName, $deploymentName); |
|
277 } |
|
278 |
|
279 if ($waitForOperation) { |
|
280 $client->waitForOperation(); |
|
281 } |
|
282 echo $client->getLastRequestId(); |
|
283 } |
|
284 |
|
285 /** |
|
286 * Updates a deployment's configuration. |
|
287 * |
|
288 * @command-name UpdateConfig |
|
289 * @command-description Updates a deployment's configuration. |
|
290 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
291 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
292 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
293 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
294 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
295 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
296 * @command-parameter-for $serviceConfigurationLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. |
|
297 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
298 * @command-example Update configuration: |
|
299 * @command-example UpdateConfig -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
300 * @command-example --Name:"hostedservicename" --ByName:"deploymentname" |
|
301 * @command-example --ServiceConfigLocation:".\ServiceConfiguration.cscfg" |
|
302 */ |
|
303 public function updateConfigurationCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $serviceConfigurationLocation, $waitForOperation = false) |
|
304 { |
|
305 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
306 |
|
307 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
308 $deploymentSlot = strtolower($deploymentSlot); |
|
309 |
|
310 $client->configureDeploymentBySlot($serviceName, $deploymentSlot, $serviceConfigurationLocation); |
|
311 } else { |
|
312 $client->configureDeploymentByDeploymentId($serviceName, $deploymentName, $serviceConfigurationLocation); |
|
313 } |
|
314 |
|
315 if ($waitForOperation) { |
|
316 $client->waitForOperation(); |
|
317 } |
|
318 echo $client->getLastRequestId(); |
|
319 } |
|
320 |
|
321 /** |
|
322 * Updates a deployment's status. |
|
323 * |
|
324 * @command-name UpdateStatus |
|
325 * @command-description Updates a deployment's status. |
|
326 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
327 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
328 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
329 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
330 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
331 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
332 * @command-parameter-for $newStatus Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Status Required. New status (Suspended|Running) |
|
333 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
334 * @command-example Suspend a deployment: |
|
335 * @command-example UpdateStatus -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
336 * @command-example --Name:"hostedservicename" --ByName:"deploymentname" |
|
337 * @command-example --Status:"Suspended" |
|
338 */ |
|
339 public function updateStatusCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $newStatus, $waitForOperation = false) |
|
340 { |
|
341 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
342 |
|
343 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
344 $deploymentSlot = strtolower($deploymentSlot); |
|
345 |
|
346 $client->updateDeploymentStatusBySlot($serviceName, $deploymentSlot, $newStatus); |
|
347 } else { |
|
348 $client->updateDeploymentStatusByDeploymentId($serviceName, $deploymentName, $newStatus); |
|
349 } |
|
350 |
|
351 if ($waitForOperation) { |
|
352 $client->waitForOperation(); |
|
353 } |
|
354 echo $client->getLastRequestId(); |
|
355 } |
|
356 |
|
357 /** |
|
358 * Updates the number of instances. |
|
359 * |
|
360 * @command-name EditInstanceNumber |
|
361 * @command-description Updates the number of instances. |
|
362 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
363 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
364 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
365 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
366 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
367 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
368 * @command-parameter-for $roleName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RoleName|-r Required. Role name to update the number of instances for. |
|
369 * @command-parameter-for $newInstanceNumber Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --NewInstanceNumber|-i Required. New number of instances. |
|
370 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
371 * @command-example Suspend a deployment: |
|
372 * @command-example EditInstanceNumber -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
373 * @command-example --Name:"hostedservicename" --ByName:"deploymentname" |
|
374 * @command-example --NewInstanceNumber:"4" |
|
375 */ |
|
376 public function editInstanceNumberCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $roleName, $newInstanceNumber = 1, $waitForOperation = false) |
|
377 { |
|
378 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
379 |
|
380 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
381 $deploymentSlot = strtolower($deploymentSlot); |
|
382 |
|
383 $client->setInstanceCountBySlot($serviceName, $deploymentSlot, $roleName, $newInstanceNumber); |
|
384 } else { |
|
385 $client->setInstanceCountByDeploymentId($serviceName, $deploymentName, $roleName, $newInstanceNumber); |
|
386 } |
|
387 |
|
388 if ($waitForOperation) { |
|
389 $client->waitForOperation(); |
|
390 } |
|
391 echo $client->getLastRequestId(); |
|
392 } |
|
393 |
|
394 /** |
|
395 * Reboots a role instance. |
|
396 * |
|
397 * @command-name RebootInstance |
|
398 * @command-description Reboots a role instance. |
|
399 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
400 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
401 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
402 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
403 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
404 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
405 * @command-parameter-for $instanceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RoleInstanceName Required. The name of the role instance to work with. |
|
406 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
407 * @command-example Reboot a role instance: |
|
408 * @command-example RebootInstance -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
409 * @command-example --Name:"hostedservicename" --ByName:"deploymentname" |
|
410 * @command-example --RoleInstanceName:"PhpOnAzure.Web_IN_0" |
|
411 */ |
|
412 public function rebootInstanceCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $waitForOperation = false) |
|
413 { |
|
414 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
415 |
|
416 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
417 $deploymentSlot = strtolower($deploymentSlot); |
|
418 |
|
419 $client->rebootRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName); |
|
420 } else { |
|
421 $client->rebootRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName); |
|
422 } |
|
423 |
|
424 if ($waitForOperation) { |
|
425 $client->waitForOperation(); |
|
426 } |
|
427 echo $client->getLastRequestId(); |
|
428 } |
|
429 |
|
430 /** |
|
431 * Reimages a role instance. |
|
432 * |
|
433 * @command-name ReimageInstance |
|
434 * @command-description Reimages a role instance. |
|
435 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
436 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
437 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
438 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
439 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
440 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
441 * @command-parameter-for $instanceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RoleInstanceName Required. The name of the role instance to work with. |
|
442 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
443 * @command-example Reimage a role instance: |
|
444 * @command-example ReimageInstance -sid:"<your_subscription_id>" -cert:"mycert.pem" |
|
445 * @command-example --Name:"hostedservicename" --ByName:"deploymentname" |
|
446 * @command-example --RoleInstanceName:"PhpOnAzure.Web_IN_0" |
|
447 */ |
|
448 public function reimageInstanceCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $instanceName, $waitForOperation = false) |
|
449 { |
|
450 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
451 |
|
452 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
453 $deploymentSlot = strtolower($deploymentSlot); |
|
454 |
|
455 $client->reimageRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName); |
|
456 } else { |
|
457 $client->reimageRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName); |
|
458 } |
|
459 |
|
460 if ($waitForOperation) { |
|
461 $client->waitForOperation(); |
|
462 } |
|
463 echo $client->getLastRequestId(); |
|
464 } |
|
465 |
|
466 /** |
|
467 * Upgrades a deployment from a remote package file and service configuration. |
|
468 * |
|
469 * @command-name UpgradeFromStorage |
|
470 * @command-description Upgrades a deployment from a remote package file and service configuration. |
|
471 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
472 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
473 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
474 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
475 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
476 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
477 * @command-parameter-for $label Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment. |
|
478 * @command-parameter-for $packageUrl Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --PackageUrl Required. The remote location of the .cspkg file. |
|
479 * @command-parameter-for $serviceConfigurationLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. |
|
480 * @command-parameter-for $mode Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Mode Required. Set to auto|manual. |
|
481 * @command-parameter-for $roleName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RoleName Optional. Role name to upgrade. |
|
482 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
483 */ |
|
484 public function upgradeFromStorageCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $mode = 'auto', $roleName = null, $waitForOperation = false) |
|
485 { |
|
486 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
487 |
|
488 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
489 $deploymentSlot = strtolower($deploymentSlot); |
|
490 |
|
491 $client->upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $packageUrl, $serviceConfigurationLocation, $mode, $roleName); |
|
492 } else { |
|
493 $client->upgradeDeploymentByDeploymentId($serviceName, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $mode, $roleName); |
|
494 } |
|
495 |
|
496 if ($waitForOperation) { |
|
497 $client->waitForOperation(); |
|
498 } |
|
499 echo $client->getLastRequestId(); |
|
500 } |
|
501 |
|
502 /** |
|
503 * Upgrades a deployment from a local package file and service configuration. |
|
504 * |
|
505 * @command-name UpgradeFromLocal |
|
506 * @command-description Upgrades a deployment from a local package file and service configuration. |
|
507 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
508 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
509 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
510 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
511 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
512 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
513 * @command-parameter-for $label Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Label Required. The label for the deployment. |
|
514 * @command-parameter-for $packageLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --PackageLocation Required. The location of the .cspkg file. |
|
515 * @command-parameter-for $serviceConfigurationLocation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ServiceConfigLocation Required. The location of the .cspkg file. |
|
516 * @command-parameter-for $storageAccount Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --StorageAccount Required. Storage account to use when creating the deployment. |
|
517 * @command-parameter-for $mode Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Mode Required. Set to auto|manual. |
|
518 * @command-parameter-for $roleName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RoleName Optional. Role name to upgrade. |
|
519 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
520 */ |
|
521 public function upgradeFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $label, $packageLocation, $serviceConfigurationLocation, $storageAccount, $mode = 'auto', $roleName = null, $waitForOperation = false) |
|
522 { |
|
523 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
524 |
|
525 $blobClient = $client->createBlobClientForService($storageAccount); |
|
526 $blobClient->createContainerIfNotExists('phpazuredeployments'); |
|
527 $blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation); |
|
528 $package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation)); |
|
529 |
|
530 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
531 $deploymentSlot = strtolower($deploymentSlot); |
|
532 |
|
533 $client->upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $package->Url, $serviceConfigurationLocation, $mode, $roleName); |
|
534 } else { |
|
535 $client->upgradeDeploymentByDeploymentId($serviceName, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $mode, $roleName); |
|
536 } |
|
537 |
|
538 $client->waitForOperation(); |
|
539 $blobClient->deleteBlob('phpazuredeployments', basename($packageLocation)); |
|
540 |
|
541 if ($waitForOperation) { |
|
542 $client->waitForOperation(); |
|
543 } |
|
544 echo $client->getLastRequestId(); |
|
545 } |
|
546 |
|
547 /** |
|
548 * Walks upgrade domains. |
|
549 * |
|
550 * @command-name WalkUpgradeDomains |
|
551 * @command-description Walks upgrade domains. |
|
552 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on. |
|
553 * @command-parameter-for $certificate Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Certificate|-cert Required. This is the .pem certificate that user has uploaded to Windows Azure subscription as Management Certificate. |
|
554 * @command-parameter-for $certificatePassphrase Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Prompt --Passphrase|-p Required. The certificate passphrase. If not specified, a prompt will be displayed. |
|
555 * @command-parameter-for $serviceName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Name Required. The hosted service account name to operate on. |
|
556 * @command-parameter-for $deploymentSlot Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --BySlot Required if deployment name is omitted. The slot to retrieve property information for. |
|
557 * @command-parameter-for $deploymentName Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --ByName Required if deployment slot is omitted. The deployment name to retrieve property information for. |
|
558 * @command-parameter-for $upgradeDomain Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --UpgradeDomain Required. The upgrade domain index. |
|
559 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete? |
|
560 */ |
|
561 public function walkUpgradeDomainsCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $upgradeDomain, $waitForOperation = false) |
|
562 { |
|
563 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
|
564 |
|
565 if (!is_null($deploymentSlot) && $deploymentSlot != '') { |
|
566 $deploymentSlot = strtolower($deploymentSlot); |
|
567 |
|
568 $client->walkUpgradeDomainBySlot($serviceName, $deploymentSlot, $upgradeDomain); |
|
569 } else { |
|
570 $client->walkUpgradeDomainByDeploymentId($serviceName, $deploymentName, $upgradeDomain); |
|
571 } |
|
572 |
|
573 if ($waitForOperation) { |
|
574 $client->waitForOperation(); |
|
575 } |
|
576 echo $client->getLastRequestId(); |
|
577 } |
|
578 } |
|
579 |
|
580 Zend_Service_Console_Command::bootstrap($_SERVER['argv']); |