def test_export_power(self):
     with session.begin():
         system = data_setup.create_system()
         data_setup.configure_system_power(system,
                                           power_type=u'drac',
                                           address=u'100 East Davie Street',
                                           user=u'Shadowman',
                                           password=u'usethesource',
                                           power_id=u'666')
     login(self.browser)
     csv_request = self.get_csv('power')
     row, = [
         row for row in csv.DictReader(csv_request)
         if row['fqdn'] == system.fqdn
     ]
     self.assertEquals(
         row, {
             'csv_type': 'power',
             'fqdn': system.fqdn,
             'power_type': 'drac',
             'power_address': '100 East Davie Street',
             'power_user': '******',
             'power_passwd': 'usethesource',
             'power_id': '666',
         })
Exemple #2
0
 def test_system_powertype(self):
     excluded = data_setup.create_system()
     data_setup.configure_system_power(excluded, power_type=u'ipmilan')
     included = data_setup.create_system()
     data_setup.configure_system_power(included, power_type=u'virsh')
     self.check_filter("""
         <hostRequires>
             <system><powertype op="=" value="virsh" /></system>
         </hostRequires>
         """,
         present=[included], absent=[excluded])
Exemple #3
0
 def test_system_powertype(self):
     excluded = data_setup.create_system()
     data_setup.configure_system_power(excluded, power_type=u'ipmilan')
     included = data_setup.create_system()
     data_setup.configure_system_power(included, power_type=u'virsh')
     self.check_filter("""
         <hostRequires>
             <system><powertype op="=" value="virsh" /></system>
         </hostRequires>
         """,
         present=[included], absent=[excluded])
 def setUp(self):
     with session.begin():
         self.owner = data_setup.create_user(password=u"owner")
         self.privileged = data_setup.create_user(password=u"privileged")
         self.system = data_setup.create_system(
             owner=self.owner, shared=True, lab_controller=data_setup.create_labcontroller()
         )
         data_setup.configure_system_power(self.system)
         self.system.custom_access_policy.add_rule(permission=SystemPermission.control_system, user=self.privileged)
         self.unprivileged = data_setup.create_user(password=u"unprivileged")
         data_setup.create_running_job(system=self.system)
     self.browser = self.get_browser()
Exemple #5
0
 def check_power_action(self, action, command_actions):
     with session.begin():
         user = data_setup.create_user(password=u'password')
         system = data_setup.create_system()
         data_setup.configure_system_power(system)
         system.lab_controller = self.lab_controller
         system.user = user
     self.server.auth.login_password(user.user_name, 'password')
     self.server.systems.power(action, system.fqdn)
     with session.begin():
         for i, a in enumerate(command_actions):
             self.assertEqual(system.command_queue[i].action, a)
Exemple #6
0
 def test_can_force_powering_system_in_use(self):
     with session.begin():
         owner = data_setup.create_user(password=u'password')
         user = data_setup.create_user()
         system = data_setup.create_system(owner=owner)
         data_setup.configure_system_power(system)
         system.lab_controller = self.lab_controller
         system.user = user
     self.server.auth.login_password(owner.user_name, 'password')
     self.server.systems.power('on', system.fqdn, False, True)
     with session.begin():
         self.assertEqual(system.command_queue[0].action, 'on')
 def test_clear_netboot(self):
     with session.begin():
         user = data_setup.create_user(password=u'password')
         system = data_setup.create_system()
         data_setup.configure_system_power(system)
         system.lab_controller = self.lab_controller
         system.user = None
     self.server.auth.login_password(user.user_name, 'password')
     self.server.systems.power('reboot', system.fqdn, True)
     with session.begin():
         self.assertEqual(system.command_queue[0].action, 'reboot')
         self.assertEqual(system.command_queue[1].action, 'clear_netboot')
 def check_power_action(self, action):
     with session.begin():
         user = data_setup.create_user(password=u'password')
         system = data_setup.create_system()
         data_setup.configure_system_power(system)
         system.lab_controller = self.lab_controller
         system.user = None
     self.server.auth.login_password(user.user_name, 'password')
     self.server.systems.power(action, system.fqdn)
     self.assertEqual(
             System.by_fqdn(system.fqdn, user).command_queue[0].action,
             action)
Exemple #9
0
 def test_clear_netboot(self):
     with session.begin():
         owner = data_setup.create_user(password=u'password')
         system = data_setup.create_system(owner=owner)
         data_setup.configure_system_power(system)
         system.lab_controller = self.lab_controller
         system.user = None
     self.server.auth.login_password(owner.user_name, 'password')
     self.server.systems.power('reboot', system.fqdn, True)
     with session.begin():
         self.assertEqual(system.command_queue[0].action, 'on')
         self.assertEqual(system.command_queue[1].action, 'off')
         self.assertEqual(system.command_queue[2].action, 'clear_netboot')
    def test_errors_when_deleting_referenced_power_type(self):
        with session.begin():
            system = data_setup.create_system(with_power=False)
            data_setup.configure_system_power(system, power_type=u'ilo')
            power_type_count = PowerType.query.count()

        b = self.browser
        b.get(get_server_base() + 'powertypes/')
        b.find_element_by_xpath('//li[contains(., "ilo")]/button').click()

        b.find_element_by_xpath('//div[contains(@class, "alert-error") and '
                'h4/text()="Error deleting power type" and '
                'contains(string(.), "Power type ilo still referenced")]')
        with session.begin():
            self.assertEqual(power_type_count, PowerType.query.count())
