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
Next Next commit
initial checkin azure v2
  • Loading branch information
morsh committed Dec 12, 2016
commit bcbccbf162278c8c3f662fcf18f97e25327741e5
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}\\lib\\pkgcloud",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Launch Azure V2",
"program": "${workspaceRoot}\\examples\\compute\\azure-v2.js",
"cwd": "${workspaceRoot}",
"stopOnEntry": true
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
63 changes: 63 additions & 0 deletions examples/compute/azure-v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
var pkgcloud = require('../../lib/pkgcloud'),
fs = require('fs'),
client,
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}"
};
client = pkgcloud.compute.createClient(options);

//
// Create a server.
// This may take several minutes.
//
options = {
// pkgcloud compute properties
name: 'ms-pkgc-test2', // name of the server
flavor: 'Standard_D1', // azure vm size
//image: '5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS63DEC20121220', // OS Image to use
image: {
uri: 'https://{storename}.blob.core.windows.net/osdiks/ms-pkgc-test-os2.vhd',
OS: 'linux'
},
nic: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Network/networkInterfaces/{nicName}',

// Azure vm properties
location: 'West Europe', // Azure location for server
username: 'pkgcloud', // Username for server
password: 'Pkgcloud!!' // Password for server
};

console.log('creating server...');

client.createServer(options, function (err, server) {
if (err) {
console.log(err);
} else {
// Wait for the server to reach the RUNNING state.
// This may take several minutes.
console.log('waiting for server RUNNING state...');
server.setWait({ status: server.STATUS.running }, 10000, function (err, server) {
if (err) {
console.log(err);
} else {
console.dir(server);
}
});
}
});



1 change: 1 addition & 0 deletions lib/pkgcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var components = [
var providers = [
'amazon',
'azure',
'azure-v2',
'digitalocean',
'google',
'iriscouch',
Expand Down
54 changes: 54 additions & 0 deletions lib/pkgcloud/azure-v2/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* client.js: Base client from which all Azure clients inherit from
*
* (C) Microsoft Open Technologies, Inc. All rights reserved.
*
*/

var util = require('util'),
base = require('../core/base');

var Client = exports.Client = function (options) {
base.Client.call(this, options);

options = options || {};

// Allow overriding serversUrl in child classes
this.provider = 'azure-v2';
this.protocol = options.protocol || 'https://';

if (!this.before) {
this.before = [];
}
};

util.inherits(Client, base.Client);

Client.prototype._toArray = function toArray(obj) {
if (typeof obj === 'undefined') {
return [];
}

return Array.isArray(obj) ? obj : [obj];
};

Client.prototype.failCodes = {
400: 'Bad Request',
401: 'Unauthorized',
403: 'Forbidden',
404: 'Item not found',
409: 'Already exists or in progress',
412: 'Lease error',
413: 'Request Entity Too Large',
415: 'Bad Media Type',
500: 'Fault',
503: 'Service Unavailable'
};

Client.prototype.successCodes = {
200: 'OK',
201: 'Created',
202: 'Accepted',
203: 'Non-authoritative information',
204: 'No content'
};
44 changes: 44 additions & 0 deletions lib/pkgcloud/azure-v2/compute/client/flavors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* flavors.js: Implementation of Azure Flavors Client.
*
* (C) Microsoft Open Technologies, Inc.
*
*/

var pkgcloud = require('../../../../../lib/pkgcloud'),
base = require('../../../core/compute'),
compute = pkgcloud.providers.azure.compute;

//
// ### function getFlavors (callback)
// #### @callback {function} f(err, flavors). `flavors` is an array that
// represents the flavors that are available to your account
//
// Lists all flavors available to your account.
//
exports.getFlavors = function getFlavors(callback) {
var self = this;

callback(null, Object.keys(compute.Flavor.options).map(function (name) {
return new compute.Flavor(self, { name: name });
}));
};

//
// ### function getFlavor (flavor, callback)
// #### @image {Flavor|String} Flavor ID or an Flavor
// #### @callback {function} f(err, flavor). `flavor` is an object that
// represents the flavor that was retrieved.
//
// Gets a specified flavor of AWS DataSets using the provided details
// object.
//
exports.getFlavor = function getFlavor(flavor, callback) {
var flavorId = flavor instanceof base.Flavor ? flavor.id : flavor;

if (flavor instanceof base.Flavor) {
return callback(null, flavor);
}

callback(null, new compute.Flavor(this, { id : flavorId }));
};
121 changes: 121 additions & 0 deletions lib/pkgcloud/azure-v2/compute/client/images.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*
* images.js: Implementation of Azure Images Client.
*
* (C) Microsoft Open Technologies, Inc.
*
*/
var pkgcloud = require('../../../../../lib/pkgcloud'),
base = require('../../../core/compute'),
compute = pkgcloud.providers.azure.compute,
azureApi = require('../../utils/azureApiV2');

//
// ### function getImages (callback)
// #### @callback {function} f(err, images). `images` is an array that
// represents the images that are available to your account
//
// Lists all images available to your account.
//
exports.getImages = function getImages(options, callback) {
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}

var path = this.config.subscriptionId + '/services/images',
self = this;

return this.get(path, function (err, body, res) {
return err
? callback(err)
: callback(null, self._toArray(body.OSImage).map(function (image) {
return new compute.Image(self, image);
}), res);
});
};

// ### function getImage (image, callback)
// #### @image {Image|String} Image id or an Image
// #### @callback {function} f(err, image). `image` is an object that
// represents the image that was retrieved.
//
// Gets a specified image of Azure using the provided details
// object.
//
exports.getImage = function getImage(image, callback) {
var self = this,
imageId = image instanceof base.Image ? image.id : image,
path = this.config.subscriptionId + '/services/images/' + imageId;

this.get(path, function (err, body, res) {

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

var result = null;
if (body) {
result = new compute.Image(self, body);
}

return result
? callback(null, result, res)
: callback(new Error('Image not found'));
});
};

//
// ### function createImage(options, callback)
// #### @id {Object} an object literal with options
// #### @name {String} String name of the image
// #### @server {Server} the server to use
// #### @callback {function} f(err, image). `image` is an object that
// represents the image that was created.
//
// Creates an image in Azure based on a server
//
exports.createImage = function createImage(options, callback) {
options || (options = {});

if (!options.name) {
throw new TypeError('`name` is a required option');
}

if (!options.server) {
throw new TypeError('`server` is a required option');
}

var self = this,
serverId = options.server instanceof base.Server
? options.server.id
: options.server;

azureApi.createImage(this, serverId, options.name, function (err, result) {
return !err
? self.getImage(result, callback)
: callback(err);
});
};

//
// ### function destroyImage(image, callback)
// #### @image {Image|String} Image id or an Image
// #### @callback {function} f(err, image). `image` is an object that
// represents the image that was deleted.
//
// Destroys an image in Azure
//
exports.destroyImage = function destroyImage(image, callback) {
var self = this,
imageId = image instanceof base.Image ? image.id : image,
path = self.config.subscriptionId + '/services/images/' + imageId;

self._xmlRequest({
method: 'DELETE',
path: path
}, function (err, body, res) {
return err
? callback(err)
: callback(null, { ok: imageId }, res);
});
};
Loading