Commit Graph

53 Commits

Author SHA1 Message Date
ricolin 9bbf3d8a97 retire js-openstack-lib
This project is being retired

Release update: https://review.opendev.org/c/openstack/governance/+/771789

ML: http://lists.openstack.org/pipermail/openstack-discuss/2021-January/019847.html
Codesearch: https://codesearch.opendev.org/?q=js-openstack-lib&i=nope&files=&excludeFiles=&repos=

Change-Id: I94c42c0ac3ec23c685d1b50d35383ad078916f06
2023-10-19 12:29:20 -07:00
Monty Taylor 346f7eeda0 Update eslint and switch to standard
The openstack eslint package is just really not needed at this
point. Use standardjs and run --fix on it.

Switch away from using node 8 to run linters and tests.

Change-Id: I51f68d4ec30c8da5d1601ef00045e53f90d0554b
2020-06-12 13:04:59 -05:00
Radosław Piliszek 8354146c11 CI: New jobs
This follows removal of jobs from project-config. [1]

New jobs use newer node versions and new Zuul v3 format,
reusing devstack for deployment of OpenStack for functional
testing of jslib.

Version tests have been adapted to follow support logic
already in place instead of hardcoded supported versions.

Includes workaround (fixup) of devstack's bug. [2]

Move the functional test to experimental for now, because version
discovery doesn't work right and Firefox is generally grumpy.
We want to get the structural stuff in first.

[1] https://review.opendev.org/702030
[2] https://bugs.launchpad.net/devstack/+bug/1860287

Depends-on: https://review.opendev.org/704882
Depends-on: https://review.opendev.org/726547
Co-authored-by: Monty Taylor <mordred@inaugust.com>
Change-Id: I197eb2b59be7a49d168edf09d554b444bbcc29b2
2020-06-12 17:06:24 +00:00
Dong Ma cfc2f665d4 Add flavorList to Openstack wrapper
This patch integrated nova into Openstack wrapper, allowing
flavorList to be used

Change-Id: Ic149ce2bd11bc439431cca0e2aa294874708d234
2016-12-04 07:18:15 -08:00
Michael Krotscheck 7ee22fdfbe Created Nova service with flavorList method.
We can now query for flavors.

Change-Id: Ia19afa530ae8c2df60db740cec9267fe240978c0
2016-12-02 17:49:37 -05:00
Jenkins cf336dec98 Merge "Add imageList to Openstack wrapper" 2016-12-02 21:55:05 +00:00
Corentin Ardeois beec17c6e4 Use serviceEndpoint compatible with versions
This patch adds a more flexible selection of version in AbstractService.
A version will be selected if it's compatible with the 'supportedVersions'.
Example:
  supportedVersions = ['v3.1'];
  All minor versions above 3.1 will be compatible (3.1.2, 3.2, 3.3 etc)
  However 4.x will not be compatible

Change-Id: Icd540449ebf6a09d9bb7e1d25a85e2dbe787c5a4
2016-11-23 09:53:27 -05:00
Corentin Ardeois 0ba0ea9668 Add imageList to Openstack wrapper
This patch integrated glance into Openstack wrapper, allowing
imageList to be  used

Change-Id: I64e5d432224aa673ab1e6ace3e927af2f8b3a13f
2016-11-21 15:17:44 -05:00
Corentin Ardeois 0a4fb9f8b9 Added support for multi-region catalog
OpenStack wrapper will read the 'region_name' from config, and use
the correct endpoint matching this region

Change-Id: I01049f3bed227eb1e11f9a1f7d338177e95aef34
2016-10-25 12:44:20 +02:00
Vitaly Kramskikh 9dabaecf11 Added tokenInfo() method to Keystone API
Also fixed nesting in keystone functional tests and deduplicated
mock data for Keystone.

Change-Id: Ia2f0def84d45616eb8c3464b7ba4f47fadfda50d
2016-10-17 21:53:07 +00:00
Jenkins 8828ec6382 Merge "Support names and ids for users, projects and domains in Keystone" 2016-10-17 21:49:20 +00:00
Vitaly Kramskikh 3956dbe65b Support names and ids for users, projects and domains in Keystone
In Keystone API it's possible to provide both ids and names for
users, projects, user domains and project domains. This commit
adds support for this functionality.

Change-Id: I3268bd82cc92a150927c98e0827ebd105d91f5e3
2016-10-17 19:01:11 +03:00
Corentin Ardeois c330bbdc62 Added networkList() method to OpenStack wrapper
This patch adds the networkList() method to the OpenStack wrapper
class. This method will initialize `Neutron` instance if needed and
cache it. As neutron needs the URL, `Keystone` instance is also
initialize and cache if needed.