Exemple #11
0
 def setUp(self):
     with session.begin():
         self.owner = data_setup.create_user(password=u'owner')
         self.privileged = data_setup.create_user(password=u'privileged')
         self.system = data_setup.create_system(
             owner=self.owner,
             shared=True,
             lab_controller=data_setup.create_labcontroller())
         data_setup.configure_system_power(self.system)
         self.system.custom_access_policy.add_rule(
             permission=SystemPermission.control_system,
             user=self.privileged)
         self.unprivileged = data_setup.create_user(
             password=u'unprivileged')
         data_setup.create_running_job(system=self.system)
     self.browser = self.get_browser()
    def test_errors_when_deleting_referenced_power_type(self):
        with session.begin():
            system = data_setup.create_system(with_power=False)
            data_setup.configure_system_power(system, power_type=u'ilo')
            power_type_count = PowerType.query.count()

        b = self.browser
        b.get(get_server_base() + 'powertypes/')
        b.find_element_by_xpath('//li[contains(., "ilo")]/button').click()

        b.find_element_by_xpath(
            '//div[contains(@class, "alert-error") and '
            'h4/text()="Error deleting power type" and '
            'contains(string(.), "Power type ilo still referenced")]')
        with session.begin():
            self.assertEqual(power_type_count, PowerType.query.count())
Exemple #13
0
 def setUp(self):
     self.lab_controller = data_setup.create_labcontroller()
     self.distro_tree = data_setup.create_distro_tree(osmajor=u'Fedora20',
             arch=u'i386', lab_controllers=[self.lab_controller])
     self.usable_system = data_setup.create_system(arch=u'i386',
             owner=User.by_user_name(data_setup.ADMIN_USER),
             status=u'Manual', shared=True)
     data_setup.configure_system_power(self.usable_system, power_type=u'drac',
             address=u'nowhere.example.com', user=u'teh_powz0r',
             password=u'onoffonoff', power_id=u'asdf')
     self.usable_system.lab_controller = self.lab_controller
     self.usable_system.user = data_setup.create_user(password=u'password')
     self.usable_system.provisions[self.distro_tree.arch] = Provision(
             arch=self.distro_tree.arch,
             kernel_options='ksdevice=eth0 console=ttyS0')
     self.server = self.get_server()
Exemple #14
0
    def test_broken_system_notification_on(self):
        with session.begin():
            owner = data_setup.create_user(
                email_address=u'*****@*****.**')
            lc = data_setup.create_labcontroller()
            system = data_setup.create_system(fqdn=u'home-one',
                                              owner=owner,
                                              lender=u"Uncle Bob's Dodgy Shop",
                                              location=u'shed out the back',
                                              lab_controller=lc,
                                              vendor=u'Acorn',
                                              arch=u'i386')
            system.arch.append(Arch.by_name(u'x86_64'))
            data_setup.configure_system_power(system,
                                              power_type=u'drac',
                                              address=u'pdu2.home-one',
                                              power_id=u'42')

        mail_capture_thread.start_capturing()
        with session.begin():
            bkr.server.mail.broken_system_notify(system, reason="It's a tarp!")
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEqual(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        self.assertEqual(rcpts, ['*****@*****.**'])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], '*****@*****.**')
        self.assertEqual(msg['Subject'],
                         'System home-one automatically marked broken')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-broken')
        self.assertEqual(msg['X-Beaker-System'], 'home-one')
        self.assertEqual(msg['X-Lender'], "Uncle Bob's Dodgy Shop")
        self.assertEqual(msg['X-Location'], 'shed out the back')
        self.assertEqual(msg['X-Lab-Controller'], lc.fqdn)
        self.assertEqual(msg['X-Vendor'], 'Acorn')
        self.assertEqual(msg['X-Type'], 'Machine')
        self.assertEqual(msg.get_all('X-Arch'), ['i386', 'x86_64'])
        self.assertEqual(
            msg.get_payload(decode=True),
            'Beaker has automatically marked system \n'
            'home-one <%sview/home-one> \n'
            'as broken, due to:\n\n'
            'It\'s a tarp!\n\n'
            'Please investigate this error and take appropriate action.\n\n'
            'Power type: drac\n'
            'Power address: pdu2.home-one\n'
            'Power id: 42' % get_server_base())
