Bug 278 - Allow updating of NSD when there are instantiated network services
Signed-off-by: velandy <rajesh.velandy@riftio.com>
diff --git a/skyquake/plugins/composer/api/composer.js b/skyquake/plugins/composer/api/composer.js
index e9e4be1..93cc553 100644
--- a/skyquake/plugins/composer/api/composer.js
+++ b/skyquake/plugins/composer/api/composer.js
@@ -125,8 +125,7 @@
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"] = {};
@@ -134,9 +133,6 @@
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"];
});
}
}
@@ -487,7 +483,7 @@
}
/**
- * 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.
*/
diff --git a/skyquake/plugins/composer/src/src/components/CatalogItems.js b/skyquake/plugins/composer/src/src/components/CatalogItems.js
index 78a18e0..9b96bb5 100644
--- a/skyquake/plugins/composer/src/src/components/CatalogItems.js
+++ b/skyquake/plugins/composer/src/src/components/CatalogItems.js
@@ -88,8 +88,6 @@
const isOpenForEdit = d.uiState.isOpenForEdit;
const spanClassNames = ClassNames({'-is-selected': isSelected, '-is-open-for-edit': isOpenForEdit});
const sectionClassNames = ClassNames('catalog-item', {'-is-modified': isModified, '-is-deleted': isDeleted});
- const instanceCount = d.uiState['instance-ref-count'];
- const instanceCountLabel = isNSD && instanceCount ? <span>({instanceCount})</span> : null;
let type;
if(isNSD) {
type = 'nsd';
@@ -104,7 +102,7 @@
{isModified ? <div className="-is-modified-indicator" title="This descriptor has changes."></div> : null}
<div className="type-header">{type}</div>
<dl>
- <dt className="name">{d.name} {instanceCountLabel}</dt>
+ <dt className="name">{d.name}</dt>
<dd className="logo">
<img className="logo" src={cleanDataURI(d['logo'], type, d.id)} draggable="false" onError={self.handleImageError} />
</dd>
diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js
index ad2bf3d..651c40d 100644
--- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js
+++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js
@@ -324,7 +324,7 @@
// We stick in a string when the user actually sets it to simplify things
// but the correct thing happens when we serialize to user data
let isEmptyLeafPresent = (value === EMPTY_LEAF_PRESENT || value === null);
- let present = isEmptyLeafPresent ? EMPTY_LEAF_PRESENT : "";
+ let present = isEmptyLeafPresent ? EMPTY_LEAF_PRESENT : [null];
const options = [
<option key={'true'} value={EMPTY_LEAF_PRESENT}>Enabled</option>,
<option key={'false'} value="">Not Enabled</option>
diff --git a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js
index 06d1342..9179f21 100644
--- a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js
+++ b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js
@@ -57,7 +57,6 @@
UID.assignUniqueId(newItem.uiState);
newItem.uiState.isNew = true;
newItem.uiState.modified = true;
- newItem.uiState['instance-ref-count'] = 0;
}
return newItem;
}
@@ -189,7 +188,6 @@
});
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'];
@@ -197,10 +195,6 @@
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'];
@@ -319,17 +313,9 @@
// 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;
}
@@ -353,17 +339,9 @@
// 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;
});
@@ -415,27 +393,19 @@
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);
}
}
}
@@ -528,13 +498,6 @@
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) {
diff --git a/skyquake/plugins/launchpad/api/launchpad.js b/skyquake/plugins/launchpad/api/launchpad.js
index d74bb3e..4e288c3 100644
--- a/skyquake/plugins/launchpad/api/launchpad.js
+++ b/skyquake/plugins/launchpad/api/launchpad.js
@@ -266,8 +266,7 @@
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"] = {};
@@ -275,9 +274,6 @@
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"];
nsd["constituent-vnfd"] && nsd["constituent-vnfd"].map(function(v) {
v.name = vnfdDict[v["vnfd-id-ref"]];
})