Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bcbccbf
initial checkin azure v2
morsh Dec 12, 2016
d62014b
adding login to get server
morsh Dec 13, 2016
906472d
DestroyServer addition
jeniawhite Dec 13, 2016
725ef47
Merge branch 'master' of https://github.com/CatalystCode/pkgcloud
morsh Dec 13, 2016
043e151
Fixing removal of options in logintoazure after merge
jeniawhite Dec 13, 2016
49745cc
Fixing get server status response on errors
jeniawhite Dec 13, 2016
6244f34
adding storage for azure-v2
morsh Dec 30, 2016
d49cfcd
azure-v2 compute mgmt + moving to templates
morsh Jan 2, 2017
69ee436
not including .private. files
morsh Jan 2, 2017
61b7b3e
adjustments to code with self
morsh Jan 2, 2017
6e51331
minor fixes
morsh Jan 2, 2017
1f0301b
updating code according to travis-ci comments
morsh Jan 3, 2017
288c81e
travis-ci review #2
morsh Jan 3, 2017
1eb444f
adding first tests
morsh Jan 4, 2017
186f0d0
update test name
morsh Jan 4, 2017
c586d42
fix bind
morsh Jan 4, 2017
6ae7635
update test for multple calls
morsh Jan 4, 2017
ee05c2d
destroying dependencies when destroying a linux VM
morsh Jan 8, 2017
424d6b8
adding tests to containers for azure-v2
morsh Jan 8, 2017
2398625
travis review
morsh Jan 8, 2017
32f957e
removing launch.json
morsh Jan 8, 2017
b37ed6c
updating examples
morsh Jan 8, 2017
07cdf66
changing destroy server to enable different dependencies
morsh Jan 11, 2017
5fa39a7
adding remote extension for windows vms
morsh Feb 9, 2017
d965ec3
Merge remote-tracking branch 'pkgcloud/master'
jackyalbo Feb 13, 2017
5607270
adding remove file functionality
morsh Feb 14, 2017
227467c
updating relative pkgcloud path
morsh Feb 14, 2017
8de41e9
adding dynamic data disk creation
morsh Feb 15, 2017
a2ce4f0
reverting package to right name/version
morsh Feb 15, 2017
63f27a5
fixing jshint #1
morsh Feb 15, 2017
e030cd3
jshint fixes #2
morsh Feb 15, 2017
3113e82
jshint fix #3
morsh Feb 15, 2017
bd3867e
Merge pull request #1 from pkgcloud/master
Feb 15, 2017
1e44b67
removing all arrow functions
morsh Feb 15, 2017
6a38525
reverting package.json
morsh Feb 15, 2017
7058437
removing es6 singlequotes
morsh Feb 15, 2017
326a5f5
jshint #4
morsh Feb 15, 2017
cd551f1
removing extractors
morsh Feb 15, 2017
ac50dc8
adjusting some tests
morsh Feb 16, 2017
0e8b229
canceling filter of azure-v2
morsh Feb 16, 2017
13575ee
Merge remote-tracking branch 'origin/master'
jackyalbo Mar 12, 2017
b8f41ac
adding ssh support for both linux and windows
jackyalbo Mar 15, 2017
4dec2ec
Merge pull request #3 from CatalystCode/ssh_fix2
Mar 16, 2017
b02a55c
small urgent fix
jackyalbo Apr 25, 2017
98aa959
Merge pull request #4 from CatalystCode/ssh_fix2
jackyalbo Apr 25, 2017
718987c
miniature fix for running ssh on windows
jackyalbo Apr 26, 2017
a8fb5b4
Merge pull request #5 from CatalystCode/ssh_fix2
jackyalbo Apr 26, 2017
2caa019
bug fix
jackyalbo Apr 27, 2017
c1c749d
Merge pull request #6 from CatalystCode/ssh_fix2
jackyalbo Apr 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding first tests
  • Loading branch information
