|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | +(function($, cloudStack) { |
| 18 | + cloudStack.modules.vnmcAsa1000v = function(module) { |
| 19 | + module.vnmcNetworkProvider.addDevice({ |
| 20 | + id: 'asa1000v', |
| 21 | + title: 'ASA 1000v', |
| 22 | + listView: { |
| 23 | + id: 'asa1000vDevices', |
| 24 | + fields: { |
| 25 | + hostname: { label: 'label.host' }, |
| 26 | + insideportprofile: { label: 'Inside Port Profile' } |
| 27 | + }, |
| 28 | + dataProvider: function(args) { |
| 29 | + $.ajax({ |
| 30 | + url: createURL('listCiscoAsa1000vResources'), |
| 31 | + data: { |
| 32 | + physicalnetworkid: args.context.physicalNetworks[0].id |
| 33 | + }, |
| 34 | + success: function(json){ |
| 35 | + var items = json.listCiscoAsa1000vResources.CiscoAsa1000vResource; |
| 36 | + args.response.success({ data: items }); |
| 37 | + } |
| 38 | + }); |
| 39 | + }, |
| 40 | + |
| 41 | + actions: { |
| 42 | + add: { |
| 43 | + label: 'Add CiscoASA1000v Resource', |
| 44 | + messages: { |
| 45 | + notification: function(args) { |
| 46 | + return 'Add CiscoASA1000v Resource'; |
| 47 | + } |
| 48 | + }, |
| 49 | + createForm: { |
| 50 | + title: 'Add CiscoASA1000v Resource', |
| 51 | + fields: { |
| 52 | + hostname: { |
| 53 | + label: 'label.host', |
| 54 | + validation: { required: true } |
| 55 | + }, |
| 56 | + insideportprofile: { |
| 57 | + label: 'Inside Port Profile', |
| 58 | + validation: { required: true } |
| 59 | + }, |
| 60 | + clusterid: { |
| 61 | + label: 'label.cluster', |
| 62 | + validation: { required: true }, |
| 63 | + select: function(args){ |
| 64 | + $.ajax({ |
| 65 | + url: createURL('listClusters'), |
| 66 | + data: { |
| 67 | + zoneid: args.context.zones[0].id |
| 68 | + }, |
| 69 | + success: function(json) { |
| 70 | + var objs = json.listclustersresponse.cluster; |
| 71 | + var items = []; |
| 72 | + if(objs != null) { |
| 73 | + for(var i = 0; i < objs.length; i++){ |
| 74 | + items.push({id: objs[i].id, description: objs[i].name}); |
| 75 | + } |
| 76 | + } |
| 77 | + args.response.success({data: items}); |
| 78 | + } |
| 79 | + }); |
| 80 | + } |
| 81 | + } |
| 82 | + } |
| 83 | + }, |
| 84 | + action: function(args) { |
| 85 | + var data = { |
| 86 | + physicalnetworkid: args.context.physicalNetworks[0].id, |
| 87 | + hostname: args.data.hostname, |
| 88 | + insideportprofile: args.data.insideportprofile, |
| 89 | + clusterid: args.data.clusterid |
| 90 | + }; |
| 91 | + |
| 92 | + $.ajax({ |
| 93 | + url: createURL('addCiscoAsa1000vResource'), |
| 94 | + data: data, |
| 95 | + success: function(json){ |
| 96 | + var item = json.addCiscoAsa1000vResource.CiscoAsa1000vResource; |
| 97 | + args.response.success({data: item}); |
| 98 | + }, |
| 99 | + error: function(data) { |
| 100 | + args.response.error(parseXMLHttpResponse(data)); |
| 101 | + } |
| 102 | + }); |
| 103 | + |
| 104 | + }, |
| 105 | + notification: { |
| 106 | + poll: function(args) { |
| 107 | + args.complete(); |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + }, |
| 112 | + |
| 113 | + detailView: { |
| 114 | + name: 'CiscoASA1000v details', |
| 115 | + actions: { |
| 116 | + remove: { |
| 117 | + label: 'delete CiscoASA1000v', |
| 118 | + messages: { |
| 119 | + confirm: function(args) { |
| 120 | + return 'Please confirm you want to delete CiscoASA1000v'; |
| 121 | + }, |
| 122 | + notification: function(args) { |
| 123 | + return 'delete CiscoASA1000v'; |
| 124 | + } |
| 125 | + }, |
| 126 | + action: function(args) { |
| 127 | + $.ajax({ |
| 128 | + url: createURL('deleteCiscoAsa1000vResource'), |
| 129 | + data: { |
| 130 | + resourceid: args.context.asa1000vDevices[0].resourceid |
| 131 | + }, |
| 132 | + success: function(json) { |
| 133 | + args.response.success(); |
| 134 | + }, |
| 135 | + error: function(data) { |
| 136 | + args.response.error(parseXMLHttpResponse(data)); |
| 137 | + } |
| 138 | + }); |
| 139 | + }, |
| 140 | + notification: { |
| 141 | + poll: function(args) { |
| 142 | + args.complete(); |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | + }, |
| 147 | + |
| 148 | + tabs: { |
| 149 | + details: { |
| 150 | + title: 'label.details', |
| 151 | + |
| 152 | + fields: [ |
| 153 | + { |
| 154 | + hostname: { |
| 155 | + label: 'label.host' |
| 156 | + } |
| 157 | + }, |
| 158 | + { |
| 159 | + insideportprofile: { label: 'Inside Port Profile' }, |
| 160 | + RESOURCE_NAME: { label: 'Resource Name' }, |
| 161 | + resourceid: { label: 'Resource ID' } |
| 162 | + } |
| 163 | + ], |
| 164 | + |
| 165 | + dataProvider: function(args) { |
| 166 | + $.ajax({ |
| 167 | + url: createURL('listCiscoAsa1000vResources'), |
| 168 | + data: { |
| 169 | + resourceid: args.context.asa1000vDevices[0].resourceid |
| 170 | + }, |
| 171 | + success: function(json) { |
| 172 | + var item = json.listCiscoAsa1000vResources.CiscoAsa1000vResource[0]; |
| 173 | + args.response.success({ data: item }); |
| 174 | + } |
| 175 | + }); |
| 176 | + } |
| 177 | + } |
| 178 | + } |
| 179 | + } |
| 180 | + } |
| 181 | + }); |
| 182 | + }; |
| 183 | +}(jQuery, cloudStack)); |
0 commit comments