Example #1
0
 def test_list_registry(self):
     # """ Testing GET /Registries """
     redfish().list_registry()
     registry = self.__get_data()
     logs.debug(dumps(registry, indent=4))
     self.assertNotEqual(0, len(registry), msg='Registry list was empty!')
     self.__class__.__registryList = registry
Example #2
0
 def test_list_schemas(self):
     # """ Testing GET /Schemas """
     redfish().list_schemas()
     schemas = self.__get_data()
     logs.debug(dumps(schemas, indent=4))
     self.assertNotEqual(0, len(schemas), msg='Schema list was empty!')
     self.__class__.__schemaList = schemas
Example #3
0
 def test_post_session(self):
     """ Testing POST /SessionService/Sessions """
     body = {'UserName': '******', 'Password': '******'}
     redfish().post_session(payload=body)
     sessions = self.__get_data()
     self.__session = sessions.get('Id')
     assert_not_equal(None, self.__session)
Example #4
0
 def test_get_systems_actions_reset(self):
     """ Testing GET /Systems/{identifier}/Actions/ComputerSystem.Reset """
     self.__membersList = self.__systemsList.get("Members")
     assert_is_not_none(self.__membersList)
     for member in self.__membersList:
         dataId = member.get("@odata.id")
         assert_is_not_none(dataId)
         dataId = dataId.split("/redfish/v1/Systems/")[1]
         redfish().list_reset_types(dataId)
         reset_actions = self.__get_data()
         LOG.debug(reset_actions, json=True)
         self.__resetActionTypes = reset_actions.get("*****@*****.**")
         assert_equal(
             dumps(self.__resetActionTypes),
             dumps(
                 [
                     "On",
                     "ForceOff",
                     "GracefulShutdown",
                     "GracefulRestart",
                     "ForceRestart",
                     "Nmi",
                     "ForceOn",
                     "PushPowerButton",
                 ]
             ),
         )
Example #5
0
 def test_list_chassis(self):
     # """ Testing GET /Chassis """
     redfish().list_chassis()
     chassis = self.__get_data()
     logs.debug(dumps(chassis, indent=4))
     self.assertNotEqual(0, len(chassis), msg='Chassis list was empty!')
     self.__class__.__chassisList = chassis
Example #6
0
 def test_list_schemas(self):
     """ Testing GET /Schemas """
     redfish().list_schemas()
     schemas = self.__get_data()
     LOG.debug(schemas,json=True)
     assert_not_equal(0, len(schemas), message='Schema list was empty!')
     self.__schemaList = schemas
Example #7
0
 def test_list_schemas(self):
     """ Testing GET /Schemas """
     redfish().list_schemas()
     schemas = self.__get_data()
     LOG.debug(schemas, json=True)
     assert_not_equal(0, len(schemas), message='Schema list was empty!')
     self.__schemaList = schemas
Example #8
0
 def test_list_registry(self):
     # """ Testing GET /Registries """
     redfish().list_registry()
     registry = self.__get_data()
     logs.debug(dumps(registry, indent=4))
     self.assertNotEqual(0, len(registry), msg='Registry list was empty!')
     self.__class__.__registryList = registry
Example #9
0
 def test_get_schema(self):
     # """ Testing GET /Schemas/{identifier} """
     self.__class__.__membersList = self.__class__.__schemaList.get(
         'Members')
     self.assertNotEqual(None, self.__class__.__membersList)
     for member in self.__class__.__membersList:
         dataId = member.get('@odata.id')
         self.assertNotEqual(None, dataId)
         dataId = dataId.split('/redfish/v1/Schemas/')[1]
         redfish().get_schema(dataId)
         schema_ref = self.__get_data()
         logs.debug(dumps(schema_ref, indent=4))
         id = schema_ref.get('Id')
         self.assertEqual(dataId,
                          id,
                          msg='unexpected id {0}, expected {1}'.format(
                              id, dataId))
         self.assertEqual(type(schema_ref.get('Location')),
                          list,
                          msg='expected list not found')
         location = schema_ref.get('Location')[0]
         location_uri = location.get('Uri')
         # avoid python3 hound error by not using the word unicode
         self.assertEqual(
             type(location_uri),
             type(u'unicode_string_type'),
             msg='expected type for Uri not string-like, received {}'.
             format(location_uri))
         self.assertIn(dataId,
                       location_uri,
                       msg='expected dataId {} not in Uri {}'.format(
                           dataId, location_uri))
         self.__class__.__locationUri.append(location.get('Uri'))
