response[0].descriptors = JSON.parse(result[0].body).collection['nsd:nsd'];
if (result[2].body) {
var data = JSON.parse(result[2].body);
- if (data && data["nsr:ns-instance-opdata"] && data["nsr:ns-instance-opdata"]["rw-nsr:nsd-ref-count"]) {
- var nsdRefCountCollection = data["nsr:ns-instance-opdata"]["rw-nsr:nsd-ref-count"];
+ if (data && data["nsr:ns-instance-opdata"]) {
response[0].descriptors.map(function(nsd) {
if (!nsd["meta"]) {
nsd["meta"] = {};
if (typeof nsd['meta'] == 'string') {
nsd['meta'] = JSON.parse(nsd['meta']);
}
- nsd["meta"]["instance-ref-count"] = _.findWhere(nsdRefCountCollection, {
- "nsd-id-ref": nsd.id
- })["instance-ref-count"];
});
}
}
}
/**
- * This methods retrieves the status of package operations. It takes an optional
+ * This methods retrieves the status of package operations. It takes an optional
* transaction id (id) this if present will return only that status otherwise
* an array of status' will be response.
*/
UID.assignUniqueId(newItem.uiState);
newItem.uiState.isNew = true;
newItem.uiState.modified = true;
- newItem.uiState['instance-ref-count'] = 0;
}
return newItem;
}
});
updatedCatalogs.filter(d => d.type === 'nsd').forEach(catalog => {
catalog.descriptors = catalog.descriptors.map(descriptor => {
- const instanceRefCount = parseInt(descriptor.uiState['instance-ref-count'], 10);
if (descriptor['constituent-vnfd']) {
descriptor.vnfd = descriptor['constituent-vnfd'].map(d => {
const vnfdId = d['vnfd-id-ref'];
if (!vnfd) {
throw new ReferenceError('no VNFD found in the VNFD Catalog for the constituent-vnfd: ' + d);
}
- if (!isNaN(instanceRefCount) && instanceRefCount > 0) {
- // this will notify user that this item cannot be updated when/if they make a change to it
- vnfd.uiState['instance-ref-count'] = instanceRefCount;
- }
// create an instance of this vnfd to carry transient ui state properties
const instance = _cloneDeep(vnfd);
instance.uiState['member-vnf-index'] = d['member-vnf-index'];
// compare just the catalog uiState data (id, name, short-name, description, etc.)
const modified = !areCatalogItemsMetaDataEqual(d, item);
if (modified) {
- if (d.uiState['instance-ref-count'] > 0) {
- console.log('cannot edit NSD/VNFD with references to instantiated Network Services');
- ComposerAppActions.showError.defer({
- errorMessage: 'Cannot edit NSD/VNFD with references to instantiated Network Services'
- });
- return _cloneDeep(d);
- } else {
- item.uiState.modified = modified;
- requiresSave = true;
- this.addSnapshot(item);
- }
+ item.uiState.modified = modified;
+ requiresSave = true;
+ this.addSnapshot(item);
}
return item;
}
// replace the old descriptor with the updated one
catalog.descriptors = catalog.descriptors.map(d => {
if (d.id === descriptorId) {
- if (d.uiState['instance-ref-count'] > 0) {
- console.log('cannot edit NSD/VNFD with references to instantiated Network Services');
- ComposerAppActions.showError.defer({
- errorMessage: 'Cannot edit NSD/VNFD with references to instantiated Network Services'
- });
- return _cloneDeep(d);
- } else {
- itemDescriptor.model.uiState.modified = true;
- this.addSnapshot(itemDescriptor.model);
- return itemDescriptor.model;
- }
+ itemDescriptor.model.uiState.modified = true;
+ this.addSnapshot(itemDescriptor.model);
+ return itemDescriptor.model;
}
return d;
});
if (item.uiState.isNew) {
CatalogDataStore.confirmDelete(remove, confirmDeleteCancel);
} else {
- if (item.uiState['instance-ref-count'] > 0) {
- console.log('cannot delete NSD/VNFD with references to instantiated Network Services');
- ComposerAppActions.showError.defer({
- errorMessage: 'Cannot delete NSD/VNFD with references to instantiated Network Services'
- });
- undo();
- } else {
- const confirmDeleteOK = event => {
- event.preventDefault();
- item.uiState.deleted = true;
- this.setState({catalogs: this.getCatalogs()});
- ModalOverlayActions.showModalOverlay.defer();
- this.getInstance().deleteCatalogItem(item.uiState.type, item.id)
- .then(remove, undo)
- .then(ModalOverlayActions.hideModalOverlay, ModalOverlayActions.hideModalOverlay)
- .catch(function() {
- console.log('overcoming ES6 unhandled rejection red herring');
- });
- };
- CatalogDataStore.confirmDelete(confirmDeleteOK, confirmDeleteCancel);
- }
+ const confirmDeleteOK = event => {
+ event.preventDefault();
+ item.uiState.deleted = true;
+ this.setState({catalogs: this.getCatalogs()});
+ ModalOverlayActions.showModalOverlay.defer();
+ this.getInstance().deleteCatalogItem(item.uiState.type, item.id)
+ .then(remove, undo)
+ .then(ModalOverlayActions.hideModalOverlay, ModalOverlayActions.hideModalOverlay)
+ .catch(function() {
+ console.log('overcoming ES6 unhandled rejection red herring');
+ });
+ };
+ CatalogDataStore.confirmDelete(confirmDeleteOK, confirmDeleteCancel);
}
}
}
saveItem(item) {
if (item) {
- if (item.uiState['instance-ref-count'] > 0) {
- console.log('cannot save NSD/VNFD with references to instantiated Network Services');
- ComposerAppActions.showError.defer({
- errorMessage: 'Cannot save NSD/VNFD with references to instantiated Network Services'
- });
- return;
- }
const success = () => {
delete item.uiState.modified;
if (item.uiState.isNew) {