Change-Id: If12af29a86b9856a145c1f91de25eb3473938de5
2016-10-17 10:31:41 -04:00
Corentin Ardeois 70a98fb10c Added networkList() method to neutron API
This patch adds the networkList() method to the network API.

Change-Id: Ie0878787169988253a93dd6d67b07a97bd005587
2016-10-05 15:58:42 -04:00
Dong Ma c5c58bcaad Seperate OpenStack class from index.js
This commit to seperate OpenStack class from index.js to new file

Change-Id: If433040fce752e0033eb61139fd8daa9c6dbb669
2016-09-29 09:12:54 -07:00
Dong Ma 9677a06a2d OpenStack wrapper instance
Create wrapper class that takes clouds.yaml instance

Change-Id: I37429b7bda35ca09efc3bf153841d4dc92d96b55
2016-09-28 07:38:46 -07:00
Corentin Ardeois b033ad652e Added Neutron Service
This neutron service follows the same pattern as the glance service,
and provides both version negotiation and endpoint discovery.

Change-Id: Ia2f59213eedf6d7acbb02789ee921c13ff391d09
2016-09-26 14:05:34 -04:00
msmol 7c544e1460 Updates linting rules
New linting rule to disable spaces after functions, before parens
Fixed all new linting errors

I suppose I'd like this to eventually get landed in official
`eslint-config-openstack` project, but for now it is here

Change-Id: I6c77524c5679117ce3b211db0bd9943c5ad5e646
2016-09-23 13:46:04 -04:00
Jenkins 3221a3513d Merge "Export supported services from index.js" 2016-09-23 16:25:48 +00:00
Vitaly Kramskikh c2164e8b15 Export supported services from index.js
This is required to make services provided by library accessible
this way:

  import {Keystone} from 'openstack-lib';

instead of

  import Keystone from 'openstack-lib/dist/keystone';

Also, Test class and dummy functional and unit tests for it were
removed since they aren't needed anymore.

Change-Id: I6bf0b6eebab095d6585d19d8398d9f2ac119cacc
2016-09-22 20:42:27 +03:00
Michael Krotscheck 525d5897c7
Renamed abstract_service to abstractService
Mostly because abstract_serviceTest looks weird.

Change-Id: Ia27b0e0cc70b8e4280f52f40eb78b466e358aa54
2016-09-22 07:39:42 -07:00
Michael Krotscheck abfe901b5e
AbstractService will try to detect the versions resource in more places.
We have no guarantees that the keystone service catalog will have the
root resource of any given service registered. As most versioned API
endpoints require tokens, we can reasonably assume that a 401 will
be encountered. This patch adds an extra check against the response
from the provided URL, and should a 401 be encountered, attempts
to resolve the versions from the root resource of the provided URL.

Change-Id: I655409f0eb9bfbd3489827db46faef026ede82f9
2016-09-22 07:36:39 -07:00
Corentin Ardeois 773b2b8ee3 Add more service abstraction
This patch add _requestComponents and serviceEndpoint methods to
abstract service, as these methods ared used for both Keystone and
Glance services.

Change-Id: Iccc334c0bbd79c1207855260932dab984f2d9d6c
2016-09-06 13:21:29 -04:00
Jenkins a9bac97fab Merge "Use babel-plugin-transform-runtime instead of babel-polyfill" 2016-09-06 14:15:37 +00:00
Vitaly Kramskikh e33758f9db Use babel-plugin-transform-runtime instead of babel-polyfill
babel-plugin-transform-runtime allows to reduce size of the
resulting bundle dramatically (from 260kb to 24kb).

Change-Id: I3cceb1caddfb5b0b2048b7d4efc2cebfee26ab91
2016-09-05 19:25:18 +03:00
Corentin Ardeois 07a5dde06c Create common service version abstraction
This patch updates common class named AbstractService to propose
common logic for multiple version negociation.

Change-Id: I999d95fca8ff01afea02ed9953c6b4a3828fa3eb
2016-09-01 14:41:51 -07:00
Michael Krotscheck acbc25ce99 Created common service abstraction
This patch creates a common class named AbstractService from which
all API classes can inherit common logic.

Change-Id: I18339ac19ed2b97a7b9b3d6a0f1e01292080c422
2016-09-01 14:40:46 -07:00
Michael Krotscheck 45809be72b Added imageList() method to glance API
This patch adds the imageList() method (and associated token handling)
to the glance API.

Change-Id: I840f347d446b9b774c532afe38d62a94e5336a73
2016-09-01 14:38:52 -07:00
Michael Krotscheck 7a64d24795 Added Glance Service
This glance service follows the same pattern as the keystone service,
and provides both version negotiation and endpoint discovery. Unlike
the keystone service, however, it is configured using an endpoint
configuration object as discovered from the Keystone service catalog.

