Exemplo n.º 1
0
    def process_json(self, redfishConfig, url):

        # Don't attempt to purge if a session is not active
        sessionId = Label.decode(config.sessionIdVariable)
        if sessionId is None:
            Trace.log(
                TraceLevel.INFO,
                '-- A valid session ({}) was not found!'.format(sessionId))
            return

        # Purge all StorageGroups
        ids = super().get_members_list(self, redfishConfig, 'StorageGroups')
        super().delete_id_list(
            self, redfishConfig,
            RedfishSystem.get_uri(redfishConfig, 'StorageGroups'), ids)

        # Purge all Volumes
        ids = super().get_members_list(self, redfishConfig, 'Volumes')
        super().delete_id_list(self, redfishConfig,
                               RedfishSystem.get_uri(redfishConfig, 'Volumes'),
                               ids)

        # Purge all StoragePools
        ids = super().get_members_list(self, redfishConfig, 'StoragePools',
                                       'A B')
        super().delete_id_list(
            self, redfishConfig,
            RedfishSystem.get_uri(redfishConfig, 'StoragePools'), ids)
Exemplo n.º 2
0
    def display_results(self, redfishConfig):

        if (redfishConfig.sessionValid == True):
            Trace.log(
                TraceLevel.INFO,
                '[] Redfish session established ({}:{})'.format(
                    Label.decode(config.sessionIdVariable),
                    redfishConfig.sessionKey))
        else:
            Trace.log(
                TraceLevel.ERROR,
                'Unable to establish a Redfish session, connection, check ip address, username and password'
            )
Exemplo n.º 3
0
    def delete_id_list(self, redfishConfig, startUrl, ids):

        Trace.log(
            TraceLevel.DEBUG,
            '   ++ delete_id_list ids ({}) using start URL ({})'.format(
                len(ids), startUrl))

        successes = 0

        if (len(ids) >= 1):
            Trace.log(TraceLevel.INFO, ' ')
            for i in range(len(ids)):
                url = startUrl + Label.decode(ids[i], ids[i], 0)
                Trace.log(TraceLevel.INFO, '[] DELETE ({0})'.format(url))
                link = UrlAccess.process_request(redfishConfig, UrlStatus(url),
                                                 'DELETE', True)
                Trace.log(
                    TraceLevel.INFO, '   -- status={}, reason={}'.format(
                        link.urlStatus, link.urlReason))
                if (redfishConfig.get_bool('dumphttpdata')
                        and link.jsonData is not None):
                    Trace.log(TraceLevel.INFO,
                              '   -- httpData {}'.format(link.jsonData))

                if (link.urlStatus == 200):
                    successes += 1
                else:
                    Trace.log(TraceLevel.DEBUG,
                              '   -- response {}'.format(link.response))
                    Trace.log(TraceLevel.DEBUG,
                              '   -- urlData {}'.format(link.urlData))
                    Trace.log(TraceLevel.DEBUG,
                              '   -- jsonData {}'.format(link.jsonData))

        if (successes > 1):
            Trace.log(TraceLevel.INFO,
                      '({}) DELETE commands were successful'.format(successes))

        return (successes)
Exemplo n.º 4
0
    def test_links(self):
        Trace.log(
            TraceLevel.VERBOSE, '>> Run {}.{}:{}'.format(
                type(self).__name__,
                sys._getframe().f_code.co_name,
                sys._getframe().f_lineno))
        url = self.versionUrl
        link = UrlAccess.process_request(self.redfishConfig, UrlStatus(url),
                                         'GET', False, None)
        TestSupport.test_link_status(self, link, url)

        RedfishCommand.execute(self.redfishConfig, 'create session')

        odataIds = JsonExtract.get_values(link.jsonData, "@odata.id")
        for url in odataIds:
            link = UrlAccess.process_request(self.redfishConfig,
                                             UrlStatus(url), 'GET', True, None)
            self.assertTrue(link.valid, 'Link valid for URL ({})'.format(url))

        # Delete any current active session
        sessionId = Label.decode(config.sessionIdVariable)
        if sessionId is not None:
            RedfishCommand.execute(self.redfishConfig,
                                   f'delete sessions {sessionId}')
Exemplo n.º 5
0
 def tearDownClass(cls):
     # Delete any current active session
     sessionId = Label.decode(config.sessionIdVariable)
     if sessionId is not None:
         RedfishCommand.execute(cls.redfishConfig,
                                f'delete sessions {sessionId}')
Exemplo n.º 6
0
 def setUpClass(cls):
     cls.redfishConfig = RedfishConfig(Label.decode(config.sessionConfig))
     RedfishCommand.execute(cls.redfishConfig, 'create session')
     cls.systemInitialized = RedfishSystem.initialize_system(
         cls.redfishConfig)
Exemplo n.º 7
0
        help=
        'Set the trace level (4, 5, 6, or 7) INFO=4, VERBOSE=5, DEBUG=5, TRACE=6',
        nargs='?',
        const=1,
        type=int)

    args = parser.parse_args()

    # Load configuration settings, which can be overwritten at the command line or in a script file
    redfishConfig = RedfishConfig(config.defaultConfigFile if args.config ==
                                  None else args.config)

    if (args.tracelevel != None):
        redfishConfig.update('trace', args.tracelevel)

    if (args.scriptfile == None):
        # Run interactive mode
        ri = RedfishInteractive()
        ri.execute(redfishConfig)
    else:
        # Run script mode
        returncode = RedfishScript.execute_script(redfishConfig,
                                                  args.scriptfile)

    # Before existing, delete any current active session
    sessionId = Label.decode(config.sessionIdVariable)
    if sessionId is not None:
        RedfishCommand.execute(redfishConfig, f'delete sessions {sessionId}')

    sys.exit(returncode)
Exemplo n.º 8
0
 def setUpClass(cls):
     cls.root = '/redfish'
     cls.version = 'v1'
     cls.versionUrl = '/redfish/v1/'
     cls.redfishConfig = RedfishConfig(Label.decode(config.sessionConfig))