Пример #1
0
    def test_exec_ipmitool(self):
        pw_file = '/tmp/password_file'

        self.mox.StubOutWithMock(ipmi, '_make_password_file')
        self.mox.StubOutWithMock(utils, 'execute')
        self.mox.StubOutWithMock(bm_utils, 'unlink_without_raise')
        ipmi._make_password_file(self.ipmi.password).AndReturn(pw_file)
        args = [
            'ipmitool',
            '-I',
            'lanplus',
            '-H',
            self.ipmi.address,
            '-U',
            self.ipmi.user,
            '-f',
            pw_file,
            'A',
            'B',
            'C',
        ]
        utils.execute(*args, attempts=3).AndReturn(('', ''))
        bm_utils.unlink_without_raise(pw_file).AndReturn(None)
        self.mox.ReplayAll()

        self.ipmi._exec_ipmitool('A B C')
        self.mox.VerifyAll()
Пример #2
0
    def test_exec_ipmitool(self):
        H = 'address'
        U = 'user'
        P = 'password'
        I = 'lanplus'
        F = 'password_file'

        n1 = utils.new_bm_node(
                pm_address=H,
                pm_user=U,
                pm_password=P)

        self.mox.StubOutWithMock(ipmi, '_make_password_file')
        self.mox.StubOutWithMock(nova_utils, 'execute')
        self.mox.StubOutWithMock(ipmi, '_unlink_without_raise')
        ipmi._make_password_file(P).AndReturn(F)
        args = [
                'ipmitool',
                '-I', I,
                '-H', H,
                '-U', U,
                '-f', F,
                'A', 'B', 'C',
                ]
        nova_utils.execute(*args, attempts=3).AndReturn(('', ''))
        ipmi._unlink_without_raise(F).AndReturn(None)
        self.mox.ReplayAll()

        i = ipmi.Ipmi(n1)
        i._exec_ipmitool('A B C')
        self.mox.VerifyAll()
Пример #3
0
    def test_exec_ipmitool(self):
        H = 'address'
        U = 'user'
        P = 'password'
        I = 'lanplus'
        F = 'password_file'

        n1 = utils.new_bm_node(pm_address=H, pm_user=U, pm_password=P)

        self.mox.StubOutWithMock(ipmi, '_make_password_file')
        self.mox.StubOutWithMock(nova_utils, 'execute')
        self.mox.StubOutWithMock(ipmi, '_unlink_without_raise')
        ipmi._make_password_file(P).AndReturn(F)
        args = [
            'ipmitool',
            '-I',
            I,
            '-H',
            H,
            '-U',
            U,
            '-f',
            F,
            'A',
            'B',
            'C',
        ]
        nova_utils.execute(*args, attempts=3).AndReturn(('', ''))
        ipmi._unlink_without_raise(F).AndReturn(None)
        self.mox.ReplayAll()

        i = ipmi.Ipmi(n1)
        i._exec_ipmitool('A B C')
        self.mox.VerifyAll()
Пример #4
0
    def test_exec_ipmitool(self):
        pw_file = "/tmp/password_file"

        self.mox.StubOutWithMock(ipmi, "_make_password_file")
        self.mox.StubOutWithMock(utils, "execute")
        self.mox.StubOutWithMock(bm_utils, "unlink_without_raise")
        ipmi._make_password_file(self.ipmi.password).AndReturn(pw_file)
        args = [
            "ipmitool",
            "-I",
            "lanplus",
            "-H",
            self.ipmi.address,
            "-U",
            self.ipmi.user,
            "-f",
            pw_file,
            "A",
            "B",
            "C",
        ]
        utils.execute(*args, attempts=3).AndReturn(("", ""))
        bm_utils.unlink_without_raise(pw_file).AndReturn(None)
        self.mox.ReplayAll()

        self.ipmi._exec_ipmitool("A B C")
        self.mox.VerifyAll()
Пример #5
0
 def test_make_password_file(self):
     pw_file = ipmi._make_password_file(self.node['pm_password'])
     try:
         self.assertTrue(os.path.isfile(pw_file))
         self.assertEqual(os.stat(pw_file)[stat.ST_MODE] & 0o777, 0o600)
         with open(pw_file, "r") as f:
             pm_password = f.read()
         self.assertEqual(pm_password, self.node['pm_password'])
     finally:
         os.unlink(pw_file)
Пример #6
0
 def test_make_password_file(self):
     pw_file = ipmi._make_password_file(self.node['pm_password'])
     try:
         self.assertTrue(os.path.isfile(pw_file))
         self.assertEqual(os.stat(pw_file)[stat.ST_MODE] & 0o777, 0o600)
         with open(pw_file, "r") as f:
             pm_password = f.read()
         self.assertEqual(pm_password, self.node['pm_password'])
     finally:
         os.unlink(pw_file)
Пример #7
0
 def test_make_empty_password_file(self):
     pw_file = ipmi._make_password_file('')
     try:
         self.assertTrue(os.path.isfile(pw_file))
         self.assertEqual(os.stat(pw_file)[stat.ST_MODE] & 0o777, 0o600)
         with open(pw_file, "rb") as f:
             pm_password = f.read()
         self.assertEqual(b"\0", pm_password)
     finally:
         os.unlink(pw_file)
Пример #8
0
 def test_make_empty_password_file(self):
     pw_file = ipmi._make_password_file('')
     try:
         self.assertTrue(os.path.isfile(pw_file))
         self.assertEqual(os.stat(pw_file)[stat.ST_MODE] & 0o777, 0o600)
         with open(pw_file, "rb") as f:
             pm_password = f.read()
         self.assertEqual(b"\0", pm_password)
     finally:
         os.unlink(pw_file)
Пример #9
0
 def test_make_password_file(self):
     PASSWORD = '******'
     path = ipmi._make_password_file(PASSWORD)
     self.assertTrue(os.path.isfile(path))
     self.assertEqual(os.stat(path)[stat.ST_MODE] & 0777, 0600)
     try:
         with open(path, "r") as f:
             s = f.read(100)
         self.assertEqual(s, PASSWORD)
     finally:
         os.unlink(path)
Пример #10
0
 def test_make_password_file(self):
     PASSWORD = '******'
     path = ipmi._make_password_file(PASSWORD)
     self.assertTrue(os.path.isfile(path))
     self.assertEqual(os.stat(path)[stat.ST_MODE] & 0777, 0600)
     try:
         with open(path, "r") as f:
             s = f.read(100)
         self.assertEqual(s, PASSWORD)
     finally:
         os.unlink(path)
Пример #11
0
    def test_exec_ipmitool(self):
        pw_file = '/tmp/password_file'

        self.mox.StubOutWithMock(ipmi, '_make_password_file')
        self.mox.StubOutWithMock(utils, 'execute')
        self.mox.StubOutWithMock(bm_utils, 'unlink_without_raise')
        ipmi._make_password_file(self.ipmi.password).AndReturn(pw_file)
        args = [
                'ipmitool',
                '-I', 'lanplus',
                '-H', self.ipmi.address,
                '-U', self.ipmi.user,
                '-f', pw_file,
                'A', 'B', 'C',
                ]
        utils.execute(*args, attempts=3).AndReturn(('', ''))
        bm_utils.unlink_without_raise(pw_file).AndReturn(None)
        self.mox.ReplayAll()

        self.ipmi._exec_ipmitool('A B C')
        self.mox.VerifyAll()