test_vm_controlls.py 26.7 KB
Newer Older
1 2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE.  If not, see <http://www.gnu.org/licenses/>.
from selenose.cases import SeleniumTestCase
20 21 22 23
from django.contrib.auth.models import User
import random
import urlparse
import re
24
import time
25 26
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
27
from selenium.webdriver.support.select import Select
28
from selenium.webdriver.common.by import By
Csók Tamás committed
29
from datetime import datetime
Csók Tamás committed
30 31
random_pass = "".join([random.choice(
    '0123456789abcdefghijklmnopqrstvwxyz') for n in xrange(10)])
32 33
random_accents = random_pass + "".join([random.choice(
    u"áéíöóúűÁÉÍÖÓÜÚŰ") for n in xrange(5)])
Csók Tamás committed
34
wait_max_sec = 10
35 36 37
host = 'https:127.0.0.1'


38
class UtilityMixin(object):
Csók Tamás committed
39
    def login(self, username, password='password', location=None):
40
        driver = self.driver
Csók Tamás committed
41 42 43 44 45
        if location is None:
            location = '/dashboard/'
        driver.get('%s%s' % (host, location))
        #  Only if we aren't logged in already
        if location not in urlparse.urlparse(self.driver.current_url).path:
46
            try:
Csók Tamás committed
47 48 49
                name_input = driver.find_element_by_id("id_username")
                password_input = driver.find_element_by_id("id_password")
                submit_input = driver.find_element_by_id("submit-id-submit")
50
            except:
Csók Tamás committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
                inputs = driver.find_elements_by_tag_name("input")
                for current_input in inputs:
                    input_type = current_input.get_attribute("type")
                    if input_type == "text":
                        name_input = current_input
                    if input_type == "password":
                        password_input = current_input
                    if input_type == "submit":
                        submit_input = current_input
            try:
                name_input.clear()
                name_input.send_keys(username)
                password_input.clear()
                password_input.send_keys(password)
                submit_input.click()
                try:
                    # If selenium runs only in a small (virtual) screen
                    driver.find_element_by_class_name('navbar-toggle').click()
                    WebDriverWait(self.driver, wait_max_sec).until(
                        EC.element_to_be_clickable((
                            By.CSS_SELECTOR,
                            "a[href*='/dashboard/profile/']")))
                except:
                    time.sleep(0.5)
            except:
                raise Exception('Selenium cannot find the form controls')
77

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
    def list_options(self, select):
        try:
            option_dic = {}
            select = Select(select)
            for option in select.options:
                key = option.get_attribute('value')
                if key is not None and key:
                    option_dic[key] = [option.text]
            return option_dic
        except:
            raise Exception(
                'Selenium cannot list the select possibilities')

    def select_option(self, select, what=None):
        try:
            my_choice = None
            options = self.list_options(select)
            select = Select(select)
            if what is not None:
                for key, value in options.iteritems():
                    if what in key:
                        my_choice = key
                    else:
                        if isinstance(value, list):
                            for single_value in value:
                                if what in single_value:
                                    my_choice = key
                        else:
                            if what in value:
                                my_choice = key
            if my_choice is None:
                my_choose_list = options.keys()
                my_choice = my_choose_list[random.randint(
                    0, len(my_choose_list) - 1)]
            select.select_by_value(my_choice)
        except:
            raise Exception(
Csók Tamás committed
115
                'Selenium cannot select the chosen one')
116

117
    def get_link_by_href(self, target_href, attributes=None):
118
        try:
119 120 121
            links = self.driver.find_elements_by_tag_name('a')
            for link in links:
                href = link.get_attribute('href')
122
                if href is not None and href:
123 124 125 126 127
                    if target_href in href:
                        perfect_fit = True
                        if isinstance(attributes, dict):
                            for key, target_value in attributes.iteritems():
                                attr_check = link.get_attribute(key)
128
                                if attr_check is not None and attr_check:
129 130 131 132
                                    if target_value not in attr_check:
                                        perfect_fit = False
                        if perfect_fit:
                            return link
133
        except:
134 135
            raise Exception(
                'Selenium cannot find the href=%s link' % target_href)