morsh committed Jan 4, 2017
commit 1eb444f7f9c1679bef1b17bd6422c65e34fddbc2
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,35 @@
"cwd": "${workspaceRoot}",
"stopOnEntry": true
},
{
"type": "node",
"request": "launch",
"name": "Test Azure V2 Server",
"program": "${workspaceRoot}//test//azure-v2//compute//client//test-getServers.js",
"cwd": "${workspaceRoot}",
"stopOnEntry": true,
"env": {
"MOCK": "on"
}
},
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Run mocha",
// Type of configuration. Possible values: "node", "mono".
"type": "node",
// Workspace relative or absolute path to the program.
"program": "${workspaceRoot}//node_modules//mocha//bin//_mocha",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": ["${workspaceRoot}//test//azure-v2//compute//client//test-getServers.js"],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": "${workspaceRoot}",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Environment variables passed to the program.
"env": { "MOCK": "on" }
},
{
"type": "node",
"request": "attach",
Expand Down
16 changes: 8 additions & 8 deletions examples/compute/azure-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ var options;
// Create a pkgcloud compute instance
//
options = {
resourceGroup: '{resourceGroup}',
provider: 'azure-v2',
storageAccount: '{storeName}',
storageAccessKey: '{storeKey}',
subscriptionId: '{subscriptionId}',
spClientId: '{spClientId}',
spSecret: '{spSecret}',
spDomain: '{spDomain}',
spSubscriptionId: '{spSubscriptionId}'
subscriptionId: "{subscriptionId}",
resourceGroup: "{resourceGroup}",

servicePrincipal: {
clientId: "{spClientId}",
secret: "{spSecret}",
domain: "{spDomain}"
}
};
client = pkgcloud.compute.createClient(options);

Expand Down
95 changes: 41 additions & 54 deletions lib/pkgcloud/azure-v2/compute/client/servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,72 +138,60 @@ function destroyServer(server, callback) {
});
}

//
// ### function stopServer(server, callback)
// #### @server {Server|String} Server id or a server
// #### @callback {Function} f(err, serverId).
//
// Destroy a server in Azure.
//
/**
* Stop a server in Azure.
* @param {Server|string} server Server id or a server
* @param {function} callback cb(err, serverId).
*/
function stopServer(server, callback) {
var self = this;
var serverId = server instanceof self.models.Server ? server.id : server;

console.log('Stopping', serverId, '...');
return callback(new Error('not implemented yet'));
// azureApi.stopServer(this, serverId, function (err) {
// return !err
// ? callback(null, { ok: serverId })
// : callback(err);
// });
}
self.login(err => {

if (err) {
return callback(err);
}

//
// ### function createHostedService(serviceName, callback)
// #### @serviceName {String} name of the Hosted Service
// #### @callback {Function} f(err, serverId).
//
// Creates a Hosted Service in Azure.
//
function createHostedService(serviceName, callback) {
console.log('createing hosted service', serviceName, '...');
return callback(new Error('not implemented yet'));
// azureApi.createHostedService(this, serviceName, function (err, res) {
// return !err
// ? callback(null, res)
// : callback(err);
// });
var client = new ComputeManagementClient(self.azure.credentials, self.config.subscriptionId);
client.virtualMachines.powerOff(self.config.resourceGroup, serverId, (err) => {
return err
? callback(err)
: callback(null, serverId);
});
});
}

//
// ### function rebootServer (server, options, callback)
// #### @server {Server|String} The server to reboot
// #### @callback {Function} f(err, server).
//
// Reboots a server
//
/**
* Restart a server in Azure.
* @param {Server|string} server Server id or a server
* @param {function} callback cb(err, serverId).
*/
function rebootServer(server, callback) {
var self = this;
var serverId = server instanceof self.models.Server ? server.id : server;

console.log('rebotting server', serverId, '...');
return callback(new Error('not implemented yet'));
// azureApi.rebootServer(this, serverId, function (err) {
// return !err
// ? callback(null, { ok: serverId })
// : callback(err);
// });
self.login(err => {

if (err) {
return callback(err);
}

var client = new ComputeManagementClient(self.azure.credentials, self.config.subscriptionId);
client.virtualMachines.restart(self.config.resourceGroup, serverId, (err) => {
return err
? callback(err)
: callback(null, serverId);
});
});
}

