Example #1
0
 def test_lookup_server(self, mock_run_command):
     server = servers.ServerModel()
     rc = 0
     mock_run_command.return_value = [
         "System Power : off\nPower Overload : false\n", "", rc
     ]
     resp = server.lookup('abc')
     info = {
         'name': 'abc',
         'ipaddr': '127.0.0.1',
         'status': 'off',
     }
     self.assertEquals(info, resp)
Example #2
0
 def test_server_power_on(self, mock_run_command):
     rc = 0
     server = servers.ServerModel()
     if (mock_run_command.call_count == 1):
         mock_run_command.return_value = [
             "System Power : off\nPower Overload : false\n", "", rc
         ]
     else:
         mock_run_command.return_value = [
             "System Power : on\nPower Overload : false\n", "", rc
         ]
     resp = server.poweron('abc')
     self.assertEquals(None, resp)
Example #3
0
 def test_server_power_off_failure(self, mock_run_command):
     server = servers.ServerModel()
     rc = 0
     if (mock_run_command.call_count == 1):
         mock_run_command.return_value = [
             "System Power : on\nPower Overload : false\n", "", rc
         ]
     else:
         rc = 1
         mock_run_command.return_value = [
             "System Power : off\nPower Overload : false\n", "", rc
         ]
     self.assertRaises(OperationFailed, server.poweroff, 'abc')
Example #4
0
 def test_update_server_failure(self, mock_get_config, mock_run_command):
     server = servers.ServerModel()
     rc = 1
     mock_get_config.return_value = {
         u'username': u'Interns',
         u'password': u'baremetal',
         u'ipaddr': u'127.0.0.1',
         u'name': u'abc'
     }
     mock_run_command.return_value = [
         "System Power : off\nPower Overload : false\n", "", rc
     ]
     params = {u'username': u'Interns', u'password': u'wrong_pass'}
     name = 'abc'
     self.assertRaises(OperationFailed, server.update, name, params)
Example #5
0
 def test_update_server(self, mock_get_config, mock_run_command):
     server = servers.ServerModel()
     rc = 0
     mock_get_config.return_value = {
         u'username': u'Interns',
         u'password': u'baremetal',
         u'ipaddr': u'127.0.0.1',
         u'name': u'abc'
     }
     mock_run_command.return_value = [
         "System Power : on\nPower Overload : false\n", "", rc
     ]
     params = {u'username': u'Interns', u'password': u'baremetal'}
     name = 'abc'
     resp = server.update(name, params)
     self.assertEquals('abc', resp)
Example #6
0
 def test_server_remove_without_username(self):
     server1 = servers.ServerModel()
     resp = server1.delete('def')
     self.assertEquals(None, resp)
Example #7
0
 def test_server_remove(self):
     server1 = servers.ServerModel()
     resp = server1.delete('abc')
     self.assertEquals(None, resp)