Index: /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/network/interface/__init__.py
===================================================================
--- /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/network/interface/__init__.py	(revision 9210)
+++ /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/network/interface/__init__.py	(working copy)
@@ -8,6 +8,7 @@
 from hive.utils import get_current_session, andebug
 from avx.router import get_ssl_card_type
 from hive.model.legacycli import cli_parse, RegexParser, MATCHALL, MATCHONE, EasyParser
+import re
 __ = _
 
 child_seq = ['SystemInterface', 'TrafficInterface', 'SSL']
@@ -204,27 +205,13 @@
     class Manager(CLIManager):
         def _get_query_set(self):
             self.cli.set_enable()
-            parser = RegexParser('(?P<interface_name>port[0-9]+?)\((?P<physical_name>[^\)]+)\):\s+flags=[^>]+>\s+mtu\s+(?P<mtu>[0-9]+)((?!ether).)*?' +
-                                    '\s+ether\s+"?(?P<mac>[\w|0-9|:]+)((?!RX packets).)*?' + 
-                                    '\s+RX packets\s(?P<rx_packets>[0-9]+)\s+bytes\s(?P<rx_bytes>[0-9]+).*?' + 
-                                    '(TX packets\s(?P<tx_packets>[0-9]+)\s+bytes\s(?P<tx_bytes>[0-9]+)).*?' +
-                                    '(status: (?P<interface_status>active|no carrier|down\(Administratively down\))).*?' +
-                                    '(?P<model>[0-9]+ lost carrier, [0-9]+ WDT reset)', MATCHALL, reflags=re.S)
-            
-            parser2 = RegexParser('(?P<interface_name>port[0-9]+?)\((?P<physical_name>[^\)]+)\):\s+This port has been passed through to a VA instance\.', MATCHALL, reflags=re.S)
-
-            parser3 = RegexParser('(?P<interface_name>port[0-9]+?):\s+flags=[^>]+>\s+mtu\s+(?P<mtu>[0-9]+)((?!ether).)*?' +
-                                    '\s+ether\s+"?(?P<mac>[\w|0-9|:]+)((?!RX packets).)*?' + 
-                                    '\s+RX packets\s(?P<rx_packets>[0-9]+)\s+bytes\s(?P<rx_bytes>[0-9]+).*?' + 
-                                    '(TX packets\s(?P<tx_packets>[0-9]+)\s+bytes\s(?P<tx_bytes>[0-9]+)).*?' +
-                                    '(status: (?P<interface_status>active|no carrier|down\(Administratively down\))).*?' +
-                                    '(?P<model>[0-9]+ lost carrier, [0-9]+ WDT reset)', MATCHALL, reflags=re.S)
-
-            result = self.cli.cmd('show interface', [parser, parser2, parser3])
+            block_parser = RegexParser(r'(\w+\([^\)]+\):[\s\S]+?)(?=\n\w+\([^\)]+\):|\Z)', MATCHALL, reflags=re.S)
+            result = self.cli.cmd('show interface', [block_parser])
             result2 = self.cli.cmd('show system resource',
                   RegexParser('-+NIC Resource Status-+\n(?P<nic>[\s\S]+)-+SSL Resource Status-+', MATCHALL, reflags=re.S))
             nic = result2[0]["nic"]
             port_domains = cli_parse(nic, RegexParser('\s+(?P<domain>domain[0-9]+:\n(\s+port\s*[0-9]+\(\s*[0-9]+VFs\):\s+[0-9]+\savailable\.)+)', MATCHALL, reflags=re.S))
