This repository has been archived by the owner on May 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from tistocks/tistocks_HDInsight_2
List and Create HDInsight clusters Tests and moved things around to comply with OneSDK standards
- Loading branch information
Showing
15 changed files
with
2,567 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright (c) Microsoft. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// External dependencies | ||
var crypto = require('crypto'); | ||
|
||
function HDInsightNamespace() { | ||
|
||
} | ||
|
||
function _LongUnsignedRor(value, count) { | ||
for(var i = 0; i<count; i++) { | ||
value = value / 2; | ||
} | ||
return Math.floor(value); | ||
} | ||
|
||
var base32StandardAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; | ||
function _Base32NoPaddingEncode (data) { | ||
var result = ''; | ||
for (var i = 0; i < data.length; i+=5) { | ||
|
||
// Process input 5 bytes at a time | ||
var multiplier = 256; | ||
var loopValue = 0; | ||
for (var j = Math.min(data.length-1, i+4); j >= i ; j--) { | ||
loopValue += data[j] * multiplier; | ||
multiplier = multiplier * 256; | ||
} | ||
|
||
// Converts them into base32 | ||
var bytes = Math.min(data.length - i, 5); | ||
for (var bitOffset = (bytes+1)*8 - 5; bitOffset > 3; bitOffset -= 5) { | ||
var index = _LongUnsignedRor(loopValue,bitOffset) % 32; | ||
result += base32StandardAlphabet[index]; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
HDInsightNamespace.prototype.GetNameSpace = function (subscriptionId, prefix, location) { | ||
location = location.replace(' ', '-'); | ||
var hash = crypto.createHash('sha256').update(new Buffer(subscriptionId, 'utf-8')).digest('hex'); | ||
return prefix + _Base32NoPaddingEncode(new Buffer(hash, 'hex')) + '-' + location; | ||
}; | ||
|
||
module.exports = HDInsightNamespace; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.