136

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
    def click_on_link(self, link):
        """
        There are situations when selenium built in click() function
        doesn't work as intended, that's when this function is used.
        Fires a click event via javascript injection.
        """
        try:
            #  Javascript function to simulate a click on a link
            javascript = (
                "var link = arguments[0];"
                "var cancelled = false;"
                "if(document.createEvent) {"
                "   var event = document.createEvent(\"MouseEvents\");"
                "   event.initMouseEvent("
                "       \"click\", true, true, window, 0, 0, 0, 0, 0,"
                "       false,false,false,false,0,null);"
                "   cancelled = !link.dispatchEvent(event);"
                "} else if(link.fireEvent) {"
                "   cancelled = !link.fireEvent(\"onclick\");"
                "} if (!cancelled) {"
                "   window.location = link.href;"
                "}")
            self.driver.execute_script("%s" % javascript, link)
        except:
            raise Exception(
                'Selenium cannot inject javascript to the page')

    def wait_and_accept_operation(self, argument=None):
165
        # try:
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
            accept = WebDriverWait(self.driver, wait_max_sec).until(
                EC.element_to_be_clickable((
                    By.ID, "op-form-send")))
            if argument is not None:
                possible = self.driver.find_elements_by_css_selector(
                    "div.controls > input[type='text']")
                if isinstance(argument, list):
                    for x in range(0, len(possible)):
                        possible[x].clear()
                        possible[x].send_keys(argument[x % len(argument)])
                else:
                    for form in possible:
                        form.clear()
                        form.send_keys(argument)
            accept.click()
181 182 183
        # except:
        #     raise Exception("Selenium cannot accept the"
        #                     " operation confirmation")
184 185 186 187 188 189 190 191 192 193 194 195

    def create_base_template(self, name=None, architecture="x86-64",
                             method=None, op_system=None, lease=None,
                             network="vm"):
        if name is None:
            name = "template_%s" % random_accents
        if op_system is None:
            op_system = "!os %s" % random_accents
        try:
            self.driver.get('%s/dashboard/template/choose/' % host)
            self.driver.find_element_by_css_selector(
                "input[type='radio'][value='base_vm']").click()
Csók Tamás committed
196 197
            self.driver.find_element_by_id(
                "template-choose-next-button").click()
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
            template_name = WebDriverWait(self.driver, wait_max_sec).until(
                EC.visibility_of_element_located((
                    By.ID, 'id_name')))
            template_name.clear()
            template_name.send_keys(name)
            self.select_option(self.driver.find_element_by_id(
                "id_arch"), architecture)
            self.select_option(self.driver.find_element_by_id(
                "id_access_method"), method)
            system_name = self.driver.find_element_by_id("id_system")
            system_name.clear()
            system_name.send_keys(op_system)
            self.select_option(self.driver.find_element_by_id(
                "id_lease"), lease)
            self.select_option(self.driver.find_element_by_id(
                "id_networks"), network)
            self.driver.find_element_by_css_selector(
                "input.btn[type='submit']").click()
            WebDriverWait(self.driver, wait_max_sec).until(
                EC.visibility_of_element_located((
                    By.ID, 'ops')))
            self.click_on_link(self.get_link_by_href('/op/deploy/'))
            self.wait_and_accept_operation()
            self.click_on_link(WebDriverWait(self.driver, wait_max_sec).until(
                EC.element_to_be_clickable((
                    By.CSS_SELECTOR, "a[href$='/op/shut_off/']"))))
            self.wait_and_accept_operation()
            WebDriverWait(self.driver, wait_max_sec).until(
                EC.element_to_be_clickable((
                    By.CSS_SELECTOR, "a[href$='/op/deploy/']")))
            self.click_on_link(self.get_link_by_href('/op/save_as_template/'))
            self.wait_and_accept_operation(name)
            return name
        except:
            raise Exception(
                'Selenium cannot create a base template virtual machine')

235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
    def get_template_id(self, name=None):
        try:
            self.driver.get('%s/dashboard/template/list/' % host)
            templates = self.driver.find_elements_by_css_selector("td.name")
            found_template_ids = []
            for template in templates:
                if name in template.text or name is None:
                    template_link = template.find_element_by_css_selector(
                        "a[data-original-title]")
                    found_template_ids.append(
                        re.search(r'\d+', template_link.get_attribute(
                            'innerHTML')).group())
            if not found_template_ids and name is not None:
                print ("Selenium could not find the specified "
                       "%(name)s template in the list" % {
                           'name': name})
            return found_template_ids
        except:
            raise Exception(
                'Selenium cannot found the template\'s id')