+            domain_map = {}
             for each_domain in port_domains:
                 each_res = cli_parse(each_domain["domain"], [
                     RegexParser('domain\s*(?P<domain_id>[0-9]+):', MATCHALL, reflags=re.S),
@@ -235,27 +222,63 @@
                 except Exception, e:
                     return HttpResponse(json.dumps({"state": False}))
                 for item in each_res[1]:
-                    for each in result[0]:
-                        port_id = each["interface_name"].split("port")[-1]
-                        each["port_id"] = int(port_id)
-                        each["interface_status"] = each["interface_status"].title()
-                        if port_id == item["port_id"]:
-                            each["domain"] = each_id
-                            each["available"] = item["vf_available"] + " available port VF(s)"
-                            break
-                    for each in result[1]:
-                        port_id = each["interface_name"].split("port")[-1]
-                        each["port_id"] = int(port_id)
-                        if port_id == item["port_id"]:
-                            each["domain"] = each_id
-                            each["available"] = "This port has been passed through to a VA instance."
-                    for each in result[2]:
-                        port_id = each["interface_name"].split("port")[-1]
-                        each["port_id"] = int(port_id)
-                        if port_id == item["port_id"]:
-                            each["domain"] = each_id
-                            each["available"] = item["vf_available"] + " available port VF(s)"
-            res = result[0] + result[1] + result[2]
+                    domain_map[item["port_id"]] = {
+                        "vf_sum": item["vf_sum"],
+                        "vf_available": item["vf_available"],
+                        "domain": each_id,
+                    }
+            res = []
+            for block in result[0]:
+                each = block[0]
+                if not each.startswith('port'):
+                    continue
+                port = ""
+                physical_name = ""
+                port_part = each.split("port")[1].split()[0]
+                if "(" in port_part and ")" in port_part:
+                    port = port_part.split("(")[0]
+                    physical_name = port_part.split("(")[1].split(")")[0]
+                # mtu
+                m = re.search(r'mtu\s+(\d+)', each)
+                mtu = m.group(1) if m else None
+                # mac
+                m = re.search(r'ether\s+([0-9a-f:]+)', each)
+                mac = m.group(1) if m else None
+                # rx_packets and rx_bytes
+                m = re.search(r'RX packets\s+(\d+)\s+bytes\s+(\d+)', each)
+                rx_packets = m.group(1) if m else None
+                rx_bytes = m.group(2) if m else None
+                # tx_packets and tx_bytes
+                m = re.search(r'TX packets\s+(\d+)\s+bytes\s+(\d+)', each)
+                tx_packets = m.group(1) if m else None
+                tx_bytes = m.group(2) if m else None
+                # status
+                m = re.search(r'status: (?P<interface_status>active|no carrier|down\(Administratively down\))', each)
+                interface_status = m.group('interface_status') if m else None
+                # model
+                m = re.search(r'(?P<model>\d+ lost carrier, \d+ WDT reset)', each)
+                model = m.group('model') if m else None
+                available = ""
+                domain_info = domain_map[port] if port in domain_map else {}
+                if "This port has been passed through to a VA instance" in each:
+                    available = "This port has been passed through to a VA instance."
+                elif "vf_available" in domain_info:
+                    available = domain_info["vf_available"] + " available port VF(s)"
+                res.append({
+                    "port_id": int(port),
+                    "interface_name": "port" + port,
+                    "physical_name": physical_name,
+                    "mtu": mtu,
+                    "mac": mac,
+                    "rx_packets": rx_packets,
+                    "rx_bytes": rx_bytes,
+                    "tx_packets": tx_packets,
+                    "tx_bytes": tx_bytes,
+                    "interface_status": interface_status.title() if interface_status else None,
+                    "model": model,
+                    "domain": domain_info.get("domain", None),
+                    "available": available,
+                })
             res_sorted = sorted(res, key=lambda e: e.__getitem__('port_id'))
             for each in res_sorted:
                 del each["port_id"]
Index: /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/va/instance/__init__.py
===================================================================
--- /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/va/instance/__init__.py	(revision 9210)
+++ /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/models/va/instance/__init__.py	(working copy)
@@ -13,8 +13,6 @@
     import xml.etree.cElementTree as ET
 except ImportError:
     import xml.etree.ElementTree as ET
-import uuid
-from handler import VAInstanceHandle, SessionCounter
 
 __ = _
 
@@ -143,21 +141,192 @@
 
     class Manager(CLIManager):
         def _get_query_set(self):
-            vaHandler = VAInstanceHandle(self.cli)
-            current_time = int(time.time())
-            query_type = ""
-            if getattr(self, 'query_type', None):
-                query_type = getattr(self, 'query_type')
-            counter = SessionCounter(vaHandler.get_id(), query_type)
-            counter_data = counter.get_counter_data()
-            if counter_data['timestamp'] <= current_time: # check newest request
-                request_id = str(uuid.uuid4())
-                counter.cleanup_old_results(request_id)
-                counter.set_counter_data(counter_data['counter'] + 1, request_id, current_time)
-                vaHandler.get_data_from_cli(request_id, counter)
-            else:
-                counter.wait_for_result(counter_data['uuid'])
-            rst = counter.read_result_file(counter.get_counter_data()['uuid'])
+            self.cli.set_enable()
+            result = self.cli.cmd('show va instance',
+                                  EasyParser('va instance', ['?va_name', '?va_size', '?starting_port', '?domain_id', '?tgt_name']),
+                                  EasyParser('va custinstance', ['?va_name', '?cpu_thread', '?memory', '?domain_id', '?tgt_name']))
+            cpu_thread_result = self.cli.cmd('show va resource', RegexParser('\s+(?P<va_name>[^\n]+?)\s+(?P<cpu_thread>[0-9]+(\sshared)?)\s+(?P<memory>[0-9]+)G\s+[0-9]+\s+dedicated VF\s+', MATCHALL, reflags=re.S))
+
+            va_status_result = self.cli.cmd('show va status', RegexParser('(?P<va_name>\S+)\s+(?P<status>running|shutoff)\n', MATCHALL, reflags=re.S))
+
+            vnc_result = self.cli.cmd('show vncport', RegexParser('(?P<va_name>\S+):\s*(?P<vnc_port>[0-9]+)\n', MATCHALL, reflags=re.S))
+
+            mgmtip_result = self.cli.cmd('show va mgmtip', RegexParser('va mgmtip (?P<va_name>\S+) (?P<ip>\S+)\n', MATCHALL, reflags=re.S))
+
+            vlan_result = self.cli.cmd('show va mgmtvlan' , RegexParser('va mgmtvlan (?P<va_name>\S+) (?P<tag>\S+)\n', MATCHALL, reflags=re.S))
+
+            nic_type_result = self.cli.cmd('show va mgmttype', RegexParser('(?P<va_name>\S+)\s+(?P<nic_type>\S+)\n', MATCHALL, reflags=re.S))
+
+            va_exdisk_result = self.cli.cmd('show va disk',
+                            RegexParser('(?P<va_name>\S+):\n(?P<disk_name>([\S]+\s*?[\S]*?\s*?[\S]*?\s*?[\S]*?\n)+)\n', MATCHALL, reflags=re.S))
+
+            res = []
+            for each in va_exdisk_result:
+                disks = each["disk_name"].split("\n")
+                del disks[0]
+                for item in disks:
+                    if item and item.split()[0] != "reserved":
+                        each_disk = {
+                            "disk_name": item.split()[0],
+                            "va_name": each["va_name"],
+                            "disk_size": item.split()[-2].split("(")[0],
+                            "bus_type": item.split()[-1]
+                        }
+                        res.append(each_disk)
+
+            if COMPANY_KEYWORD == "Array":
+                apv_type_result = self.cli.cmd('show va license apv', EasyParser('', ['?va_name', '?type']))
+
+                ag_type_result = self.cli.cmd('show va license ag', EasyParser('', ['?va_name', '?type']))
+
+                netgate_type_result = self.cli.cmd('show va license netgate', EasyParser('', ['?va_name', '?type']))
+
+                netiag_type_result = self.cli.cmd('show va license netiag', EasyParser('', ['?va_name', '?type']))
+
+
+            if COMPANY_KEYWORD == "Infosec":
+                nsae_type_result = self.cli.cmd('show va license nsae', EasyParser('', ['?va_name', '?type']))
+
+                netgate_type_result = self.cli.cmd('show va license netgate', EasyParser('', ['?va_name', '?type']))
+
+                netopti_type_result = self.cli.cmd('show va license netopti', EasyParser('', ['?va_name', '?type']))
+
+                apv_type_result = self.cli.cmd('show va license apv', EasyParser('', ['?va_name', '?type']))
+
+                ag_type_result = self.cli.cmd('show va license ag', EasyParser('', ['?va_name', '?type']))
+
+                netiag_type_result = self.cli.cmd('show va license netiag', EasyParser('', ['?va_name', '?type']))
+
+            rst = result[0] + result[1]
+            for each in rst:
+                # for normal va instance
+                if "starting_port" in each and each["starting_port"] == 'null':
+                    del each["starting_port"]
+                # for custom va instance
+                if "va_size" not in each:
+                    each["va_size"] = "custom"
+                    each["cpu_thread_shared"] = False
+
+                # init the field
+                name = each["va_name"]
+                each["ip"] = ""
+                each["va_vncport"] = ""
+                each["vlan_tag"] = ""
+                each["nic_type"] = "e1000"
+                each["type"] = ""
+                each["attached_disk"] = []
+
+                # memory & cpu_thread & cpu_thread_shared
+                for item in cpu_thread_result:
+                    if item["va_name"] == name:
+                        each["memory"] = item["memory"]
+                        if "shared" in item["cpu_thread"]:
+                            cpu_thread = int(item["cpu_thread"].split("shared")[0])
+                            cpu_thread_shared = True
+                        else:
+                            cpu_thread = int(item["cpu_thread"])
+                            cpu_thread_shared = False
+                        break
+                each["cpu_thread"] = cpu_thread
+                each["cpu_thread_shared"] = cpu_thread_shared
+                # vnc
+                for item in vnc_result:
+                    if item["va_name"] == name:
+                        each["va_vncport"] = item["vnc_port"]
+                        break
+                # mgmt_ip
+                for item in mgmtip_result:
+                    if item["va_name"] == name:
+                        each["ip"] = item["ip"]
+                        break
+                # mgmtvlan
+                for item in vlan_result:
+                    if item["va_name"] == name:
+                        each["vlan_tag"] = item["tag"]
+                        break
+                # mgmttype
+                for item in nic_type_result:
+                    if item["va_name"] == name:
+                        each["nic_type"] = item["nic_type"]
+                        break
+                # mgmtexdisk
+
+                for item in res:
+                    if item["va_name"] == name:
+                        each_disk = {
+                            "disk_name": item["disk_name"],
+                            "va_name": item["va_name"],
+                            "disk_size": item["disk_size"],
+                            "bus_type": item["bus_type"]
+                        }
+                        each["attached_disk"].append(each_disk)
+
+                if COMPANY_KEYWORD == "Array":
+                    # ag/apv license type
+                    for item in apv_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in ag_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in netgate_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in netiag_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                if COMPANY_KEYWORD == "Infosec":
+                    # nsae/netopti/netgate license type
+                    for item in nsae_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in netopti_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in netgate_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in apv_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in ag_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                    for item in netiag_type_result:
+                        if "va_name" in item and item["va_name"] == name:
+                            each["type"] = item["type"]
+                            break
+                self._model._meta.mark_delay_query(each)
+
+                # query va image info for each va instance
+                image = each["tgt_name"]
+                sess = get_current_session()
+                image_model = get_model('avx', ['va', 'image', 'VAImageManagement'])
+                image_manager = image_model.get_manager(sess)
+                image_instance = image_manager.all().filter({"image_name": image})
+                product_category = image_instance[0].product_category if image_instance else ''
+                if product_category == "Other":
+                    product_category = image_instance[0].other_category
+                product_name = image_instance[0].product_name if image_instance else ''
+                vendor = image_instance[0].vendor if image_instance else ''
+                each["product_category"] = product_category
+                each["product_name"] = product_name
+                each["vendor"] = vendor
+                each["status"] = False
+                for item in va_status_result:
+                    if item["va_name"] == each["va_name"]:
+                        each["status"] = True if item["status"] == "running" else False
+                        break
+
             return QuerySet(self._model, rst)
 
         def _get_boottime(self, pk_dict):
Index: /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/router.py
===================================================================
--- /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/router.py	(revision 9210)
+++ /branches/rel_avx_2_7_5_caswell_5070/src/webui/webui/htdocs/new/src/avx/router.py	(working copy)
@@ -1922,7 +1922,7 @@
                     each_ssl = {
                         "id": item["ssl_id"],
                         "vf_sum": item["vf_sum"] if "vf_sum" in item else 1,
-                        "card_type": card_type_list[each_id+'-ssl'+item["ssl_id"]],
+                        "card_type": "", # card_type_list[each_id+'-ssl'+item["ssl_id"]],
                         "vf_dedicated_available": item["vf_dedi_available"],
                         "vf_share_available": item["vf_share_available"] if "vf_share_available" in item else "",
                     }
@@ -1937,7 +1937,7 @@
                 each_ssl = {
                     "id": item["ssl_id"],
                     "vf_sum": item["vf_sum"] if "vf_sum" in item else 1,
-                    "card_type": card_type_list[each_id+'-ssl'+item["ssl_id"]],
+                    "card_type": "", # card_type_list[each_id+'-ssl'+item["ssl_id"]],
                     "vf_dedicated_available": item["vf_dedi_available"],
                     "vf_share_available": item["vf_share_available"] if "vf_share_available" in item else "",
                 }