Example #10
0
 def test_get_schema_content(self):
     # """ Testing GET /SchemaStore/en/{identifier} """
     self.assertNotEqual([], self.__class__.__locationUri)
     for member in self.__class__.__locationUri:
         self.assertNotEqual(None, member)
         dataId = member.split('/redfish/v1/SchemaStore/en/')[1]
         redfish().get_schema_content(dataId)
Example #11
0
 def test_get_schema_content(self):
     # """ Testing GET /SchemaStore/en/{identifier} """
     self.assertNotEqual([], self.__class__.__locationUri)
     for member in self.__class__.__locationUri:
         self.assertNotEqual(None, member)
         dataId = member.split('/redfish/v1/SchemaStore/en/')[1]
         redfish().get_schema_content(dataId)
 def test_list_registry(self):
     """ Testing GET /Registries """
     redfish().list_registry()
     registry = self.__get_data()
     LOG.debug(registry,json=True)
     assert_not_equal(0, len(registry), message='Registry list was empty!')
     self.__registryList = registry
Example #13
0
    def test_submit_test_event(self):
        """ Testing POST /EventService/SubmitTestEvent  """
        global task
        # Suppose rackhd and test stack have the same localhost
        server = Httpd(port=int(self.__httpd_port),
                       handler_class=self.EventServiceHandler)
        task = WorkerThread(server, 'httpd')
        worker = WorkerTasks(tasks=[task], func=self.__httpd_start)
        worker.run()
        redfish().test_event(body={})
        worker.wait_for_completion(timeout_sec=60)
        if task.timeout:
            # Else port forward rackhd -> localhost
            server = Httpd(port=int(HTTPD_PORT),
                           handler_class=self.EventServiceHandler)
            task = WorkerThread(server, 'httpd')
            worker = WorkerTasks(tasks=[task], func=self.__httpd_start)
            worker.run()

            # forward port for services running on a guest host
            session = open_ssh_forward(self.__httpd_port)

            redfish().test_event(body={})
            worker.wait_for_completion(timeout_sec=60)
            session.logout()
        assert_false(task.timeout,
                     message='timeout waiting for task {0}'.format(task.id))
Example #14
0
 def test_list_chassis(self):
     """ Testing GET /Chassis """
     redfish().list_chassis()
     chassis = self.__get_data()
     LOG.debug(chassis,json=True)
     assert_not_equal(0, len(chassis), message='Chassis list was empty!')
     self.__chassisList = chassis
Example #15
0
    def test_submit_test_event(self):
        """ Testing POST /EventService/SubmitTestEvent  """
        global task
        # Suppose rackhd and test stack have the same localhost
        server = Httpd(port=int(self.__httpd_port), handler_class=self.EventServiceHandler)
        task = WorkerThread(server, 'httpd')
        worker = WorkerTasks(tasks=[task], func=self.__httpd_start)
        worker.run()
        redfish().test_event(body={})
        worker.wait_for_completion(timeout_sec=60)
        if task.timeout:
            # Else port forward rackhd -> localhost
            server = Httpd(port=int(HTTPD_PORT), handler_class=self.EventServiceHandler)
            task = WorkerThread(server, 'httpd')
            worker = WorkerTasks(tasks=[task], func=self.__httpd_start)
            worker.run()

            # forward port for services running on a guest host
            session = open_ssh_forward(self.__httpd_port)

            redfish().test_event(body={})
            worker.wait_for_completion(timeout_sec=60)
            session.logout()
        self.assertFalse(task.timeout, msg='timeout waiting for task {0}'.format(task.id))
        self.assertFalse(self.__class__.eventHandlerFailed, msg='Event handler reported subscriptionId / memberId mismatch')