Csók Tamás committed
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
    def check_operation_result(self, operation_id):
        try:
            url_save = self.driver.current_url
            self.driver.get('%(host)s/dashboard/vm/activity/%(id)s/' % {
                'host': host,
                'id': operation_id})
            result = WebDriverWait(self.driver, wait_max_sec).until(
                EC.visibility_of_element_located((
                    By.ID, "activity_status")))
            if (result.text == "success"):
                out = True
            else:
                out = False
            self.driver.get(url_save)
            return out
        except:
            raise Exception(
                'Selenium cannot check the result of an operation')

    def recently(self, timeline_dict, second=90):
        try:
            if isinstance(timeline_dict, dict):
                for key, value in timeline_dict.iteritems():
                    time = datetime.strptime(key, '%Y-%m-%d %H:%M')
                    delta = datetime.now() - time
                    if delta.total_seconds() <= second:
                        return value
        except:
            raise Exception(
                'Selenium cannot filter timeline activities to recent')

    def get_timeline_elements(self, code):
        try:
            self.get_link_by_href("#activity").click()
            activity_dict = {}
            timeline = WebDriverWait(self.driver, wait_max_sec).until(
                EC.visibility_of_element_located((
                    By.ID, "activity-timeline")))
            searched_activity = timeline.find_elements_by_css_selector(
                "div[data-activity-code='%s']" % code)
            print "Found activity list for %s:" % code
            for activity in searched_activity:
                activity_id = activity.get_attribute('data-activity-id')
                activity_text = activity.text
                key = re.search(
                    r'\d+-\d+-\d+ \d+:\d+,', activity_text).group()[:-1]
                print ("%(id)s @ %(activity)s" % {
                    'id': activity_id,
                    'activity': key})
                activity_dict[key] = activity_id
            return activity_dict
        except:
            raise Exception('Selenium cannot find the searched activity')

    def create_template_from_base(self, delete_disk=True, name=None):
311
        try:
Csók Tamás committed
312 313 314 315 316 317 318 319 320 321 322 323 324 325
            if name is None:
                name = "template_from_base_%s" % random_accents
            self.driver.get('%s/dashboard/template/choose/' % host)
            choice_list = []
            choices = self.driver.find_elements_by_css_selector(
                "input[type='radio']")
            choice_list = [item for item in choices if (
                'test' not in item.get_attribute('value')
                and item.get_attribute('value') != 'base_vm')]
            chosen = random.randint(0, len(choice_list) - 1)
            choice_list[chosen].click()
            self.driver.find_element_by_id(
                "template-choose-next-button").click()
            if delete_disk:
326 327
                self.click_on_link(
                    self.get_link_by_href("#resources"))
Csók Tamás committed
328 329 330 331 332 333
                disks = WebDriverWait(self.driver, wait_max_sec).until(
                    EC.visibility_of_element_located((
                        By.ID, 'vm-details-resources-disk')))
                disk_list = disks.find_elements_by_css_selector(
                    "h4[class*='list-group-item-heading']")
                if len(disk_list) > 0:
334 335
                    self.click_on_link(
                        self.get_link_by_href("/op/remove_disk/"))
Csók Tamás committed
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
                    self.wait_and_accept_operation()
                    WebDriverWait(self.driver, wait_max_sec).until(
                        EC.visibility_of_element_located((
                            By.ID, "_activity")))
                    recent_remove_disk = self.recently(
                        self.get_timeline_elements(
                            "vm.Instance.remove_disk"))
                    if not self.check_operation_result(recent_remove_disk):
                        print ("Selenium cannot delete disk "
                               "of the chosen template")
                        raise Exception('Cannot delete disk')
                    WebDriverWait(self.driver, wait_max_sec).until(
                        EC.element_to_be_clickable((
                            By.CSS_SELECTOR,
                            "a[href$='/op/deploy/']")))
351
            self.click_on_link(self.get_link_by_href("/op/deploy/"))
Csók Tamás committed
352 353 354 355 356 357 358 359
            self.wait_and_accept_operation()
            time.sleep(5)
            recent_deploy = self.recently(self.get_timeline_elements(
                "vm.Instance.deploy"))
            if not self.check_operation_result(recent_deploy):
                print ("Selenium cannot deploy the "
                       "chosen template virtual machine")
                raise Exception('Cannot deploy the virtual machine')
360
            self.click_on_link(WebDriverWait(self.driver, wait_max_sec).until(
Csók Tamás committed
361 362
                EC.element_to_be_clickable((
                    By.CSS_SELECTOR,
363
                    "a[href$='/op/shut_off/']"))))
Csók Tamás committed
364 365 366 367 368 369 370 371
            self.wait_and_accept_operation()
            time.sleep(2)
            recent_shut_off = self.recently(self.get_timeline_elements(
                "vm.Instance.shut_off"))
            if not self.check_operation_result(recent_shut_off):
                print ("Selenium cannot shut off the "
                       "chosen template virtual machine")
                raise Exception('Cannot shut off the virtual machine')
