14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Service_Console |
16 * @package Zend_Service_Console |
17 * @subpackage Exception |
17 * @subpackage Exception |
18 * @version $Id$ |
18 * @version $Id$ |
19 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @license http://framework.zend.com/license/new-bsd New BSD License |
21 */ |
21 */ |
22 |
22 |
|
23 /** |
|
24 * @see Zend_Service_Console_Command |
|
25 */ |
|
26 require_once 'Zend/Service/Console/Command.php'; |
|
27 |
|
28 /** |
|
29 * @see Zend_Service_WindowsAzure_Management_Client |
|
30 */ |
|
31 require_once 'Zend/Service/WindowsAzure/Management/Client.php'; |
23 |
32 |
24 /** |
33 /** |
25 * Storage commands |
34 * Storage commands |
26 * |
35 * |
27 * @category Zend |
36 * @category Zend |
28 * @package Zend_Service_WindowsAzure_CommandLine |
37 * @package Zend_Service_WindowsAzure_CommandLine |
29 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
38 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
30 * @license http://framework.zend.com/license/new-bsd New BSD License |
39 * @license http://framework.zend.com/license/new-bsd New BSD License |
31 * |
40 * |
32 * @command-handler storage |
41 * @command-handler storage |
33 * @command-handler-description Windows Azure Storage commands |
42 * @command-handler-description Windows Azure Storage commands |
34 * @command-handler-header Windows Azure SDK for PHP |
43 * @command-handler-header Windows Azure SDK for PHP |
35 * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com) |
44 * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com) |
36 * @command-handler-footer Note: Parameters that are common across all commands can be stored |
45 * @command-handler-footer Note: Parameters that are common across all commands can be stored |
37 * @command-handler-footer in two dedicated environment variables. |
46 * @command-handler-footer in two dedicated environment variables. |
38 * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on. |
47 * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on. |
39 * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate. |
48 * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate. |
40 * @command-handler-footer |
49 * @command-handler-footer |
41 * @command-handler-footer All commands support the --ConfigurationFile or -F parameter. |
50 * @command-handler-footer All commands support the --ConfigurationFile or -F parameter. |
42 * @command-handler-footer The parameter file is a simple INI file carrying one parameter |
51 * @command-handler-footer The parameter file is a simple INI file carrying one parameter |
43 * @command-handler-footer value per line. It accepts the same parameters as one can |
52 * @command-handler-footer value per line. It accepts the same parameters as one can |
44 * @command-handler-footer use from the command line command. |
53 * @command-handler-footer use from the command line command. |
45 */ |
54 */ |
46 class Zend_Service_WindowsAzure_CommandLine_Storage |
55 class Zend_Service_WindowsAzure_CommandLine_Storage |
47 extends Zend_Service_Console_Command |
56 extends Zend_Service_Console_Command |
48 { |
57 { |
49 /** |
58 /** |
50 * List storage accounts for a specified subscription. |
59 * List storage accounts for a specified subscription. |
51 * |
60 * |
52 * @command-name ListAccounts |
61 * @command-name ListAccounts |
53 * @command-description List storage accounts for a specified subscription. |
62 * @command-description List storage accounts for a specified subscription. |
54 * @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. |
63 * @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. |
55 * @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. |
64 * @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. |
56 * @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. |
65 * @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. |
67 } |
76 } |
68 foreach ($result as $object) { |
77 foreach ($result as $object) { |
69 $this->_displayObjectInformation($object, array('ServiceName', 'Url')); |
78 $this->_displayObjectInformation($object, array('ServiceName', 'Url')); |
70 } |
79 } |
71 } |
80 } |
72 |
81 |
73 /** |
82 /** |
74 * Get storage account properties. |
83 * Get storage account properties. |
75 * |
84 * |
76 * @command-name GetProperties |
85 * @command-name GetProperties |
77 * @command-description Get storage account properties. |
86 * @command-description Get storage account properties. |
78 * @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. |
87 * @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. |
79 * @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. |
88 * @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. |
80 * @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. |
89 * @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. |
85 */ |
94 */ |
86 public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName) |
95 public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName) |
87 { |
96 { |
88 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
97 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
89 $result = $client->getStorageAccountProperties($accountName); |
98 $result = $client->getStorageAccountProperties($accountName); |
90 |
99 |
91 $this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location')); |
100 $this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location')); |
92 } |
101 } |
93 |
102 |
94 /** |
103 /** |
95 * Get storage account property. |
104 * Get storage account property. |
96 * |
105 * |
97 * @command-name GetProperty |
106 * @command-name GetProperty |
98 * @command-description Get storage account property. |
107 * @command-description Get storage account property. |
99 * @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. |
108 * @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. |
100 * @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. |
109 * @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. |
101 * @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. |
110 * @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. |
107 */ |
116 */ |
108 public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName, $property) |
117 public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName, $property) |
109 { |
118 { |
110 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
119 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
111 $result = $client->getStorageAccountProperties($accountName); |
120 $result = $client->getStorageAccountProperties($accountName); |
112 |
121 |
113 printf("%s\r\n", $result->$property); |
122 printf("%s\r\n", $result->$property); |
114 } |
123 } |
115 |
124 |
116 /** |
125 /** |
117 * Get storage account keys. |
126 * Get storage account keys. |
118 * |
127 * |
119 * @command-name GetKeys |
128 * @command-name GetKeys |
120 * @command-description Get storage account keys. |
129 * @command-description Get storage account keys. |
121 * @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. |
130 * @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. |
122 * @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. |
131 * @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. |
123 * @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. |
132 * @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. |
128 */ |
137 */ |
129 public function getKeysCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName) |
138 public function getKeysCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName) |
130 { |
139 { |
131 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
140 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
132 $result = $client->getStorageAccountKeys($accountName); |
141 $result = $client->getStorageAccountKeys($accountName); |
133 |
142 |
134 $this->_displayObjectInformation((object)array('Key' => 'primary', 'Value' => $result[0]), array('Key', 'Value')); |
143 $this->_displayObjectInformation((object)array('Key' => 'primary', 'Value' => $result[0]), array('Key', 'Value')); |
135 $this->_displayObjectInformation((object)array('Key' => 'secondary', 'Value' => $result[1]), array('Key', 'Value')); |
144 $this->_displayObjectInformation((object)array('Key' => 'secondary', 'Value' => $result[1]), array('Key', 'Value')); |
136 } |
145 } |
137 |
146 |
138 /** |
147 /** |
139 * Get storage account key. |
148 * Get storage account key. |
140 * |
149 * |
141 * @command-name GetKey |
150 * @command-name GetKey |
142 * @command-description Get storage account key. |
151 * @command-description Get storage account key. |
143 * @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. |
152 * @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. |
144 * @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. |
153 * @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. |
145 * @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. |
154 * @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. |
151 */ |
160 */ |
152 public function getKeyCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName, $key = 'primary') |
161 public function getKeyCommand($subscriptionId, $certificate, $certificatePassphrase, $accountName, $key = 'primary') |
153 { |
162 { |
154 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
163 $client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase); |
155 $result = $client->getStorageAccountKeys($accountName); |
164 $result = $client->getStorageAccountKeys($accountName); |
156 |
165 |
157 if (strtolower($key) == 'secondary') { |
166 if (strtolower($key) == 'secondary') { |
158 printf("%s\r\n", $result[1]); |
167 printf("%s\r\n", $result[1]); |
159 } |
168 } |
160 printf("%s\r\n", $result[0]); |
169 printf("%s\r\n", $result[0]); |
161 } |
170 } |
162 |
171 |
163 /** |
172 /** |
164 * Regenerate storage account keys. |
173 * Regenerate storage account keys. |
165 * |
174 * |
166 * @command-name RegenerateKeys |
175 * @command-name RegenerateKeys |
167 * @command-description Regenerate storage account keys. |
176 * @command-description Regenerate storage account keys. |
168 * @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. |
177 * @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. |
169 * @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. |
178 * @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. |
170 * @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. |
179 * @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. |