Create Azure storage account if needed

This commit is contained in:
Ilya Dmitrichenko 2015-03-05 14:38:06 +00:00
parent 1f4474cf4b
commit 2510f89863
3 changed files with 21 additions and 1 deletions

View File

@ -7,6 +7,7 @@ azure.create_config('kubernetes', { 'etcd': 3, 'kube': 3 });
azure.run_task_queue([
azure.queue_default_network(),
azure.queue_storage_if_needed(),
azure.queue_machines('etcd', 'stable',
kube.create_etcd_cloud_config),
azure.queue_machines('kube', 'stable',

View File

@ -161,6 +161,22 @@ exports.queue_default_network = function () {
'--address-space=172.16.0.0',
conf.resources['vnet'],
]);
}
exports.queue_storage_if_needed = function() {
if (!process.env['AZURE_STORAGE_ACCOUNT']) {
conf.storage_account = util.rand_suffix;
task_queue.push([
'storage', 'account', 'create',
get_location(),
conf.storage_account,
]);
process.env['AZURE_STORAGE_ACCOUNT'] = conf.storage_account;
} else {
// Preserve it for resizing, so we don't create a new one by accedent,
// when the environment variable is unset
conf.storage_account = process.env['AZURE_STORAGE_ACCOUNT'];
}
};
exports.queue_machines = function (name_prefix, coreos_update_channel, cloud_config_creator) {
@ -232,6 +248,8 @@ exports.destroy_cluster = function (state_file) {
task_queue.push(['network', 'vnet', 'delete', '--quiet', conf.resources['vnet']]);
// TODO: add storage deletion when AZURE_STORAGE_ACCOUNT is unset (depends on Azure/azure-xplat-cli#1615)
exports.run_task_queue();
};
@ -247,4 +265,5 @@ exports.load_state_for_resizing = function (state_file, node_type, new_nodes) {
conf.nodes[node_type] += new_nodes;
hosts.collection = conf.hosts;
hosts.ssh_port_counter += conf.hosts.length;
process.env['AZURE_STORAGE_ACCOUNT'] = conf.storage_account;
}

View File

@ -9,7 +9,7 @@
"author": "Ilya Dmitrichenko <errordeveloper@gmail.com>",
"license": "Apache 2.0",
"dependencies": {
"azure-cli": "^0.8.14",
"azure-cli": "^0.8.15",
"colors": "^1.0.3",
"js-yaml": "^3.2.5",
"openssl-wrapper": "^0.2.1",