372
            self.click_on_link(WebDriverWait(self.driver, wait_max_sec).until(
Csók Tamás committed
373 374
                EC.element_to_be_clickable((
                    By.CSS_SELECTOR,
375
                    "a[href$='/op/save_as_template/']"))))
Csók Tamás committed
376 377
            self.wait_and_accept_operation(name)
            return name
378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
        except:
            raise Exception('Selenium cannot start a template from a base one')

    def delete_template(self, template_id):
        try:
            self.driver.get('%s/dashboard/template/%s/' % (host, template_id))
            self.click_on_link(
                self.get_link_by_href(
                    "/dashboard/template/delete/%s/" % template_id))
            self.wait_and_accept_operation()
            WebDriverWait(self.driver, wait_max_sec).until(
                EC.visibility_of_element_located((
                    By.CLASS_NAME, 'alert-success')))
            url = urlparse.urlparse(self.driver.current_url)
            if "/template/list/" not in url.path:
                raise Exception()
        except:
            raise Exception('Selenium cannot delete the desired template')
Csók Tamás committed
396

397 398 399 400 401 402 403 404 405
    def create_random_vm(self):
        try:
            self.driver.get('%s/dashboard/vm/create/' % host)
            vm_list = []
            pk = None
            vm_list = self.driver.find_elements_by_class_name(
                'vm-create-template-summary')
            choice = random.randint(0, len(vm_list) - 1)
            vm_list[choice].click()
406
            WebDriverWait(self.driver, wait_max_sec).until(
407
                EC.element_to_be_clickable((
408
                    By.CLASS_NAME, 'vm-create-start'))).click()
Csók Tamás committed
409
            WebDriverWait(self.driver, wait_max_sec).until(
410 411 412 413 414 415
                EC.visibility_of_element_located((
                    By.CLASS_NAME, 'alert-success')))
            url = urlparse.urlparse(self.driver.current_url)
            pk = re.search(r'\d+', url.path).group()
            return pk
        except:
Csók Tamás committed
416
            raise Exception('Selenium cannot start a VM')
417 418 419 420 421 422 423 424 425 426 427 428 429 430

    def viewChange(self, target_box):
        driver = self.driver
        driver.get('%s/dashboard/' % host)
        list_view = driver.find_element_by_id('%s-list-view' % target_box)
        graph_view = driver.find_element_by_id('%s-graph-view' % target_box)
        js_script = 'return arguments[0].style.display;'
        required_attributes = {'data-index-box': target_box}
        graph_view_link = self.get_link_by_href(
            '#index-graph-view',
            required_attributes).find_element_by_tag_name('i')
        list_view_link = self.get_link_by_href(
            '#index-list-view',
            required_attributes).find_element_by_tag_name('i')
431
        self.click_on_link(list_view_link)
432 433
        states = [driver.execute_script("%s" % js_script, list_view),
                  driver.execute_script("%s" % js_script, graph_view)]
434
        self.click_on_link(graph_view_link)
435 436
        states.extend([driver.execute_script("%s" % js_script, list_view),
                       driver.execute_script("%s" % js_script, graph_view)])
437
        self.click_on_link(list_view_link)
438 439 440 441 442 443 444 445 446
        states.extend([driver.execute_script("%s" % js_script, list_view),
                       driver.execute_script("%s" % js_script, graph_view)])
        return states

    def delete_vm(self, pk):
        try:
            driver = self.driver
            driver.get('%s/dashboard/vm/%s/' % (host, pk))
            status_span = driver.find_element_by_id('vm-details-state')
447 448 449 450
            self.get_link_by_href(
                "/dashboard/vm/%s/op/destroy/" % pk).click()
            WebDriverWait(self.driver, wait_max_sec).until(
                EC.element_to_be_clickable((By.ID, 'op-form-send'))).click()
Csók Tamás committed
451
            WebDriverWait(status_span, wait_max_sec).until(
452 453 454 455 456 457 458 459
                EC.visibility_of_element_located((
                    By.CLASS_NAME, 'fa-trash-o')))
            return True
        except:
            raise Exception("Selenium can not destroy a VM")


class VmDetailTest(UtilityMixin, SeleniumTestCase):
Csók Tamás committed
460
    template_ids = []
461 462 463 464 465 466 467 468 469 470 471

    @classmethod
    def setup_class(cls):
        cls._user = User.objects.create(username='test_%s' % random_accents,
                                        is_superuser=True)
        cls._user.set_password(random_accents)
        cls._user.save()

    @classmethod
    def teardown_class(cls):
        cls._user.delete()
472