Example #16
0
 def test_list_chassis(self):
     # """ Testing GET /Chassis """
     redfish().list_chassis()
     chassis = self.__get_data()
     logs.debug(dumps(chassis, indent=4))
     self.assertNotEqual(0, len(chassis), msg='Chassis list was empty!')
     self.__class__.__chassisList = chassis
Example #17
0
 def test_list_schemas(self):
     # """ Testing GET /Schemas """
     redfish().list_schemas()
     schemas = self.__get_data()
     logs.debug(dumps(schemas, indent=4))
     self.assertNotEqual(0, len(schemas), msg='Schema list was empty!')
     self.__class__.__schemaList = schemas
Example #18
0
 def test_get_schema_content(self):
     """ Testing GET /SchemaStore/en/{identifier} """
     assert_not_equal([], self.__locationUri)
     for member in self.__locationUri:
         assert_not_equal(None, member)
         dataId = member.split('/redfish/v1/SchemaStore/en/')[1]
         redfish().get_schema_content(dataId)
         schema_file_contents = self.__get_data()
Example #19
0
 def test_list_managers(self):
     """ Testing GET /Managers """
     redfish().list_managers()
     manager = self.__get_data()
     LOG.debug(manager, json=True)
     assert_not_equal(0, len(manager), message="managers list was empty!")
     self.__managersList = manager.get("Members")
     assert_is_not_none(self.__managersList)
Example #20
0
 def test_list_managers(self):
     """ Testing GET /Managers """
     redfish().list_managers()
     manager = self.__get_data()
     LOG.debug(manager, json=True)
     assert_not_equal(0, len(manager), message='managers list was empty!')
     self.__managersList = manager.get('Members')
     assert_is_not_none(self.__managersList)
Example #21
0
 def test_get_event_subscription(self):
     """ Testing GET /EventService/Subscription/:id  """
     redfish().get_event(subscription.get('Id'))
     data = self.__get_data()
     status = self.__client.last_response.status
     assert_equal(200, status, message='unexpected status')
     assert_equal(subscription.get('Id'), data.get('Id'), \
         message='subscription id not found')
Example #22
0
 def test_get_schema_content(self):
     """ Testing GET /SchemaStore/en/{identifier} """
     assert_not_equal([], self.__locationUri)
     for member in self.__locationUri:
         assert_not_equal(None,member)
         dataId = member.split('/redfish/v1/SchemaStore/en/')[1]
         redfish().get_schema_content(dataId)
         schema_file_contents = self.__get_data()
Example #23
0
 def test_get_event_subscription(self):
     # """ Testing GET /EventService/Subscription/:id  """
     redfish().get_event(subscription.get('Id'))
     data = self.__get_data()
     status = self.__client.last_response.status
     self.assertEqual(200, status, msg='Expected 200 status, received status of {}'.format(status))
     self.assertEqual(subscription.get('Id'), data.get('Id'),
                      msg='subscription id not found')
Example #24
0
 def test_list_systems(self):
     """ Testing GET /Systems """
     redfish().list_systems()
     self.__systemsList = self.__get_data()
     LOG.debug(self.__systemsList, json=True)
     assert_not_equal(0,
                      len(self.__systemsList),
                      message='systems list was empty!')
 def test_event_service_root(self):
     # """ Testing GET /EventService """
     redfish().event_service_root()
     status = self.__client.last_response.status
     self.assertEqual(
         200,
         status,
         msg='Expected 200 status, received status of {}'.format(status))
Example #26
0
 def test_list_systems(self):
     # """ Testing GET /Systems """
     redfish().list_systems()
     self.__class__.__systemsList = self.__get_data()
     logs.debug(dumps(self.__class__.__systemsList, indent=4))
     self.assertNotEqual(0,
                         len(self.__class__.__systemsList),
                         msg='systems list was empty!')
def listThermal():
    redfish().list_chassis()
    membersList = get_data().get('Members')
    if membersList is not None:
        for member in membersList:
            id = member.get('@odata.id').split('/redfish/v1/Chassis/')[1]
            redfish().get_thermal(id)
            pprint()
 def test_get_list_tasks(self):
     """ Testing GET /TaskService/Tasks """
     redfish().list_tasks()
     self.__taskList = self.__get_data()
     LOG.debug(self.__taskList,json=True)
     members = self.__taskList.get('Members')
     assert_is_not_none(members)
     assert_not_equal(0, len(members), message='Task members list was empty!')
