3 * STANDARD_RIFT_IO_COPYRIGHT
5 import NS_ACTIONS from './launchNetworkServiceActions.js';
6 import $ from 'jquery';
7 let Utils = require('utils/utils.js');
8 let rw = require('utils/rw.js');
9 const API_SERVER = require('utils/rw.js').getSearchParams(window.location).api_server;
10 const API_PORT = require('utils/rw.js').getSearchParams(window.location).api_port;
11 const NODE_PORT = API_PORT || 3000;
16 return new Promise((resolve,reject) => {
18 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
20 beforeSend: Utils.addAuthorizationStub,
21 success: function (data) {
23 typeof(data) == "string" ? JSON.parse(data):data
26 }).fail(function(xhr){
28 //Authentication and the handling of fail states should be wrapped up into a connection class.
29 Utils.checkAuthentication(xhr.status);
33 success: NS_ACTIONS.getCatalogSuccess,
34 error: NS_ACTIONS.getCatalogError
40 return new Promise((resolve, reject) => {
42 url: '//' + window.location.hostname + ':' +
43 NODE_PORT + '/launchpad/cloud-account?api_server=' +
46 beforeSend: Utils.addAuthorizationStub,
47 success: function (data) {
56 success: NS_ACTIONS.getCloudAccountSuccess,
57 error: NS_ACTIONS.getCloudAccountError
63 return new Promise((resolve, reject) => {
65 url: '//' + window.location.hostname + ':' +
66 NODE_PORT + '/launchpad/data-centers?api_server=' +
69 beforeSend: Utils.addAuthorizationStub,
70 success: function (data) {
76 success: NS_ACTIONS.getDataCentersSuccess,
77 error: NS_ACTIONS.getDataCentersError
82 remote (state, VNFDid) {
83 return new Promise((resolve,reject) => {
85 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/vnfd?api_server=' + API_SERVER,
87 beforeSend: Utils.addAuthorizationStub,
92 success: function (data) {
94 typeof(data) == "string" ? JSON.parse(data):data
100 success: NS_ACTIONS.getVDUSuccess,
101 error: NS_ACTIONS.getVDUError
106 remote (state, NSR) {
107 return new Promise((resolve, reject) => {
108 console.log('Attempting to instantiate NSR:', NSR)
110 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsr?api_server=' + API_SERVER,
112 beforeSend: Utils.addAuthorizationStub,
117 success: function (data) {
119 typeof(data) == "string" ? JSON.parse(data):data
122 error: function (err) {
128 loading: NS_ACTIONS.launchNSRLoading,
129 success: NS_ACTIONS.launchNSRSuccess,
130 error: NS_ACTIONS.launchNSRError
135 remote(state, NSDId) {
136 return new Promise((resolve, reject) => {
138 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/nsd/' + NSDId + '/input-param?api_server=' + API_SERVER,
140 beforeSend: Utils.addAuthorizationStub,
141 success: function (data) {
149 getLaunchpadConfig: function() {
152 return new Promise(function(resolve, reject) {
154 url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/config?api_server=' + API_SERVER,
156 beforeSend: Utils.addAuthorizationStub,
157 success: function(data) {
163 success: NS_ACTIONS.getLaunchpadConfigSuccess,
164 error: NS_ACTIONS.getLaunchpadConfigError
170 // return new Promise((resolve,reject) => {
172 // url: '//' + window.location.hostname + ':' + NODE_PORT + '/launchpad/catalog?api_server=' + API_SERVER,
173 // success: function (data) {
175 // typeof(data) == "string" ? JSON.parse(data):data
181 // success: NS_ACTIONS.getCatalogSuccess,
182 // error: NS_ACTIONS.getCatalogError