Exemple #15
0
 def test_broken_system_notification_off(self):
     with session.begin():
         owner = data_setup.create_user(email_address=u'*****@*****.**',
                                        notify_broken_system=False)
         lc = data_setup.create_labcontroller()
         system = data_setup.create_system(fqdn=u'home-two', owner=owner,
                                           lender=u"Aunty Jane's Dodgy Shop",
                                           location=u'shed out the front',
                                           lab_controller=lc,
                                           vendor=u'Acorn', arch=u'i386')
         system.arch.append(Arch.by_name(u'x86_64'))
         data_setup.configure_system_power(system, power_type=u'drac',
                                           address=u'pdu3.home-one',
                                           power_id=u'42')
     mail_capture_thread.start_capturing()
     with session.begin():
         bkr.server.mail.broken_system_notify(system, reason="It's not a tarp!")
     captured_mails = mail_capture_thread.stop_capturing(wait=False)
     self.assertEqual(len(captured_mails), 0)
Exemple #16
0
 def test_broken_system_notification_off(self):
     with session.begin():
         owner = data_setup.create_user(email_address=u'*****@*****.**',
                                        notify_broken_system=False)
         lc = data_setup.create_labcontroller()
         system = data_setup.create_system(fqdn=u'home-two', owner=owner,
                                           lender=u"Aunty Jane's Dodgy Shop",
                                           location=u'shed out the front',
                                           lab_controller=lc,
                                           vendor=u'Acorn', arch=u'i386')
         system.arch.append(Arch.by_name(u'x86_64'))
         data_setup.configure_system_power(system, power_type=u'drac',
                                           address=u'pdu3.home-one',
                                           power_id=u'42')
     mail_capture_thread.start_capturing()
     with session.begin():
         bkr.server.mail.broken_system_notify(system, reason="It's not a tarp!")
     captured_mails = mail_capture_thread.stop_capturing(wait=False)
     self.assertEqual(len(captured_mails), 0)
 def test_export_power(self):
     with session.begin():
         system = data_setup.create_system()
         data_setup.configure_system_power(system, power_type=u'drac',
                 address=u'100 East Davie Street', user=u'Shadowman',
                 password=u'usethesource', power_id=u'666')
     login(self.browser)
     csv_request = self.get_csv('power')
     row, = [row for row in csv.DictReader(csv_request)
             if row['fqdn'] == system.fqdn]
     self.assertEquals(row, {
         'csv_type': 'power',
         'fqdn': system.fqdn,
         'power_type': 'drac',
         'power_address': '100 East Davie Street',
         'power_user': '******',
         'power_passwd': 'usethesource',
         'power_id': '666',
     })
Exemple #18
0
    def test_broken_system_notification_on(self):
        with session.begin():
            owner = data_setup.create_user(email_address=u'*****@*****.**')
            lc = data_setup.create_labcontroller()
            system = data_setup.create_system(fqdn=u'home-one', owner=owner,
                    lender=u"Uncle Bob's Dodgy Shop", location=u'shed out the back',
                    lab_controller=lc, vendor=u'Acorn', arch=u'i386')
            system.arch.append(Arch.by_name(u'x86_64'))
            data_setup.configure_system_power(system, power_type=u'drac',
                    address=u'pdu2.home-one', power_id=u'42')

        mail_capture_thread.start_capturing()
        with session.begin():
            bkr.server.mail.broken_system_notify(system, reason="It's a tarp!")
        captured_mails = mail_capture_thread.stop_capturing()
        self.assertEqual(len(captured_mails), 1)
        sender, rcpts, raw_msg = captured_mails[0]
        self.assertEqual(rcpts, ['*****@*****.**'])
        msg = email.message_from_string(raw_msg)
        self.assertEqual(msg['To'], '*****@*****.**')
        self.assertEqual(msg['Subject'],
                'System home-one automatically marked broken')
        self.assertEqual(msg['X-Beaker-Notification'], 'system-broken')
        self.assertEqual(msg['X-Beaker-System'], 'home-one')
        self.assertEqual(msg['X-Lender'], "Uncle Bob's Dodgy Shop")
        self.assertEqual(msg['X-Location'], 'shed out the back')
        self.assertEqual(msg['X-Lab-Controller'], lc.fqdn)
        self.assertEqual(msg['X-Vendor'], 'Acorn')
        self.assertEqual(msg['X-Type'], 'Machine')
        self.assertEqual(msg.get_all('X-Arch'), ['i386', 'x86_64'])
        self.assertEqual(msg.get_payload(decode=True),
                'Beaker has automatically marked system \n'
                'home-one <%sview/home-one> \n'
                'as broken, due to:\n\n'
                'It\'s a tarp!\n\n'
                'Please investigate this error and take appropriate action.\n\n'
                'Power type: drac\n'
                'Power address: pdu2.home-one\n'
                'Power id: 42'
                % get_server_base())