Example #29
0
 def test_get_event_subscription(self):
     """ Testing GET /EventService/Subscription/:id  """
     redfish().get_event(subscription.get('Id'))
     data = self.__get_data()
     status = self.__client.last_response.status
     assert_equal(200, status, message='unexpected status')
     assert_equal(subscription.get('Id'), data.get('Id'), \
         message='subscription id not found')
 def test_get_session_service(self):
     """ Testing GET /SessionService """
     redfish().get_session_service()
     service = self.__get_data()
     LOG.debug(service,json=True)
     id = service.get('Id')
     assert_equal('SessionService', id, message='unexpected id {0}, expected {1}'.format(id,'SessionService'))
     sessions = service.get('Sessions')
     assert_not_equal(None, sessions, message='Failed to get sessions')
Example #31
0
 def test_delete_subscriptions(self):
     """ Testing DELETE /EventService/Subscription  """
     redfish().get_events_collection()
     data = self.__get_data()
     for member in data.get('Members'):
         id = member.get('@odata.id').split('/redfish/v1/EventService/Subscriptions/')[1]
         redfish().delete_event(id)
         status = self.__client.last_response.status
         assert_equal(200, status, message='unexpected status on DELETE')
Example #32
0
 def test_get_list_tasks(self):
     # """ Testing GET /TaskService/Tasks """
     redfish().list_tasks()
     self.__class__.__taskList = self.__get_data()
     self.__taskList = self.__class__.__taskList
     logs.debug(dumps(self.__taskList, indent=4))
     members = self.__taskList.get('Members')
     self.assertIsNotNone(members)
     self.assertNotEqual(0, len(members), msg='Task members list was empty!')
Example #33
0
 def test_get_session_service(self):
     # """ Testing GET /SessionService """
     redfish().get_session_service()
     service = self.__get_data()
     logs.debug(dumps(service, indent=4))
     id = service.get('Id')
     self.assertEqual('SessionService', id, msg='unexpected id {0}, expected {1}'.format(id, 'SessionService'))
     sessions = service.get('Sessions')
     self.assertNotEqual(None, sessions, msg='Failed to get sessions')
Example #34
0
 def test_list_managers(self):
     # """ Testing GET /Managers """
     redfish().list_managers()
     manager = self.__get_data()
     logs.debug(dumps(manager, indent=4))
     self.assertNotEqual(0, len(manager), msg='managers list was empty!')
     self.__class__.__managersList = manager.get('Members')
     self.assertIsNotNone(self.__class__.__managersList, msg='Manager members section was not found')
     self.assertNotEqual(len(self.__class__.__managersList), 0, msg='Manager members list is empty')
Example #35
0
 def test_modify_account(self):
     """ Testing PATCH /AcountService/Accounts/{name} """
     body = {'Password': '******', 'RoleId': 'ReadOnly'}
     redfish().modify_account('funtest-name', payload=body)
     redfish().get_account('funtest-name')
     account = self.__get_data()
     assert_equal(account.get('RoleId'),
                  'ReadOnly',
                  message='unexpected RoleId')
