LEFT | RIGHT |
1 /* | 1 /* |
2 This file is part of the Juju GUI, which lets users view and manage Juju | 2 This file is part of the Juju GUI, which lets users view and manage Juju |
3 environments within a graphical interface (https://launchpad.net/juju-gui). | 3 environments within a graphical interface (https://launchpad.net/juju-gui). |
4 Copyright (C) 2012-2013 Canonical Ltd. | 4 Copyright (C) 2012-2013 Canonical Ltd. |
5 | 5 |
6 This program is free software: you can redistribute it and/or modify it under | 6 This program is free software: you can redistribute it and/or modify it under |
7 the terms of the GNU Affero General Public License version 3, as published by | 7 the terms of the GNU Affero General Public License version 3, as published by |
8 the Free Software Foundation. | 8 the Free Software Foundation. |
9 | 9 |
10 This program is distributed in the hope that it will be useful, but WITHOUT | 10 This program is distributed in the hope that it will be useful, but WITHOUT |
(...skipping 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 Single atomic, non-mutating parse of a bundle | 1328 Single atomic, non-mutating parse of a bundle |
1329 followed by things like id assignment, this | 1329 followed by things like id assignment, this |
1330 returns a complex data structure which is used | 1330 returns a complex data structure which is used |
1331 by importDeployer to enact the deploy. | 1331 by importDeployer to enact the deploy. |
1332 | 1332 |
1333 @method injestDeployer | 1333 @method injestDeployer |
1334 */ | 1334 */ |
1335 injestDeployer: function(data, name, options) { | 1335 injestDeployer: function(data, name, options) { |
1336 if (!data) {return;} | 1336 if (!data) {return;} |
1337 options = options || {}; | 1337 options = options || {}; |
1338 var self = this; | |
1339 var db = this.db; | 1338 var db = this.db; |
1340 var rewriteIds = options.rewriteIds || false; | 1339 var rewriteIds = options.rewriteIds || false; |
1341 var targetBundle = options.targetBundle; | 1340 var targetBundle = options.targetBundle; |
1342 var useGhost = options.useGhost; | 1341 var useGhost = options.useGhost; |
1343 if (useGhost === undefined) { | 1342 if (useGhost === undefined) { |
1344 useGhost = true; | 1343 useGhost = true; |
1345 } | 1344 } |
1346 var defaultSeries = db.environment.get('defaultSeries'); | |
1347 | |
1348 if (!targetBundle && Object.keys(data).length > 1) { | 1345 if (!targetBundle && Object.keys(data).length > 1) { |
1349 throw new Error('Import target ambigious, aborting.'); | 1346 throw new Error('Import target ambigious, aborting.'); |
1350 } | 1347 } |
1351 | 1348 |
1352 // Builds out a object with inherited properties. | 1349 // Builds out a object with inherited properties. |
1353 var source = targetBundle && data[targetBundle] || | 1350 var source = targetBundle && data[targetBundle] || |
1354 data[Object.keys(data)[0]]; | 1351 data[Object.keys(data)[0]]; |
1355 var ancestors = []; | 1352 var ancestors = []; |
1356 var seen = []; | 1353 var seen = []; |
1357 | 1354 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1399 }); | 1396 }); |
1400 | 1397 |
1401 // Create an id mapping. This will track the ids of objects | 1398 // Create an id mapping. This will track the ids of objects |
1402 // read from data as they are mapped into db. When options | 1399 // read from data as they are mapped into db. When options |
1403 // rewriteIds is true this is required for services, but some | 1400 // rewriteIds is true this is required for services, but some |
1404 // types of object ids ('relations' for example) can always | 1401 // types of object ids ('relations' for example) can always |
1405 // be rewritten but depend on the use of the proper ids. | 1402 // be rewritten but depend on the use of the proper ids. |
1406 // By building this mapping now we can detect collisions | 1403 // By building this mapping now we can detect collisions |
1407 // prior to mutating the database. | 1404 // prior to mutating the database. |
1408 var serviceIdMap = {}; | 1405 var serviceIdMap = {}; |
1409 var charms = []; | |
1410 | |
1411 /** | 1406 /** |
1412 Helper to generate the next valid service id. | 1407 Helper to generate the next valid service id. |
1413 @method nextServiceId | 1408 @method nextServiceId |
1414 @return {String} next service id to use. | 1409 @return {String} next service id to use. |
1415 */ | 1410 */ |
1416 function nextServiceId(modellist, id) { | 1411 function nextServiceId(modellist, id) { |
1417 var existing = modellist.getById(id); | 1412 var existing = modellist.getById(id); |
1418 var count = 0; | 1413 var count = 0; |
1419 var target; | 1414 var target; |
1420 while (existing) { | 1415 while (existing) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 Y.namespace('juju.environments').FakeBackend = FakeBackend; | 1576 Y.namespace('juju.environments').FakeBackend = FakeBackend; |
1582 | 1577 |
1583 }, '0.1.0', { | 1578 }, '0.1.0', { |
1584 requires: [ | 1579 requires: [ |
1585 'base', | 1580 'base', |
1586 'js-yaml', | 1581 'js-yaml', |
1587 'juju-models', | 1582 'juju-models', |
1588 'promise' | 1583 'promise' |
1589 ] | 1584 ] |
1590 }); | 1585 }); |
LEFT | RIGHT |