/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
var Accounts = {};
var nameSpace = {
cloud: 'cloud',
- sdn: 'sdn-account',
+ sdn: 'sdn',
'config-agent': 'config-agent'
};
Accounts.get = function(req) {
var id = req.params.id || req.params.name;
var requestHeaders = {};
var type = nameSpace[req.params.type];
- var url = utils.confdPort(api_server) + '/api/operational/' + type;
- //SDN model doesn't follow convention
- if (type != 'sdn-account') {
- url += '/account';
- }
+ var url = utils.confdPort(api_server) + '/api/operational/' + type + '/account';
if (id) {
url += '/' + id;
}
var data;
var objKey = 'rw-' + type + ':account';
//SDN model doesn't follow convention
- if (type == 'sdn-account') {
- objKey = 'rw-sdn:sdn-account';
- }
if (utils.validateResponse(type.toUpperCase() + '.get', error, response, body, resolve, reject)) {
try {
data = JSON.parse(response.body);
if (!id) {
data = data.collection;
}
-
data = data[objKey]
} catch (e) {
console.log('Problem with "' + type.toUpperCase() + '.get"', e);
var url = utils.confdPort(api_server) + '/api/config/' + type;
var method = 'POST'
if (!id) {
- if (type == 'sdn-account') {
- createData = {
- 'sdn-account': Array.isArray(data) ? data : [data]
- }
- } else {
- createData = {
- 'account': Array.isArray(data) ? data : [data]
- }
+ createData = {
+ 'account': Array.isArray(data) ? data : [data]
}
console.log('Creating ' + type + ' account: ', createData);
} else {
method = 'PUT';
- if (type == 'sdn-account') {
- url += '/' + id;
- createData['rw-sdn:sdn-account'] = Array.isArray(data) ? data : [data];
-
- } else {
- url += '/account/' + id;
- createData['rw-' + type + ':account'] = Array.isArray(data) ? data : [data];
- }
- //createData = createData[0];
+ url += '/account/' + id;
+ createData['rw-' + type + ':account'] = Array.isArray(data) ? data : [data];
}
var requestHeaders = {};
var createData = {};
var url = utils.confdPort(api_server) + '/api/config/' + type;
- if (type == 'sdn-account') {
- url += '/' + id;
- } else {
- url += '/account/' + id;
- }
+ url += '/account/' + id;
return new Promise(function(resolve, reject) {
_.extend(requestHeaders,
constants.HTTP_HEADERS.accept.data,
/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
'Authorization': req.get('Authorization')
});
request({
- url: utils.confdPort(api_server) + '/api/operational/sdn-account?deep',
+ url: utils.confdPort(api_server) + '/api/operational/sdn/account?deep',
type: 'GET',
headers: requestHeaders,
forever: constants.FOREVER_ON,
var data;
if (utils.validateResponse('Sdn.get', error, response, body, resolve, reject)) {
try {
- data = JSON.parse(response.body).collection['rw-sdn:sdn-account']
+ data = JSON.parse(response.body).collection['rw-sdn:account']
} catch (e) {
console.log('Problem with "Sdn.get"', e);
});
request({
- url: utils.confdPort(api_server) + '/api/operational/sdn-account/' + id + '?deep',
+ url: utils.confdPort(api_server) + '/api/operational/sdn/account/' + id + '?deep',
type: 'GET',
headers: requestHeaders,
forever: constants.FOREVER_ON,
var data;
if (utils.validateResponse('Sdn.get', error, response, body, resolve, reject)) {
try {
- data = JSON.parse(response.body)['rw-sdn:sdn-account'];
+ data = JSON.parse(response.body)['rw-sdn:sdn'];
} catch (e) {
console.log('Problem with "Sdn.get"', e);
});
request({
- url: utils.confdPort(api_server) + '/api/config/sdn-account',
+ url: utils.confdPort(api_server) + '/api/config/sdn/account',
method: 'POST',
headers: requestHeaders,
forever: constants.FOREVER_ON,
return new Promise(function(resolve, reject) {
var jsonData = {
- "rw-sdn:sdn-account": data
+ "rw-sdn:sdn": data
};
console.log('Updating SDN account ', id, ' with', JSON.stringify(jsonData));
});
request({
- url: utils.confdPort(api_server) + '/api/config/sdn-account/' + id,
+ url: utils.confdPort(api_server) + '/api/config/sdn/account/' + id,
method: 'PUT',
headers: requestHeaders,
forever: constants.FOREVER_ON,
});
request({
- url: utils.confdPort(api_server) + '/api/config/sdn-account/' + id,
+ url: utils.confdPort(api_server) + '/api/config/sdn/account/' + id,
method: 'DELETE',
headers: requestHeaders,
forever: constants.FOREVER_ON,
<div className="accountForm-content" style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
<div style={{display: 'flex', justifyContent: 'space-between', alignItems: 'center'}}>
<AccountConnectivityStatus status={Account['connection-status'].status} />
- {Account['connection-status'].status.toUpperCase()}
+ {Account['connection-status'] && Account['connection-status'].status && Account['connection-status'].status.toUpperCase()}
</div>
<Button className="refreshList light" onClick={this.props.store.refreshAccount.bind(this, Account.name, AccountType)} label="REFRESH STATUS"></Button>
</div>
{
- Account['connection-status'].status.toUpperCase() === 'FAILURE' ?
+ (Account['connection-status'] && Account['connection-status'].status && Account['connection-status'].status.toUpperCase()) === 'FAILURE' ?
displayFailureMessage(Account['connection-status'].details) : null
}
</div>
}
generateOptionsByName(data) {
let results = [];
- if (data.constructor.name == "Array") {
+ if (data && data.constructor.name == "Array") {
data.map(function(d) {
results.push({
label: d.name,
let newState = {
dataCenters: dataCenters || []
};
- if (this.ro['account-type'] == 'openmano') {
+ if (this.state.ro && this.state.ro['account-type'] == 'openmano') {
newState.dataCenterID = dataCenters[this.ro.name][0].uuid
}
this.setState(newState)