Csók Tamás committed
473 474 475 476 477 478 479 480 481 482
    # def test_01_login(self):
    #     title = 'Dashboard | CIRCLE'
    #     location = '/dashboard/'
    #     self.login('test_%s' % random_accents, random_accents)
    #     self.driver.get('%s/dashboard/' % host)
    #     url = urlparse.urlparse(self.driver.current_url)
    #     (self.assertIn('%s' % title, self.driver.title,
    #                    '%s is not found in the title' % title) or
    #         self.assertEqual(url.path, '%s' % location,
    #                          'URL path is not equal with %s' % location))
483

Csók Tamás committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
    # def test_02_able_to_create_template(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     template_list = None
    #     create_template = self.get_link_by_href('/dashboard/template/choose/')
    #     self.click_on_link(create_template)
    #     WebDriverWait(self.driver, wait_max_sec).until(
    #         EC.visibility_of_element_located((
    #             By.ID, 'create-modal')))
    #     template_list = self.driver.find_elements_by_class_name(
    #         'template-choose-list-element')
    #     print 'Selenium found %s template possibilities' % len(template_list)
    #     (self.assertIsNotNone(
    #         template_list, "Selenium can not find the create template list") or
    #         self.assertGreater(len(template_list), 0,
    #                            "The create template list is empty"))

    # def test_03_create_base_template(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     template_name = self.create_base_template()
    #     self.driver.get('%s/dashboard/template/list/' % host)
    #     templates = self.driver.find_elements_by_css_selector("td.name")
    #     found = False
    #     for template in templates:
    #         if template_name in template.text:
    #             found = True
    #             self.template_ids.append(
    #                 re.search(r'\d+', template.text).group())
    #     self.assertTrue(
    #         found,
    #         "Coud not found the created template in the template list")
514

Csók Tamás committed
515
    def test_04_create_template_from_base(self):
516
        self.login('test_%s' % random_accents, random_accents)
517 518 519 520 521
        created_template_id = self.get_template_id(
            self.create_template_from_base())
        found = created_template_id is not None
        if found:
            self.template_ids.extend(created_template_id)
522 523 524 525
        self.assertTrue(
            found,
            "Coud not found the created template in the template list")

Csók Tamás committed
526
    def test_05_delete_templates(self):
527
        self.login('test_%s' % random_accents, random_accents)
Csók Tamás committed
528
        for template_id in self.template_ids:
529 530 531 532 533 534 535
            self.delete_template(template_id)
            existing_templates = self.get_template_id()
            for template_id in self.template_ids:
                if template_id not in existing_templates:
                    self.template_ids.remove(template_id)
        self.assertListEqual([], self.template_ids,
                             "Could not delete (all) the test template(s)")
536 537


Csók Tamás committed
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
    # def test_10_able_to_create_vm(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     vm_list = None
    #     create_vm_link = self.get_link_by_href('/dashboard/vm/create/')
    #     create_vm_link.click()
    #     WebDriverWait(self.driver, wait_max_sec).until(
    #         EC.visibility_of_element_located((
    #             By.ID, 'create-modal')))
    #     vm_list = self.driver.find_elements_by_class_name(
    #         'vm-create-template-summary')
    #     print ("Selenium found %(vm_number)s virtual machine template "
    #            " possibilities" % {
    #                'vm_number': len(vm_list)})
    #     (self.assertIsNotNone(
    #         vm_list, "Selenium can not find the VM list") or
    #         self.assertGreater(len(vm_list), 0, "The create VM list is empty"))
554

Csók Tamás committed
555 556 557 558
    # def test_11_create_vm(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     pk = self.create_random_vm()
    #     self.assertIsNotNone(pk, "Can not create a VM")
559

Csók Tamás committed
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
    # def test_12_vm_view_change(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     expected_states = ["", "none",
    #                        "none", "",
    #                        "block", "none"]
    #     states = self.viewChange("vm")
    #     print 'states: [%s]' % ', '.join(map(str, states))
    #     print 'expected: [%s]' % ', '.join(map(str, expected_states))
    #     self.assertListEqual(states, expected_states,
    #                          "The view mode does not change for VM listing")

    # def test_13_node_view_change(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     expected_states = ["", "none",
    #                        "none", "",
    #                        "block", "none"]
    #     states = self.viewChange("node")
    #     print 'states: [%s]' % ', '.join(map(str, states))
    #     print 'expected: [%s]' % ', '.join(map(str, expected_states))
    #     self.assertListEqual(states, expected_states,
    #                          "The view mode does not change for NODE listing")

    # def test_14_delete_vm(self):
    #     self.login('test_%s' % random_accents, random_accents)
    #     pk = self.create_random_vm()
    #     self.assertTrue(self.delete_vm(pk), "Can not delete a VM")