mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	CLOUDSTACK-2569: UI > Infrastructure menu > zone > physical network > network service providers > Cisco VNMC > If Cisco VNMC provider doesn't exist, show Add action and hide enable, disable action.
This commit is contained in:
		
							parent
							
								
									57623832b0
								
							
						
					
					
						commit
						9fb71c30a8
					
				| @ -14,28 +14,30 @@ | |||||||
| // KIND, either express or implied.  See the License for the
 | // KIND, either express or implied.  See the License for the
 | ||||||
| // specific language governing permissions and limitations
 | // specific language governing permissions and limitations
 | ||||||
| // under the License.
 | // under the License.
 | ||||||
| (function($, cloudStack) { | (function ($, cloudStack) { | ||||||
|   cloudStack.modules.vnmcNetworkProvider = function(module) { |     cloudStack.modules.vnmcNetworkProvider = function (module) { | ||||||
|     var vnmcDeviceViewAll = window._m = [ |         var vnmcDeviceViewAll = window._m = [{ | ||||||
|       { |  | ||||||
|             label: 'VNMC Devices', |             label: 'VNMC Devices', | ||||||
|             path: '_zone.vnmcDevices' |             path: '_zone.vnmcDevices' | ||||||
|       } |         }]; | ||||||
|     ]; |  | ||||||
| 
 | 
 | ||||||
|         var vnmcListView = { |         var vnmcListView = { | ||||||
|             id: 'vnmcDevices', |             id: 'vnmcDevices', | ||||||
|             fields: { |             fields: { | ||||||
|         resourcename: { label: 'Resource Name' }, |                 resourcename: { | ||||||
|         provider: { label: 'Provider' } |                     label: 'Resource Name' | ||||||
|                 }, |                 }, | ||||||
|       dataProvider: function(args) { |                 provider: { | ||||||
|  |                     label: 'Provider' | ||||||
|  |                 } | ||||||
|  |             }, | ||||||
|  |             dataProvider: function (args) { | ||||||
|                 $.ajax({ |                 $.ajax({ | ||||||
|                     url: createURL('listCiscoVnmcResources'), |                     url: createURL('listCiscoVnmcResources'), | ||||||
|                     data: { |                     data: { | ||||||
|                         physicalnetworkid: args.context.physicalNetworks[0].id |                         physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                     }, |                     }, | ||||||
|           success: function(json){ |                     success: function (json) { | ||||||
|                         var items = json.listCiscoVnmcResources.CiscoVnmcResource; |                         var items = json.listCiscoVnmcResources.CiscoVnmcResource; | ||||||
|                         args.response.success({ |                         args.response.success({ | ||||||
|                             data: items |                             data: items | ||||||
| @ -48,7 +50,7 @@ | |||||||
|                     label: 'Add VNMC device', |                     label: 'Add VNMC device', | ||||||
| 
 | 
 | ||||||
|                     messages: { |                     messages: { | ||||||
|             notification: function(args) { |                         notification: function (args) { | ||||||
|                             return 'Add VNMC device'; |                             return 'Add VNMC device'; | ||||||
|                         } |                         } | ||||||
|                     }, |                     }, | ||||||
| @ -58,69 +60,71 @@ | |||||||
|                         fields: { |                         fields: { | ||||||
|                             hostname: { |                             hostname: { | ||||||
|                                 label: 'label.host', |                                 label: 'label.host', | ||||||
|                 validation: { required: true } |                                 validation: { | ||||||
|  |                                     required: true | ||||||
|  |                                 } | ||||||
|                             }, |                             }, | ||||||
|                             username: { |                             username: { | ||||||
|                                 label: 'label.username', |                                 label: 'label.username', | ||||||
|                 validation: { required: true } |                                 validation: { | ||||||
|  |                                     required: true | ||||||
|  |                                 } | ||||||
|                             }, |                             }, | ||||||
|                             password: { |                             password: { | ||||||
|                                 label: 'label.password', |                                 label: 'label.password', | ||||||
|                                 isPassword: true, |                                 isPassword: true, | ||||||
|                 validation: { required: true } |                                 validation: { | ||||||
|  |                                     required: true | ||||||
|  |                                 } | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|           action: function(args) { |                     action: function (args) { | ||||||
|                         $.ajax({ |                         $.ajax({ | ||||||
|                             url: createURL('listNetworkServiceProviders'), |                             url: createURL('listNetworkServiceProviders'), | ||||||
|                             data: { |                             data: { | ||||||
|                                 name: 'CiscoVnmc', |                                 name: 'CiscoVnmc', | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id |                                 physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                             }, |                             }, | ||||||
|               success: function(json){ |                             success: function (json) { | ||||||
|                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; |                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; | ||||||
|                 if(items != null && items.length > 0) { |                                 if (items != null && items.length > 0) { | ||||||
|                                     var ciscoVnmcProvider = items[0]; |                                     var ciscoVnmcProvider = items[0]; | ||||||
|                   if(ciscoVnmcProvider.state == 'Enabled') { |                                     if (ciscoVnmcProvider.state == 'Enabled') { | ||||||
|                                         addCiscoVnmcResourceFn(); |                                         addCiscoVnmcResourceFn(); | ||||||
|                   } |                                     } else { | ||||||
|                   else { |  | ||||||
|                                         enableCiscoVnmcProviderFn(ciscoVnmcProvider); |                                         enableCiscoVnmcProviderFn(ciscoVnmcProvider); | ||||||
|                                     } |                                     } | ||||||
|                 } |                                 } else { | ||||||
|                 else { |  | ||||||
|                                     $.ajax({ |                                     $.ajax({ | ||||||
|                                         url: createURL("addNetworkServiceProvider"), |                                         url: createURL("addNetworkServiceProvider"), | ||||||
|                                         data: { |                                         data: { | ||||||
|                                             name: 'CiscoVnmc', |                                             name: 'CiscoVnmc', | ||||||
|                                             physicalnetworkid: args.context.physicalNetworks[0].id |                                             physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                                         }, |                                         }, | ||||||
|                     success: function(json) { |                                         success: function (json) { | ||||||
|                                             var jobId = json.addnetworkserviceproviderresponse.jobid; |                                             var jobId = json.addnetworkserviceproviderresponse.jobid; | ||||||
|                       var addVnmcProviderIntervalID = setInterval(function() { |                                             var addVnmcProviderIntervalID = setInterval(function () { | ||||||
|                                                 $.ajax({ |                                                 $.ajax({ | ||||||
|                           url: createURL("queryAsyncJobResult&jobId="+jobId), |                                                     url: createURL("queryAsyncJobResult&jobId=" + jobId), | ||||||
|                                                     dataType: "json", |                                                     dataType: "json", | ||||||
|                           success: function(json) { |                                                     success: function (json) { | ||||||
|                                                         var result = json.queryasyncjobresultresponse; |                                                         var result = json.queryasyncjobresultresponse; | ||||||
|                                                         if (result.jobstatus == 0) { |                                                         if (result.jobstatus == 0) { | ||||||
|                                                             return; //Job has not completed
 |                                                             return; //Job has not completed
 | ||||||
|                             } |                                                         } else { | ||||||
|                             else { |                                                             clearInterval(addVnmcProviderIntervalID); | ||||||
|                               clearInterval(addVnmcProviderIntervalID ); |  | ||||||
|                                                             if (result.jobstatus == 1) { |                                                             if (result.jobstatus == 1) { | ||||||
|                                                                 //nspMap["CiscoVnmc"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
 |                                                                 //nspMap["CiscoVnmc"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;
 | ||||||
|                                                                 var ciscoVnmcProvider = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; |                                                                 var ciscoVnmcProvider = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; | ||||||
|                                                                 enableCiscoVnmcProviderFn(ciscoVnmcProvider); |                                                                 enableCiscoVnmcProviderFn(ciscoVnmcProvider); | ||||||
|                               } |                                                             } else if (result.jobstatus == 2) { | ||||||
|                               else if (result.jobstatus == 2) { |  | ||||||
|                                                                 args.response.error(_s(result.jobresult.errortext)); |                                                                 args.response.error(_s(result.jobresult.errortext)); | ||||||
|                                                             } |                                                             } | ||||||
|                                                         } |                                                         } | ||||||
|                                                     }, |                                                     }, | ||||||
|                           error: function(XMLHttpResponse) { |                                                     error: function (XMLHttpResponse) { | ||||||
|                                                         args.response.error(parseXMLHttpResponse(data)); |                                                         args.response.error(parseXMLHttpResponse(data)); | ||||||
|                                                     } |                                                     } | ||||||
|                                                 }); |                                                 }); | ||||||
| @ -131,32 +135,30 @@ | |||||||
|                             } |                             } | ||||||
|                         }); |                         }); | ||||||
| 
 | 
 | ||||||
|             var enableCiscoVnmcProviderFn = function(ciscoVnmcProvider){ |                         var enableCiscoVnmcProviderFn = function (ciscoVnmcProvider) { | ||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('updateNetworkServiceProvider'), |                                 url: createURL('updateNetworkServiceProvider'), | ||||||
|                                 data: { |                                 data: { | ||||||
|                                     id: ciscoVnmcProvider.id, |                                     id: ciscoVnmcProvider.id, | ||||||
|                                     state: 'Enabled' |                                     state: 'Enabled' | ||||||
|                                 }, |                                 }, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var jid = json.updatenetworkserviceproviderresponse.jobid; |                                     var jid = json.updatenetworkserviceproviderresponse.jobid; | ||||||
|                   var enableVnmcProviderIntervalID = setInterval(function(){ |                                     var enableVnmcProviderIntervalID = setInterval(function () { | ||||||
|                                         $.ajax({ |                                         $.ajax({ | ||||||
|                                             url: createURL('queryAsyncJobResult'), |                                             url: createURL('queryAsyncJobResult'), | ||||||
|                                             data: { |                                             data: { | ||||||
|                                                 jobid: jid |                                                 jobid: jid | ||||||
|                                             }, |                                             }, | ||||||
|                       success: function(json){ |                                             success: function (json) { | ||||||
|                                                 var result = json.queryasyncjobresultresponse; |                                                 var result = json.queryasyncjobresultresponse; | ||||||
|                                                 if (result.jobstatus == 0) { |                                                 if (result.jobstatus == 0) { | ||||||
|                                                     return; //Job has not completed
 |                                                     return; //Job has not completed
 | ||||||
|                         } |                                                 } else { | ||||||
|                         else { |  | ||||||
|                                                     clearInterval(enableVnmcProviderIntervalID); |                                                     clearInterval(enableVnmcProviderIntervalID); | ||||||
|                                                     if (result.jobstatus == 1) { |                                                     if (result.jobstatus == 1) { | ||||||
|                                                         addCiscoVnmcResourceFn(); |                                                         addCiscoVnmcResourceFn(); | ||||||
|                           } |                                                     } else if (result.jobstatus == 2) { | ||||||
|                           else if (result.jobstatus == 2) { |  | ||||||
|                                                         args.response.error(_s(result.jobresult.errortext)); |                                                         args.response.error(_s(result.jobresult.errortext)); | ||||||
|                                                     } |                                                     } | ||||||
|                                                 } |                                                 } | ||||||
| @ -167,7 +169,7 @@ | |||||||
|                             }); |                             }); | ||||||
|                         }; |                         }; | ||||||
| 
 | 
 | ||||||
|             var addCiscoVnmcResourceFn = function(){ |                         var addCiscoVnmcResourceFn = function () { | ||||||
|                             var data = { |                             var data = { | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id, |                                 physicalnetworkid: args.context.physicalNetworks[0].id, | ||||||
|                                 hostname: args.data.hostname, |                                 hostname: args.data.hostname, | ||||||
| @ -178,11 +180,13 @@ | |||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('addCiscoVnmcResource'), |                                 url: createURL('addCiscoVnmcResource'), | ||||||
|                                 data: data, |                                 data: data, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; |                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; | ||||||
|                   args.response.success({data: item}); |                                     args.response.success({ | ||||||
|  |                                         data: item | ||||||
|  |                                     }); | ||||||
|                                 }, |                                 }, | ||||||
|                 error: function(data) { |                                 error: function (data) { | ||||||
|                                     args.response.error(parseXMLHttpResponse(data)); |                                     args.response.error(parseXMLHttpResponse(data)); | ||||||
|                                 } |                                 } | ||||||
|                             }); |                             }); | ||||||
| @ -190,7 +194,7 @@ | |||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|                     notification: { |                     notification: { | ||||||
|             poll: function(args) { |                         poll: function (args) { | ||||||
|                             args.complete(); |                             args.complete(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -203,29 +207,29 @@ | |||||||
|                     remove: { |                     remove: { | ||||||
|                         label: 'delete CiscoVNMC resource', |                         label: 'delete CiscoVNMC resource', | ||||||
|                         messages: { |                         messages: { | ||||||
|               confirm: function(args) { |                             confirm: function (args) { | ||||||
|                                 return 'Please confirm you want to delete CiscoVNMC resource'; |                                 return 'Please confirm you want to delete CiscoVNMC resource'; | ||||||
|                             }, |                             }, | ||||||
|               notification: function(args) { |                             notification: function (args) { | ||||||
|                                 return 'delete CiscoVNMC resource'; |                                 return 'delete CiscoVNMC resource'; | ||||||
|                             } |                             } | ||||||
|                         }, |                         }, | ||||||
|             action: function(args) { |                         action: function (args) { | ||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('deleteCiscoVnmcResource'), |                                 url: createURL('deleteCiscoVnmcResource'), | ||||||
|                                 data: { |                                 data: { | ||||||
|                                     resourceid: args.context.vnmcDevices[0].resourceid |                                     resourceid: args.context.vnmcDevices[0].resourceid | ||||||
|                                 }, |                                 }, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     args.response.success(); |                                     args.response.success(); | ||||||
|                                 }, |                                 }, | ||||||
|                 error: function(data) { |                                 error: function (data) { | ||||||
|                                     args.response.error(parseXMLHttpResponse(data)); |                                     args.response.error(parseXMLHttpResponse(data)); | ||||||
|                                 } |                                 } | ||||||
|                             }); |                             }); | ||||||
|                         }, |                         }, | ||||||
|                         notification: { |                         notification: { | ||||||
|               poll: function(args) { |                             poll: function (args) { | ||||||
|                                 args.complete(); |                                 args.complete(); | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
| @ -235,23 +239,28 @@ | |||||||
|                 tabs: { |                 tabs: { | ||||||
|                     details: { |                     details: { | ||||||
|                         title: 'label.details', |                         title: 'label.details', | ||||||
|             fields: [ |                         fields: [{ | ||||||
|              { |                             resourcename: { | ||||||
|                resourcename: { label: 'Resource Name' } |                                 label: 'Resource Name' | ||||||
|              }, |  | ||||||
|              { |  | ||||||
|                resourceid: { label: 'Resource ID'}, |  | ||||||
|                provider: { label: 'Provider' }, |  | ||||||
|                RESOURCE_NAME: { label: 'Resource Name'} |  | ||||||
|                             } |                             } | ||||||
|            ], |                         }, { | ||||||
|            dataProvider: function(args) { |                             resourceid: { | ||||||
|  |                                 label: 'Resource ID' | ||||||
|  |                             }, | ||||||
|  |                             provider: { | ||||||
|  |                                 label: 'Provider' | ||||||
|  |                             }, | ||||||
|  |                             RESOURCE_NAME: { | ||||||
|  |                                 label: 'Resource Name' | ||||||
|  |                             } | ||||||
|  |                         }], | ||||||
|  |                         dataProvider: function (args) { | ||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('listCiscoVnmcResources'), |                                 url: createURL('listCiscoVnmcResources'), | ||||||
|                                 data: { |                                 data: { | ||||||
|                                     resourceid: args.context.vnmcDevices[0].resourceid |                                     resourceid: args.context.vnmcDevices[0].resourceid | ||||||
|                                 }, |                                 }, | ||||||
|                success: function(json){ |                                 success: function (json) { | ||||||
|                                     var item = json.listCiscoVnmcResources.CiscoVnmcResource[0]; |                                     var item = json.listCiscoVnmcResources.CiscoVnmcResource[0]; | ||||||
|                                     args.response.success({ |                                     args.response.success({ | ||||||
|                                         data: item |                                         data: item | ||||||
| @ -269,28 +278,78 @@ | |||||||
|             label: 'VNMC', |             label: 'VNMC', | ||||||
|             viewAll: vnmcDeviceViewAll, |             viewAll: vnmcDeviceViewAll, | ||||||
|             actions: { |             actions: { | ||||||
|  |             	add: { | ||||||
|  |             		label: 'Add VNMC provider', | ||||||
|  | 
 | ||||||
|  |                     messages: { | ||||||
|  |                         confirm: function (args) { | ||||||
|  |                             return 'Please confirm you would like to add the VNMC provider.'; | ||||||
|  |                         }, | ||||||
|  |                         notification: function (args) { | ||||||
|  |                             return 'Add VNMC device'; | ||||||
|  |                         } | ||||||
|  |                     }, | ||||||
|  | 
 | ||||||
|  |                     action: function (args) {       | ||||||
|  |                     	$.ajax({ | ||||||
|  |                             url: createURL("addNetworkServiceProvider"), | ||||||
|  |                             data: { | ||||||
|  |                                 name: 'CiscoVnmc', | ||||||
|  |                                 physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|  |                             }, | ||||||
|  |                             success: function (json) {                            	 | ||||||
|  |                                 var jobId = json.addnetworkserviceproviderresponse.jobid; | ||||||
|  |                                 var addVnmcProviderIntervalID = setInterval(function () { | ||||||
|  |                                     $.ajax({ | ||||||
|  |                                         url: createURL("queryAsyncJobResult&jobId=" + jobId), | ||||||
|  |                                         dataType: "json", | ||||||
|  |                                         success: function (json) { | ||||||
|  |                                             var result = json.queryasyncjobresultresponse; | ||||||
|  |                                             if (result.jobstatus == 0) { | ||||||
|  |                                                 return; //Job has not completed
 | ||||||
|  |                                             } else { | ||||||
|  |                                                 clearInterval(addVnmcProviderIntervalID); | ||||||
|  |                                                 if (result.jobstatus == 1) {                                                     | ||||||
|  |                                                     var item = json.queryasyncjobresultresponse.jobresult.networkserviceprovider;         | ||||||
|  |                                                     args.response.success({ | ||||||
|  |                                                         data: item | ||||||
|  |                                                     });                                                     | ||||||
|  |                                                 } else if (result.jobstatus == 2) { | ||||||
|  |                                                     args.response.error(_s(result.jobresult.errortext)); | ||||||
|  |                                                 } | ||||||
|  |                                             } | ||||||
|  |                                         }, | ||||||
|  |                                         error: function (XMLHttpResponse) { | ||||||
|  |                                             args.response.error(parseXMLHttpResponse(data)); | ||||||
|  |                                         } | ||||||
|  |                                     }); | ||||||
|  |                                 }, g_queryAsyncJobResultInterval); | ||||||
|  |                             } | ||||||
|  |                         });                    	 | ||||||
|  |                     } | ||||||
|  |             	}, | ||||||
|                 enable: { |                 enable: { | ||||||
|                     label: 'Enable VNMC provider', |                     label: 'Enable VNMC provider', | ||||||
| 
 | 
 | ||||||
|                     messages: { |                     messages: { | ||||||
|             confirm: function(args) { |                         confirm: function (args) { | ||||||
|                             return 'Please confirm you would like to enable the VNMC provider.'; |                             return 'Please confirm you would like to enable the VNMC provider.'; | ||||||
|                         }, |                         }, | ||||||
|             notification: function(args) { |                         notification: function (args) { | ||||||
|                             return 'Enable VNMC device'; |                             return 'Enable VNMC device'; | ||||||
|                         } |                         } | ||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|           action: function(args) { |                     action: function (args) { | ||||||
|                         $.ajax({ |                         $.ajax({ | ||||||
|                             url: createURL('listNetworkServiceProviders'), |                             url: createURL('listNetworkServiceProviders'), | ||||||
|                             data: { |                             data: { | ||||||
|                                 name: 'CiscoVnmc', |                                 name: 'CiscoVnmc', | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id |                                 physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                             }, |                             }, | ||||||
|               success: function(json){ |                             success: function (json) { | ||||||
|                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; |                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; | ||||||
|                 if(items != null && items.length > 0) { |                                 if (items != null && items.length > 0) { | ||||||
|                                     var ciscoVnmcProvider = items[0]; |                                     var ciscoVnmcProvider = items[0]; | ||||||
| 
 | 
 | ||||||
|                                     enableCiscoVnmcProviderFn(ciscoVnmcProvider); |                                     enableCiscoVnmcProviderFn(ciscoVnmcProvider); | ||||||
| @ -300,31 +359,33 @@ | |||||||
|                             } |                             } | ||||||
|                         }); |                         }); | ||||||
| 
 | 
 | ||||||
|             var enableCiscoVnmcProviderFn = function(ciscoVnmcProvider){ |                         var enableCiscoVnmcProviderFn = function (ciscoVnmcProvider) { | ||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('updateNetworkServiceProvider'), |                                 url: createURL('updateNetworkServiceProvider'), | ||||||
|                                 data: { |                                 data: { | ||||||
|                                     id: ciscoVnmcProvider.id, |                                     id: ciscoVnmcProvider.id, | ||||||
|                                     state: 'Enabled' |                                     state: 'Enabled' | ||||||
|                                 }, |                                 }, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var jid = json.updatenetworkserviceproviderresponse.jobid; |                                     var jid = json.updatenetworkserviceproviderresponse.jobid; | ||||||
|                   var enableVnmcProviderIntervalID = setInterval(function(){ |                                     var enableVnmcProviderIntervalID = setInterval(function () { | ||||||
|                                         $.ajax({ |                                         $.ajax({ | ||||||
|                                             url: createURL('queryAsyncJobResult'), |                                             url: createURL('queryAsyncJobResult'), | ||||||
|                                             data: { |                                             data: { | ||||||
|                                                 jobid: jid |                                                 jobid: jid | ||||||
|                                             }, |                                             }, | ||||||
|                       success: function(json){ |                                             success: function (json) { | ||||||
|                                                 var result = json.queryasyncjobresultresponse; |                                                 var result = json.queryasyncjobresultresponse; | ||||||
|                                                 if (result.jobstatus == 0) { |                                                 if (result.jobstatus == 0) { | ||||||
|                                                     return; //Job has not completed
 |                                                     return; //Job has not completed
 | ||||||
|                         } |                                                 } else { | ||||||
|                         else { |  | ||||||
|                                                     if (result.jobstatus == 1) { |                                                     if (result.jobstatus == 1) { | ||||||
|                             args.response.success({ data: { state: 'Enabled' } }); |                                                         args.response.success({ | ||||||
|  |                                                             data: { | ||||||
|  |                                                                 state: 'Enabled' | ||||||
|                                                             } |                                                             } | ||||||
|                           else if (result.jobstatus == 2) { |                                                         }); | ||||||
|  |                                                     } else if (result.jobstatus == 2) { | ||||||
|                                                         args.response.error(_s(result.jobresult.errortext)); |                                                         args.response.error(_s(result.jobresult.errortext)); | ||||||
|                                                     } |                                                     } | ||||||
|                                                 } |                                                 } | ||||||
| @ -335,7 +396,7 @@ | |||||||
|                             }); |                             }); | ||||||
|                         } |                         } | ||||||
| 
 | 
 | ||||||
|             var addCiscoVnmcResourceFn = function(){ |                         var addCiscoVnmcResourceFn = function () { | ||||||
|                             var data = { |                             var data = { | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id, |                                 physicalnetworkid: args.context.physicalNetworks[0].id, | ||||||
|                                 hostname: args.data.hostname, |                                 hostname: args.data.hostname, | ||||||
| @ -346,11 +407,13 @@ | |||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('addCiscoVnmcResource'), |                                 url: createURL('addCiscoVnmcResource'), | ||||||
|                                 data: data, |                                 data: data, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; |                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; | ||||||
|                   args.response.success({data: item}); |                                     args.response.success({ | ||||||
|  |                                         data: item | ||||||
|  |                                     }); | ||||||
|                                 }, |                                 }, | ||||||
|                 error: function(data) { |                                 error: function (data) { | ||||||
|                                     args.response.error(parseXMLHttpResponse(data)); |                                     args.response.error(parseXMLHttpResponse(data)); | ||||||
|                                 } |                                 } | ||||||
|                             }); |                             }); | ||||||
| @ -358,7 +421,7 @@ | |||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|                     notification: { |                     notification: { | ||||||
|             poll: function(args) { |                         poll: function (args) { | ||||||
|                             args.complete(); |                             args.complete(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -368,24 +431,24 @@ | |||||||
|                     label: 'Disable VNMC provider', |                     label: 'Disable VNMC provider', | ||||||
| 
 | 
 | ||||||
|                     messages: { |                     messages: { | ||||||
|             confirm: function(args) { |                         confirm: function (args) { | ||||||
|                             return 'Please confirm you would like to disable the VNMC provider.'; |                             return 'Please confirm you would like to disable the VNMC provider.'; | ||||||
|                         }, |                         }, | ||||||
|             notification: function(args) { |                         notification: function (args) { | ||||||
|                             return 'Disable VNMC device'; |                             return 'Disable VNMC device'; | ||||||
|                         } |                         } | ||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|           action: function(args) { |                     action: function (args) { | ||||||
|                         $.ajax({ |                         $.ajax({ | ||||||
|                             url: createURL('listNetworkServiceProviders'), |                             url: createURL('listNetworkServiceProviders'), | ||||||
|                             data: { |                             data: { | ||||||
|                                 name: 'CiscoVnmc', |                                 name: 'CiscoVnmc', | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id |                                 physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                             }, |                             }, | ||||||
|               success: function(json){ |                             success: function (json) { | ||||||
|                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; |                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; | ||||||
|                 if(items != null && items.length > 0) { |                                 if (items != null && items.length > 0) { | ||||||
|                                     var ciscoVnmcProvider = items[0]; |                                     var ciscoVnmcProvider = items[0]; | ||||||
| 
 | 
 | ||||||
|                                     disableCiscoVnmcProviderFn(ciscoVnmcProvider); |                                     disableCiscoVnmcProviderFn(ciscoVnmcProvider); | ||||||
| @ -395,32 +458,34 @@ | |||||||
|                             } |                             } | ||||||
|                         }); |                         }); | ||||||
| 
 | 
 | ||||||
|             var disableCiscoVnmcProviderFn = function(ciscoVnmcProvider){ |                         var disableCiscoVnmcProviderFn = function (ciscoVnmcProvider) { | ||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('updateNetworkServiceProvider'), |                                 url: createURL('updateNetworkServiceProvider'), | ||||||
|                                 data: { |                                 data: { | ||||||
|                                     id: ciscoVnmcProvider.id, |                                     id: ciscoVnmcProvider.id, | ||||||
|                                     state: 'Disabled' |                                     state: 'Disabled' | ||||||
|                                 }, |                                 }, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var jid = json.updatenetworkserviceproviderresponse.jobid; |                                     var jid = json.updatenetworkserviceproviderresponse.jobid; | ||||||
|                   var disableVnmcProviderIntervalID = setInterval(function(){ |                                     var disableVnmcProviderIntervalID = setInterval(function () { | ||||||
|                                         $.ajax({ |                                         $.ajax({ | ||||||
|                                             url: createURL('queryAsyncJobResult'), |                                             url: createURL('queryAsyncJobResult'), | ||||||
|                                             data: { |                                             data: { | ||||||
|                                                 jobid: jid |                                                 jobid: jid | ||||||
|                                             }, |                                             }, | ||||||
|                       success: function(json){ |                                             success: function (json) { | ||||||
|                                                 var result = json.queryasyncjobresultresponse; |                                                 var result = json.queryasyncjobresultresponse; | ||||||
|                                                 if (result.jobstatus == 0) { |                                                 if (result.jobstatus == 0) { | ||||||
|                                                     return; //Job has not completed
 |                                                     return; //Job has not completed
 | ||||||
|                         } |                                                 } else { | ||||||
|                         else { |  | ||||||
|                                                     clearInterval(disableVnmcProviderIntervalID); |                                                     clearInterval(disableVnmcProviderIntervalID); | ||||||
|                                                     if (result.jobstatus == 1) { |                                                     if (result.jobstatus == 1) { | ||||||
|                             args.response.success({ data: { state: 'Disabled' } }); |                                                         args.response.success({ | ||||||
|  |                                                             data: { | ||||||
|  |                                                                 state: 'Disabled' | ||||||
|                                                             } |                                                             } | ||||||
|                           else if (result.jobstatus == 2) { |                                                         }); | ||||||
|  |                                                     } else if (result.jobstatus == 2) { | ||||||
|                                                         args.response.error(_s(result.jobresult.errortext)); |                                                         args.response.error(_s(result.jobresult.errortext)); | ||||||
|                                                     } |                                                     } | ||||||
|                                                 } |                                                 } | ||||||
| @ -431,7 +496,7 @@ | |||||||
|                             }); |                             }); | ||||||
|                         }; |                         }; | ||||||
| 
 | 
 | ||||||
|             var addCiscoVnmcResourceFn = function(){ |                         var addCiscoVnmcResourceFn = function () { | ||||||
|                             var data = { |                             var data = { | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id, |                                 physicalnetworkid: args.context.physicalNetworks[0].id, | ||||||
|                                 hostname: args.data.hostname, |                                 hostname: args.data.hostname, | ||||||
| @ -442,11 +507,13 @@ | |||||||
|                             $.ajax({ |                             $.ajax({ | ||||||
|                                 url: createURL('addCiscoVnmcResource'), |                                 url: createURL('addCiscoVnmcResource'), | ||||||
|                                 data: data, |                                 data: data, | ||||||
|                 success: function(json) { |                                 success: function (json) { | ||||||
|                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; |                                     var item = json.addCiscoVnmcResource.CiscoVnmcResource; | ||||||
|                   args.response.success({data: item}); |                                     args.response.success({ | ||||||
|  |                                         data: item | ||||||
|  |                                     }); | ||||||
|                                 }, |                                 }, | ||||||
|                 error: function(data) { |                                 error: function (data) { | ||||||
|                                     args.response.error(parseXMLHttpResponse(data)); |                                     args.response.error(parseXMLHttpResponse(data)); | ||||||
|                                 } |                                 } | ||||||
|                             }); |                             }); | ||||||
| @ -454,7 +521,7 @@ | |||||||
|                     }, |                     }, | ||||||
| 
 | 
 | ||||||
|                     notification: { |                     notification: { | ||||||
|             poll: function(args) { |                         poll: function (args) { | ||||||
|                             args.complete(); |                             args.complete(); | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @ -463,37 +530,41 @@ | |||||||
|             tabs: { |             tabs: { | ||||||
|                 details: { |                 details: { | ||||||
|                     title: 'label.details', |                     title: 'label.details', | ||||||
|           fields: [ |                     fields: [{ | ||||||
|             { |                         name: { | ||||||
|               name: { label: 'label.name' } |                             label: 'label.name' | ||||||
|  |                         } | ||||||
|  |                     }, { | ||||||
|  |                         state: { | ||||||
|  |                             label: 'label.state' | ||||||
|  |                         }, | ||||||
|  |                         id: { | ||||||
|  |                             label: 'label.id' | ||||||
|                         }, |                         }, | ||||||
|             { |  | ||||||
|               state: { label: 'label.state' }, |  | ||||||
|               id: { label: 'label.id' }, |  | ||||||
|                         servicelist: { |                         servicelist: { | ||||||
|                             label: 'Services', |                             label: 'Services', | ||||||
|                 converter: function(args){ |                             converter: function (args) { | ||||||
|                   if(args) |                                 if (args) | ||||||
|                                     return args.join(', '); |                                     return args.join(', '); | ||||||
|                                 else |                                 else | ||||||
|                                     return ''; |                                     return ''; | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|             } |                     }], | ||||||
|           ], |                     dataProvider: function (args) { | ||||||
|           dataProvider: function(args) { |  | ||||||
|                         $.ajax({ |                         $.ajax({ | ||||||
|                             url: createURL('listNetworkServiceProviders'), |                             url: createURL('listNetworkServiceProviders'), | ||||||
|                             data: { |                             data: { | ||||||
|                                 name: 'CiscoVnmc', |                                 name: 'CiscoVnmc', | ||||||
|                                 physicalnetworkid: args.context.physicalNetworks[0].id |                                 physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                             }, |                             }, | ||||||
|               success: function(json){ |                             success: function (json) { | ||||||
|                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; |                                 var items = json.listnetworkserviceprovidersresponse.networkserviceprovider; | ||||||
|                 if(items != null && items.length > 0) { |                                 if (items != null && items.length > 0) { | ||||||
|                   args.response.success({ data: items[0] }); |                                     args.response.success({ | ||||||
|                 } |                                         data: items[0] | ||||||
|                 else { |                                     }); | ||||||
|  |                                 } else { | ||||||
|                                     args.response.success({ |                                     args.response.success({ | ||||||
|                                         data: { |                                         data: { | ||||||
|                                             name: 'CiscoVnmc', |                                             name: 'CiscoVnmc', | ||||||
| @ -509,35 +580,39 @@ | |||||||
|             } |             } | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|     var vnmcActionFilter = function(args) { |         var vnmcActionFilter = function (args) { | ||||||
|       var enabledActions = ['enable']; |         	var allowedActions = []; | ||||||
|        |  | ||||||
|             $.ajax({ |             $.ajax({ | ||||||
|                 url: createURL('listNetworkServiceProviders'),                 |                 url: createURL('listNetworkServiceProviders'),                 | ||||||
|         async: false, |  | ||||||
|                 data: { |                 data: { | ||||||
|                     name: 'CiscoVnmc', |                     name: 'CiscoVnmc', | ||||||
|                     physicalnetworkid: args.context.physicalNetworks[0].id |                     physicalnetworkid: args.context.physicalNetworks[0].id | ||||||
|                 }, |                 }, | ||||||
|         success: function(json){ |                 async: false, | ||||||
|  |                 success: function (json) { | ||||||
|                     var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;                     |                     var items = json.listnetworkserviceprovidersresponse.networkserviceprovider;                     | ||||||
|           if(items != null && items.length > 0) { |                     if (items != null && items.length > 0) { | ||||||
|                         var ciscoVnmcProvider = items[0]; |                         var ciscoVnmcProvider = items[0]; | ||||||
| 
 |                         if (ciscoVnmcProvider.state == 'Enabled') { | ||||||
|             if (ciscoVnmcProvider.state === 'Enabled') { |                         	allowedActions.push('disable'); | ||||||
|               enabledActions = ['disable']; |                         } else if (ciscoVnmcProvider.state == 'Disabled') { | ||||||
|  |                         	allowedActions.push('enable'); | ||||||
|                         } |                         } | ||||||
|  |                     } else { | ||||||
|  |                     	allowedActions.push('add'); | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             }); |             }); | ||||||
| 
 |             return allowedActions; | ||||||
|       return enabledActions; |  | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         module.pluginAPI.extend({ |         module.pluginAPI.extend({ | ||||||
|       addDevice: function(device) { |             addDevice: function (device) { | ||||||
|                 cloudStack.sections.system.subsections[device.id] = device; |                 cloudStack.sections.system.subsections[device.id] = device; | ||||||
|         vnmcDeviceViewAll.push({ label: device.title, path: '_zone.' + device.id }); |                 vnmcDeviceViewAll.push({ | ||||||
|  |                     label: device.title, | ||||||
|  |                     path: '_zone.' + device.id | ||||||
|  |                 }); | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user