Example #36
0
 def test_delete_subscriptions(self):
     """ Testing DELETE /EventService/Subscription  """
     redfish().get_events_collection()
     data = self.__get_data()
     for member in data.get('Members'):
         id = member.get('@odata.id').split(
             '/redfish/v1/EventService/Subscriptions/')[1]
         redfish().delete_event(id)
         status = self.__client.last_response.status
         assert_equal(200, status, message='unexpected status on DELETE')
 def test_remove_account(self):
     # """ Testing DELETE /AcountService/Accounts/{name} """
     redfish().remove_account('funtest-name')
     self.test_get_accounts()
     for member in self.__class__.__accounts:
         dataId = member.get('@odata.id')
         self.assertNotEqual(None, dataId)
         dataId = dataId.split('/redfish/v1/AccountService/Accounts/')[1]
         if dataId == 'funtest-name':
             self.fail(msg='failed to delete account')
 def test_clear_test_account(self):
     # """ Clearing out any existing test Accounts funtest-name """
     self.test_get_accounts()
     for member in self.__class__.__accounts:
         dataId = member.get('@odata.id')
         if dataId:
             dataId = dataId.split('/redfish/v1/AccountService/Accounts/')[1]
             if dataId == 'funtest-name':
                 # If user tries to rerun after a failed test, this should clear out left overs
                 redfish().remove_account('funtest-name')
 def test_remove_account(self):
     redfish().remove_account('funtest-name')
     self.test_get_accounts()
     found = False
     for member in self.__accounts:
         dataId = member.get('@odata.id')
         assert_not_equal(None,dataId)
         dataId = dataId.split('/redfish/v1/AccountService/Accounts/')[1]
         if dataId == 'funtest-name':
             fail(message='failed to delete account')
Example #40
0
 def test_remove_account(self):
     redfish().remove_account('funtest-name')
     self.test_get_accounts()
     found = False
     for member in self.__accounts:
         dataId = member.get('@odata.id')
         assert_not_equal(None, dataId)
         dataId = dataId.split('/redfish/v1/AccountService/Accounts/')[1]
         if dataId == 'funtest-name':
             fail(message='failed to delete account')
 def test_post_session(self):
     """ Testing POST /SessionService/Sessions """
     body = {
         'UserName': '******',
         'Password': '******'
     }
     redfish().post_session(payload=body)
     sessions = self.__get_data()
     self.__session = sessions.get('Id')
     assert_not_equal(None, self.__session)
 def test_get_list_tasks(self):
     """ Testing GET /TaskService/Tasks """
     redfish().list_tasks()
     self.__taskList = self.__get_data()
     LOG.debug(self.__taskList, json=True)
     members = self.__taskList.get('Members')
     assert_is_not_none(members)
     assert_not_equal(0,
                      len(members),
                      message='Task members list was empty!')
Example #43
0
 def test_subscription_collection(self):
     # """ Testing GET /EventService/Subscription  """
     redfish().get_events_collection()
     data = self.__get_data()
     status = self.__client.last_response.status
     self.assertEqual(200, status, msg='Expected 200 status for GET, received status of {}'.format(status))
     ids = []
     for member in data.get('Members'):
         ids.append(member.get('@odata.id').split('/redfish/v1/EventService/Subscriptions/')[1])
     self.assertTrue(subscription.get('Id') in ids, msg='subscription id not found')
 def test_modify_account(self):
     """ Testing PATCH /AcountService/Accounts/{name} """
     body = {
         'Password': '******',
         'RoleId': 'ReadOnly'
     }
     redfish().modify_account('funtest-name', payload=body)
     redfish().get_account('funtest-name')
     account = self.__get_data()
     assert_equal(account.get('RoleId'), 'ReadOnly', message='unexpected RoleId')
 def test_get_registry_file_contents(self):
     """ Testing GET /Registries/en/{identifier} """
     assert_not_equal([], self.__locationUri)
     for member in self.__locationUri:
         assert_not_equal(None,member)
         dataId = member.split('/redfish/v1/Registries/en/')[1]
         redfish().get_registry_file_contents(dataId)
         registry_file_contents = self.__get_data()
         LOG.debug(registry_file_contents,json=True)
         id = registry_file_contents.get('Id')
         assert_equal(dataId, id, message='unexpected id {0}, expected {1}'.format(id,dataId))
Example #46
0
 def test_list_manager_ethernet_interfaces(self):
     """ Testing GET /Managers/{identifier}/EthernetInterfaces """
     for member in self.__managersList:
         dataId = member.get('@odata.id')
         assert_is_not_none(dataId)
         dataId = dataId.split('/redfish/v1/Managers/')[1]
         redfish().list_manager_ethernet_interfaces(dataId)
         interface = self.__get_data()
         LOG.debug(interface, json=True)
         count = interface.get('*****@*****.**')
         assert_true(count >= 1, message='expected count to be >= 1')