Change-Id: I0fe2bc9690022688e2cb80b9ca1b10bcea86c13d
2016-09-01 14:38:37 -07:00
Michael Krotscheck 3bce487421 Passed tokens may now be promises.
Tokens passed to token-requiring API methods may now also be promises,
permitting promise-based request chaining across API's. For example:

keystone
  .issueToken()
  .then((token) => glance.imageList(token));

...or:

const tokenPromise = keystone.issueToken();

Promise.all([
  glance.imageList(tokenPromise),
  neutron.networkList(tokenPromise),
  nova.flavorList(tokenPromise)
]).then(([images, networks, flavors]) => {
  return nova.instanceCreate( ... );
});

These updates have been wrapped into a private method, which can
be used for other API's as well. revokeToken is the noted exception,
as it may have to resolve TWO tokens (auth and subject).

Change-Id: I24e0a1e979d2aaedc6a25e378bd9d99f51ece595
2016-09-01 12:24:02 -07:00
Michael Krotscheck c98bc9cd23 Added loglevel
This patch adds loglevel back in as our logging framework, as
an assistatn for debugging the in/outbound HTTP requests.

Change-Id: I545e27f5c957f9c5c7a2dc73730b9db91600c1ce
2016-09-01 11:00:29 -07:00
Michael Krotscheck 2d61baca21 Added jsdoc3 output to doc generation
This patch adds jsdoc3-generated documentation to our docs build.
It does so by using publicly available sphinx.rst templates, writing
them into a .gitignore'd folder in the docs directory, and providing
references to these autogenerated documents in our own site.

There are some notable bugs:
- jsdoc-sphinx templates do not honor @ignore and @private
- jsdoc-sphinx templates do not ignore private variables (listed under
  members at the bottom).
- jsdoc-sphinx templates add superfluous 'Children' section to the
  top as subsection navigation.

It would make quite a bit of sense for us to contribute to
jsdoc-sphinx so that the above mentioned bugs are resolved. However,
as some documentation is better than no documentation, right now this
is fine.

Change-Id: I2905358a6410d5dace96c25dc57dda100fae4b48
2016-08-30 14:26:10 -07:00
Michael Krotscheck 7767d0183c Removed request and response interception.
The request/response interception has not yet been used, and
introduced quite a bit of complexity, especially surrounding fetchMock.
Furthermore, they made our DSVM tests fail, as the browser's implementation
of Request requires that a request body be accessed using the regular
json(), text(), etc. promise generators. Since this would have
simply added more complexity to an already complex, unused feature,
we've simply removed the feature.

Change-Id: I4cdf7b7106c771f0562de47e8835076d48d03a31
2016-08-30 14:22:52 -07:00
Michael Krotscheck a3bfae8976 Removed authenticate() method
Functionality is now available via tokenIssue() and catalogList().

Change-Id: I9871304694286d1d0f4f6c395074ebd6d8f2e2c8
2016-08-24 17:08:31 -07:00
Michael Krotscheck be86176883 Added catalogList() method to keystone API
Given a token, this method will return a promise which resolves to
the service catalog.

Change-Id: If1b7832f5e5e48902e0ef31d28384bb9aeab2fd5
2016-08-24 17:08:31 -07:00
Michael Krotscheck 558ceea566 Added tokenRevoke() method to keystone API.
This method permits the revocation of an auth token, whether by
the auth token itself, or by an admin token.

Change-Id: Ia80fd70986410b364351bffeaa5823a36d25d2cc
2016-08-24 17:08:31 -07:00
Michael Krotscheck 365f07cc0f Fixed header bug in fetchMock
Fetch-mock doesn't sanely match against a Headers() instance, whose
implementation varies due to isomorphic-fetch. Here we deconstruct the instance
back into a map, so that the actual fetch() request is properly handled.

Change-Id: Ie99ca23a6cf75c48c8762e7de36aee71ef819b7f
2016-08-24 17:08:31 -07:00
Michael Krotscheck d7de0cfb52 Added tokenIssue() method to keystone API.
This method handles sending an authorization request against the
keystone API, and returns the issued Authorization Token. At this
time it only supports the password authorization plugin. Additional
use cases should be provided by third-party developers.

It is the long term intent that this method will deprecate the
authorize() method, in order to provide a consistently idempotent
implementation.

Change-Id: If1368bcdae251606d2e03043345cd4fc6f0b8b80
2016-08-24 17:08:31 -07:00
Michael Krotscheck e86ebe7778 Keystone authenticate() now uses resolved service endpoint.
Authenticate is now called against an endpoint whose version is
known, and thus can be more easily supported.