//
// ### function renameServer(server, name, callback)
// #### @server {Server|String} Server id or a server
// #### @name {String} New name to apply to the server
// #### @callback {Function} f(err, server).
//
// Renames a server
//
function renameServer(server, name, callback) {
/**
* Rename a server in Azure.
* @param {Server|string} server Server id or a server
* @param {function} callback cb(err, serverId).
*/
function renameServer(server, callback) {
return errs.handle(
errs.create({ message: 'Not supported by Azure.' }),
callback
Expand All @@ -218,7 +206,6 @@ module.exports = {
createServer,
destroyServer,
stopServer,
createHostedService,
rebootServer,
renameServer
};
2 changes: 1 addition & 1 deletion lib/pkgcloud/azure-v2/compute/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var Server = exports.Server = function Server(client, details) {

util.inherits(Server, base.Server);

Server.prototype._setProperties = function (details, statuses) {
Server.prototype._setProperties = function (details) {

details = details || {};
this.id = details.id || '';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"jshint": "~2.7.0",
"mocha": "1.21.x",
"mocha-lcov-reporter": "0.0.1",
"nock": "^9.0.2",
"should": "4.0.x"
},
"main": "./lib/pkgcloud",
Expand Down
63 changes: 63 additions & 0 deletions test/azure-v2/compute/client/test-getServers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//TODO: Make this a vows test

var mockRequests = require('../../mock-requests');
var helpers = require('../../../helpers');
var should = require('should');
var mock = !!process.env.MOCK;

// client.getServer('azure-vm-server', function (err, result) {
// if (err) {
// console.error(err);
// } else {
// console.dir(result);
// }
// });

// client.getServers(function (err, result) {
// if (err) {
// console.error(err);
// } else {
// console.dir(result);
// }
// });

describe('pkgcloud/amazon/groups', function () {

var client;

before(function (done) {
debugger;
client = helpers.createClient('azure-v2', 'compute');

if (!mock) {
return done();
}

mockRequests.prepare();
});

it('add SecurityGroup should succeed', function(done) {

debugger;
client.getServer('azure-vm-server', (err, server) => {
should.not.exist(err);
should.exist(server)
server.status.should.equal('RUNNING');
});

});

after(function(done) {
if (!mock) {
return done();
}

//server.close(done);
});
});






40 changes: 40 additions & 0 deletions test/azure-v2/mock-requests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var path = require('path');
var nock = require('nock');
var helpers = require('../helpers');

const azureAuthUri = 'https://login.microsoftonline.com';
const azureManagementUri = 'https://management.azure.com';
const requestId = 'b67cc525-ecc5-4661-8fd6-fb3e57d724f5';
const apiVersion = '2016-03-30';

function loadFixture(name) {
return helpers.loadFixture(path.join('azure-v2', name));
}

function prepare() {

var config = helpers.loadConfig('azure-v2');
var sp = config.servicePrincipal;


// Nock authentication requests
nock(`${azureAuthUri}`)
.post(`/${sp.domain}/oauth2/token?api-version=1.0`)
.reply(200, loadFixture('authentication-certificate.json'));

// Subscriptions
nock(`${azureManagementUri}`)
.get('/subscriptions?api-version=2015-11-01')
.reply(200, loadFixture('subscriptions.json'));

// Servers
nock(`${azureManagementUri}/subscriptions/${config.subscriptionId}/resourceGroups/${config.resourceGroup}/providers/Microsoft.Compute`)
.get(`/virtualMachines?api-version=${apiVersion}`)
.reply(200, loadFixture('servers.json'))
.get(`/virtualMachines/azure-vm-server?$expand=instanceView&api-version=${apiVersion}`)
.reply(200, loadFixture('server.json'))
}

module.exports = {
prepare
};
9 changes: 9 additions & 0 deletions test/configs/mock/azure-v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"subscriptionId": "azure-account-subscription-id",
"resourceGroup": "resource-group",
"servicePrincipal": {
"clientId": "sp-client-id",
"secret": "sp-secret",
"domain": "sp-domain"
}
}
9 changes: 9 additions & 0 deletions test/fixtures/azure-v2/authentication-certificate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"token_type":"Bearer",
"expires_in":"3600",
"ext_expires_in":"10800",
"expires_on":"1483452282",
"not_before":"1483448382",
"resource":"https://management.core.windows.net/",
"access_token":"XXXXXXXX"
}
Loading