Example #47
0
 def test_subscription_collection(self):
     """ Testing GET /EventService/Subscription  """
     redfish().get_events_collection()
     data = self.__get_data()
     status = self.__client.last_response.status
     assert_equal(200, status, message='unexpected status on GET')
     ids = []
     for member in data.get('Members'):
         ids.append(member.get('@odata.id') \
             .split('/redfish/v1/EventService/Subscriptions/')[1])
     assert_true(subscription.get('Id') in ids, message='subscription id not found')
 def test_get_registry_file_contents_invalid(self):
     """ Testing GET /Registries/en/{identifier} 404s properly """
     assert_not_equal([], self.__locationUri)
     for member in self.__locationUri:
         assert_not_equal(None,member)
         dataId = member.split('/redfish/v1/Registries/en/')[1]
         try:
             redfish().get_registry_file_contents(dataId + '-invalid')
             fail(message='did not raise exception')
         except rest.ApiException as e:
             assert_equal(404, e.status, message='unexpected response {0}, expected 404'.format(e.status))
Example #49
0
 def test_get_manager(self):
     # """ Testing GET /Managers/{identifier} """
     for member in self.__class__.__managersList:
         dataId = member.get('@odata.id')
         self.assertIsNotNone(dataId)
         dataId = dataId.split('/redfish/v1/Managers/')[1]
         redfish().get_manager(dataId)
         manager = self.__get_data()
         logs.debug(dumps(manager, indent=4))
         id = manager.get('Id')
         self.assertEqual(dataId, id, msg='unexpected id {0}, expected {1}'.format(id, dataId))
Example #50
0
 def test_list_manager_ethernet_interfaces(self):
     # """ Testing GET /Managers/{identifier}/EthernetInterfaces """
     for member in self.__class__.__managersList:
         dataId = member.get('@odata.id')
         self.assertIsNotNone(dataId)
         dataId = dataId.split('/redfish/v1/Managers/')[1]
         redfish().list_manager_ethernet_interfaces(dataId)
         interface = self.__get_data()
         logs.debug(dumps(interface, indent=4))
         count = interface.get('*****@*****.**')
         self.assertTrue(count >= 1, msg='expected count to be >= 1')
Example #51
0
 def test_list_manager_ethernet_interfaces_invalid(self):
     # """ Testing GET /Managers/{identifier}/EthernetInterfaces 404s properly """
     for member in self.__class__.__managersList:
         dataId = member.get('@odata.id')
         self.assertIsNotNone(dataId)
         dataId = dataId.split('/redfish/v1/Managers/')[1]
         try:
             redfish().list_manager_ethernet_interfaces(dataId + '1')
             self.fail(msg='did not raise exception')
         except rest.ApiException as e:
             self.assertEqual(404, e.status, msg='unexpected response {0}, expected 404'.format(e.status))
Example #52
0
 def test_get_registry_file_contents(self):
     # """ Testing GET /Registries/en/{identifier} """
     self.assertNotEqual([], self.__class__.__locationUri)
     for member in self.__class__.__locationUri:
         self.assertNotEqual(None, member)
         dataId = member.split('/redfish/v1/Registries/en/')[1]
         redfish().get_registry_file_contents(dataId)
         registry_file_contents = self.__get_data()
         logs.debug(dumps(registry_file_contents, indent=4))
         id = registry_file_contents.get('Id')
         self.assertEqual(dataId, id, msg='unexpected id {0}, expected {1}'.format(id, dataId))
Example #53
0
 def test_get_registry_file_contents_invalid(self):
     # """ Testing GET /Registries/en/{identifier} 404s properly """
     self.assertNotEqual([], self.__class__.__locationUri)
     for member in self.__class__.__locationUri:
         self.assertNotEqual(None, member)
         dataId = member.split('/redfish/v1/Registries/en/')[1]
         try:
             redfish().get_registry_file_contents(dataId + '-invalid')
             self.fail(msg='did not raise exception')
         except rest.ApiException as e:
             self.assertEqual(404, e.status, msg='unexpected response {0}, expected 404'.format(e.status))