Index: /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/models/system/license.py
===================================================================
--- /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/models/system/license.py	(revision 2504)
+++ /branches/amp_3_7/src/webui/webui/htdocs/new/src/cm/models/system/license.py	(working copy)
@@ -3,7 +3,8 @@
 from hive.session import check_license_expire
 from cm.lib.postgres_db import DB
 from djproject.an_settings import *
-__=_
+
+__ = _
 
 
 def get_license():
@@ -11,15 +12,15 @@
     session.cli.set_enable()
     license_status = {
         "device_limit": 0,
-        "adc_limit":    0,
-        "vpn_limit":    0,
-        "waf_limit":    0
+        "adc_limit": 0,
+        "vpn_limit": 0,
+        "waf_limit": 0
     }
     result = session.cli.cmd('show version', [
-            RegexParser('Licensed Devices : (?P<device_limit>[0-9]*)', MATCHONE),
-            RegexParser('Licensed ADCs : (?P<adc_limit>[0-9]*)', MATCHONE),
-            RegexParser('Licensed VPNs : (?P<vpn_limit>[0-9]*)', MATCHONE),
-            RegexParser('Licensed WAFs : (?P<waf_limit>[0-9]*)', MATCHONE)])
+        RegexParser('Licensed Devices : (?P<device_limit>[0-9]*)', MATCHONE),
+        RegexParser('Licensed ADCs : (?P<adc_limit>[0-9]*)', MATCHONE),
+        RegexParser('Licensed VPNs : (?P<vpn_limit>[0-9]*)', MATCHONE),
+        RegexParser('Licensed WAFs : (?P<waf_limit>[0-9]*)', MATCHONE)])
     if result:
         for each in result:
             if "device_limit" in each and each["device_limit"]:
@@ -32,12 +33,14 @@
                 license_status["waf_limit"] = int(each["waf_limit"])
     return license_status
 
+
 def _check_license_expire():
     session = get_current_session()
     res = check_license_expire(session)
 
     return res
 
+
 def get_device_num(device_type):
     condition_list = []
     if device_type.lower() in ADC_TYPE_LIST:
@@ -63,7 +66,8 @@
         db.close()
         return result[0]
     else:
-         return 0
+        return 0
+
 
 def check_license(device_type):
     expire = _check_license_expire()
@@ -73,7 +77,7 @@
     license_limit = get_license()
     if device_type and device_type in DEVICE_STD_LIST:
         device_num = get_device_num(device_type)
-        if device_type.lower() in ADC_TYPE_LIST or device_type.lower() in WAF_TYPE_LIST:
+        if device_type.lower() in ADC_TYPE_LIST:
             limit = license_limit["adc_limit"]
         elif device_type.lower() in VPN_TYPE_LIST:
             limit = license_limit["vpn_limit"]
@@ -84,10 +88,11 @@
         if limit > device_num:
             return True
         else:
-            raise ModelQueryException(CLICmdError(__('Sorry you need more license.')))
+            raise ModelQueryException(CLICmdError(__("We've reached the current limit for %s licenses." % device_type)))
     else:
         raise ModelQueryException(CLICmdError(__('Invalid device type.')))
 
+
 class License(ANModel):
     license_key = CharField(verbose_name='License Key', length='1..256', optional=True)
     serial_num = CharField(verbose_name='Serial Number')
@@ -107,30 +112,31 @@
         def _get_query_set(self):
             self.cli.set_enable()
             output = self.cli.cmd('show version',
-                        [RegexParser('License Key : (?P<license_key>.*)', MATCHONE),
-                        RegexParser('Serial Number : (?P<serial_num>.*)', MATCHONE),
-                        RegexParser('Licensed Devices : (?P<device_num>[0-9]+)', MATCHONE),
-                        RegexParser('Expiration Date : (?P<expiration_data>.*)', MATCHONE),
-                        RegexParser('Licensed ADCs : (?P<adc_num>.*)', MATCHONE),
-                        RegexParser('Licensed VPNs : (?P<vpn_num>.*)', MATCHONE),
-                        RegexParser('Licensed WAFs : (?P<waf_num>.*)', MATCHONE),
-                        RegexParser('Licensed VPN License Session : (?P<vpn_lic_sess>.*)', MATCHONE)])
+                                  [RegexParser('License Key : (?P<license_key>.*)', MATCHONE),
+                                   RegexParser('Serial Number : (?P<serial_num>.*)', MATCHONE),
+                                   RegexParser('Licensed Devices : (?P<device_num>[0-9]+)', MATCHONE),
+                                   RegexParser('Expiration Date : (?P<expiration_data>.*)', MATCHONE),
+                                   RegexParser('Licensed ADCs : (?P<adc_num>.*)', MATCHONE),
+                                   RegexParser('Licensed VPNs : (?P<vpn_num>.*)', MATCHONE),
+                                   RegexParser('Licensed WAFs : (?P<waf_num>.*)', MATCHONE),
+                                   RegexParser('Licensed VPN License Session : (?P<vpn_lic_sess>.*)', MATCHONE)])
             expire_time = ""
             if output[3]:
                 exp_str = output[3]['expiration_data'].split('on')[-1].strip()
-                expire_time = datetime.datetime.strptime(exp_str, '%b %d %Y').strftime("%Y-%m-%d") if exp_str != "Permanent" else "Permanent"
+                expire_time = datetime.datetime.strptime(exp_str, '%b %d %Y').strftime(
+                    "%Y-%m-%d") if exp_str != "Permanent" else "Permanent"
 
             data = {
-                'license_key':output[0]['license_key'] if output[0] else '',
-                'serial_num':output[1]['serial_num'],
-                'device_num':output[2]['device_num'] if output[2] else 0,
-                'adc_num':output[4]['adc_num'] if output[4] else 0,
-                'vpn_num':output[5]['vpn_num'] if output[5] else 0,
-                'waf_num':output[6]['waf_num'] if output[6] else 0,
+                'license_key': output[0]['license_key'] if output[0] else '',
+                'serial_num': output[1]['serial_num'],
+                'device_num': output[2]['device_num'] if output[2] else 0,
+                'adc_num': output[4]['adc_num'] if output[4] else 0,
+                'vpn_num': output[5]['vpn_num'] if output[5] else 0,
+                'waf_num': output[6]['waf_num'] if output[6] else 0,
                 'vpn_lic_sess': output[7]['vpn_lic_sess'] if output[7]['vpn_lic_sess'] != "No Limitation" else 99999999,
                 'expiration_data': expire_time,
-                'status':''
-                }
+                'status': ''
+            }
             if data['expiration_data']:
                 data['status'] = 'Normal'
                 if data['expiration_data'] != 'Permanent':
@@ -141,8 +147,9 @@
                         data['status'] = 'Expiration'
                     elif result.days < 30:
                         data['status'] = 'Warning'
-                
+
             return QuerySet(self._model, [data])
+
         def _update_license_key(self, instance):
             self.cli.set_config()
             output = self.cli.cmd('system license "%s"' % instance.license_key.strip('"'))
@@ -150,9 +157,3 @@
                 result = cli_parse(output, BlankParser(nonblank_exception=CLICmdError, supplement=True))
             return
 
-
-
-
-
-
-
