GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — vm.detachDisk requires a device name · Issue #922 · googleapis/google-cloud-node Closed Labels api: computeIssues related to the Compute Engine API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. DescriptionRight now, we're sending through a disk name, which !== device name. Here's a fix that will find the device name if the provided device name automatically if a Disk object doesn't have it already: /** * Custom error type for errors related to detaching a disk. * * @param {string} message - Custom error message. * @return {Error} */ var DetachDiskError = createErrorClass('DetachDiskError', function(message) { this.message = message; }); VM.prototype.detachDisk = function(deviceName, callback) { var self = this; if (deviceName instanceof Disk) { var disk = deviceName; if (disk.metadata.deviceName) { self.detachDisk(disk.metadata.deviceName, callback); return; } this.getMetadata(function(err, metadata) { if (err) { callback(new DetachDiskError(err.message)); return; } var deviceName; var baseUrl = 'https://www.googleapis.com/compute/v1/'; // Try to find the deviceName by matching the source of the attached disks // to the name of the disk provided by the user. for (var i = 0; !deviceName && i < metadata.disks.length; i++) { var attachedDisk = metadata.disks[i]; var source = attachedDisk.source.replace(baseUrl, ''); if (source === disk.formattedName) { deviceName = attachedDisk.deviceName; } } if (deviceName) { self.detachDisk(deviceName, callback); } else { callback(new DetachDiskError('Could not find a deviceName for disk.')); } }); return; } var query = { deviceName: deviceName }; this.makeReq_('POST', '/detachDisk', query, null, callback || util.noop); }; // system test... it('should attach and detach a disk', function(done) { var disk = zone.disk(generateName()); // This test waits on a lot of operations. this.timeout(90000); async.series([ createDisk, attachDisk, detachDisk ], done); function createDisk(callback) { var config = { os: 'ubuntu' }; disk.create(config, execAfterOperationComplete(callback)); } function attachDisk(callback) { vm.attachDisk(disk, execAfterOperationComplete(callback)); } function detachDisk(callback) { vm.detachDisk(disk, execAfterOperationComplete(callback)); } }); Activity
MetadataMetadataAssigneesLabelsapi: computeIssues related to the Compute Engine API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |