use built in HTMLParser instead of lxml

The last use of lxml beyond the xml clients was the dashboard
test. Instead of using lxml we should be able to do this with built in
HTMLParser.

Change-Id: I933503a207664db720a277de6bfc68f0e1387edc
diff --git a/requirements.txt b/requirements.txt
index e939c5c..ce5886e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,7 +6,6 @@
 httplib2>=0.7.5
 jsonschema>=2.0.0,<3.0.0
 testtools>=0.9.36,!=1.2.0
-lxml>=2.3
 boto>=2.32.1
 paramiko>=1.13.0
 netaddr>=0.7.12
diff --git a/tempest/scenario/test_dashboard_basic_ops.py b/tempest/scenario/test_dashboard_basic_ops.py
index 875a1d9..1a10b79 100644
--- a/tempest/scenario/test_dashboard_basic_ops.py
+++ b/tempest/scenario/test_dashboard_basic_ops.py
@@ -12,11 +12,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import HTMLParser
 import urllib
 import urllib2
 
-from lxml import html
-
 from tempest import config
 from tempest.scenario import manager
 from tempest import test
@@ -24,6 +23,30 @@
 CONF = config.CONF
 
 
+class HorizonHTMLParser(HTMLParser.HTMLParser):
+    csrf_token = None
+    region = None
+
+    def _find_name(self, attrs, name):
+        for attrpair in attrs:
+            if attrpair[0] == 'name' and attrpair[1] == name:
+                return True
+        return False
+
+    def _find_value(self, attrs):
+        for attrpair in attrs:
+            if attrpair[0] == 'value':
+                return attrpair[1]
+        return None
+
+    def handle_starttag(self, tag, attrs):
+        if tag == 'input':
+            if self._find_name(attrs, 'csrfmiddlewaretoken'):
+                self.csrf_token = self._find_value(attrs)
+            if self._find_name(attrs, 'region'):
+                self.region = self._find_value(attrs)
+
+
 class TestDashboardBasicOps(manager.ScenarioTest):
 
     """
@@ -49,10 +72,8 @@
         response = self.opener.open(CONF.dashboard.dashboard_url).read()
 
         # Grab the CSRF token and default region
-        csrf_token = html.fromstring(response).xpath(
-            '//input[@name="csrfmiddlewaretoken"]/@value')[0]
-        region = html.fromstring(response).xpath(
-            '//input[@name="region"]/@value')[0]
+        parser = HorizonHTMLParser()
+        parser.feed(response)
 
         # Prepare login form request
         req = urllib2.Request(CONF.dashboard.login_url)
@@ -60,8 +81,8 @@
         req.add_header('Referer', CONF.dashboard.dashboard_url)
         params = {'username': CONF.identity.username,
                   'password': CONF.identity.password,
-                  'region': region,
-                  'csrfmiddlewaretoken': csrf_token}
+                  'region': parser.region,
+                  'csrfmiddlewaretoken': parser.csrf_token}
         self.opener.open(req, urllib.urlencode(params))
 
     def check_home_page(self):