Change-Id: I6e5dd64ac7ccc91d0a35630335f301377d87079c
2016-08-24 17:08:31 -07:00
Michael Krotscheck 5b2db185d7 Added serviceEndpoint() method.
This method will return the service endpoint of the current supported
keystone version.

Change-Id: I3af0faf5191b89cfd7a266edfe0bd044d6dd02ce
2016-08-24 17:08:31 -07:00
Michael Krotscheck f231326d83 Added version() resource.
This resource will attempt to resolve a supported API version from
the versions available on the Keystone API.

Change-Id: Icca49d3c124fb9526aa4316290b475d95cfda2ce
2016-08-24 17:08:29 -07:00
Michael Krotscheck 8ee9b24233 Created versions() resource for Keystone
This resource returns a (caching) promise, which will eventually
resolve to the list of versions published at the auth_url. It also
updates the unit tests to draw from a consolidated set of mock data.

Change-Id: I0d0de5b6ef6a1e3d1f5daa40a88ec3d799c43a64
2016-08-24 17:07:48 -07:00
Michael Krotscheck e96c828cd6 Removed loglevel
Removed dependency which we're not actually using for anything.

Change-Id: I4ced0fa4437b7c731c6a8c2e6bc7fa65be901820
2016-08-24 13:43:16 -07:00
Michael Krotscheck 528bccbf81 Http class now rejects 4xx and 5xx responses
This patch makes sure that successful HTTP requests, which result
in an error code, are passed to the catch() or reject handler, rather
than the success handler.

This results in two different cases in the claim() handler, that of
an internally thrown exception (like a TypeError), and that of a
Response() instance. In most cases, developers should not write
code that throws exceptions - and even in those, the ES6 Promise
API silently swallows most uncaught throws.

Change-Id: I736bcaccf6324a3d66191692e5f2ce922a727dea
2016-08-18 13:08:18 -07:00
Michael Krotscheck abd0508c30 Created HTTP wrapper
This utility class provides an abstraction layer for HTTP calls via fetch(). Its purpose is
to provide common, SDK-wide behavior for all HTTP requests. Included are:

- Providing a common extension point for request and response manipulation.
- Access to default headers.

In the future, this class chould also be extended to provide:

- Some form of progress() support for large uploads and downloads (perhaps via introduction of Q)
- Convenience decoding of the response body, depending on Content-Type.
- Internal error handling (At this time, HTTP errors are passed to then() rather than catch()).
- Other features.

Change-Id: I8173554b1b7ef052e2a74504b98f4ec574ce6136
2016-08-18 13:08:14 -07:00
Michael Krotscheck df77f84ecb Created Version Class
The version class allows us to parse, and compare, API version strings
as per the OpenStack API WG Microversion Specification. Several formats
are supported:

* v#.#.# (legacy)
* #.#.# (legacy)
* [service name] #.#.#

In the former two cases, a service type will have to be manually supplied
to ensure proper comparison.

https://specs.openstack.org/openstack/api-wg/guidelines/microversion_specification.html

Change-Id: If3596418dfe2e76489bdb48d4d15f7f3e7a6d2f9
2016-08-15 13:25:38 -07:00
Michael Krotscheck cee5a21bf2 Keystone constructor accepts only one cloud config
This patch modifies the keystone API constructor to accept only
one cloud config, rather than the entire cloud config object.

Change-Id: Ifc541aeff20e1a6b0e9815a91e93fc78989199de
2016-08-11 11:45:26 -07:00
msmol e09ccbd473 Added basic Keystone authentication
authenticate() is called outside the constructor
so that the Keystone class plays nicely with
Promises. (It would be weird for the constructor
to return a Promise)

Change-Id: I3f9008d4d954c340178c77ec0433c5a1ddc971d2
2016-08-06 09:38:01 -07:00
Michael Krotscheck 4e9cf48b43 Enabled fetch-mock with tests.
This patch adds the fetch-mock library, demonstrating how it may be
used to properly mock out API calls. An important change that was
made was the way that 'isomorphic-fetch' was included. Since
fetch-mock makes the assumption that only the window.fetch object
should be overridden, we cannot invoke it via a variable. Instead,
I've simply imported the library, which during import will override
global.fetch if necessary.

Change-Id: Ibd88b61595b4492f375294a8a08031a1a001a10c
2016-08-04 12:03:04 -07:00
Vitaly Kramskikh 1b9d90f7c0 Switch back from node-fetch to isomorphic-fetch
node-fetch utilizes Node.js standard library to work, so it
cannot be used in browsers. So we need to switch back to
isomorphic-fetch which works both in browsers and Node.js.

Change-Id: Idc8d18021a3226fb8339c99e3009dc53cbc15b2a
2016-07-25 12:55:52 +03:00