Beispiel #1
0
    def do_updatepolicy( self, dict_handler = None ):
        info = None
        policy = None
        jobid= None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            policy = next((item for item in [dict_handler.get('p'), dict_handler.get('policy')] if item is not None),
                          None)
            info = next((item for item in [dict_handler.get('i'), dict_handler.get('info')] if item is not None), None)
            uuid = next((item for item in [dict_handler.get('u'), dict_handler.get('uuid')] if item is not None), None)
            jobid = next((item for item in [dict_handler.get('j'), dict_handler.get('jobid')] if item is not None),
                         None)
            type = next((item for item in [dict_handler.get('t'), dict_handler.get('type')] if item is not None),
                         None)

        if policy:
            resp = lxca_rest().post_updatepolicy(self.con.get_url(), self.con.get_session(), policy, type, uuid)
        else:
            resp = lxca_rest().get_updatepolicy(self.con.get_url(), self.con.get_session(), info, jobid, uuid)

        try:
            py_obj = json.loads(resp.text)
            if info == "RESULTS":
                py_obj = py_obj["all"]
        except AttributeError as ValueError:
            return resp
        return py_obj
Beispiel #2
0
 def get_nodes( self, dict_handler = None ):
     uuid = None
     status = None
     chassis_uuid = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
         modify = next((item for item in [dict_handler.get('m'), dict_handler.get('modify')] if item is not None), None)
         status = next((item for item in [dict_handler.get('s') , dict_handler.get('status')] if item is not None),None)
         chassis_uuid = next((item for item in [dict_handler.get('c') , dict_handler.get('chassis')] if item is not None),None)
         
     if chassis_uuid:
         resp = lxca_rest().get_chassis(self.con.get_url(),self.con.get_session(),chassis_uuid,status)
         py_obj = json.loads(resp.text)
         py_obj = {'nodesList':py_obj["nodes"]}
     if uuid and modify:
         resp = lxca_rest().set_nodes(self.con.get_url(), self.con.get_session(), uuid, modify)
         py_obj = json.loads(resp.text)
     else:
         resp = lxca_rest().get_nodes(self.con.get_url(),self.con.get_session(),uuid,status)
         py_obj = json.loads(resp.text)
     return py_obj
Beispiel #3
0
    def get_set_compositeResults(self, dict_handler=None):
        id = None
        query_solutionGroups = None
        solutionGroups = None
        targetResources = None
        all_rules = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            id = next((item for item in [dict_handler.get('i'), dict_handler.get('id')] if item is not None),
                        None)
            query_solutionGroups = next((item for item in
                [dict_handler.get('q'), dict_handler.get('query_solutionGroups')] if item is not None),
                      None)
            solutionGroups = next((item for item in [dict_handler.get('s'),
                dict_handler.get('solutionGroups')] if item is not None),
                             None)
            targetResources = next(
                (item for item in [dict_handler.get('t'), dict_handler.get('targetResources')] if item is not None),
                None)
            all_rules = next(
                (item for item in [dict_handler.get('a'), dict_handler.get('all_rules')] if item is not None),
                None)

        if all_rules or solutionGroups or targetResources:
            resp = lxca_rest().set_compositeResults(self.con.get_url(),
                    self.con.get_session(), solutionGroups, targetResources, all_rules)
        else:
            resp = lxca_rest().get_compositeResults(self.con.get_url(),
                    self.con.get_session(), id, query_solutionGroups)
        py_obj = json.loads(resp.text)
        return py_obj
Beispiel #4
0
    def do_managementserver(self, dict_handler=None):
        key = None
        action = None
        fixids = None
        type = None
        jobid = None
        files = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            key = next((item for item in [dict_handler.get('k'), dict_handler.get('key')] if item is not None), None)
            action = next((item for item in [dict_handler.get('subcmd')] if item is not None),
                          None)
            fixids = next((item for item in [dict_handler.get('f'), dict_handler.get('fixids')] if item is not None),
                          None)
            type = next((item for item in [dict_handler.get('t'), dict_handler.get('type')] if item is not None), None)
            jobid = next((item for item in [dict_handler.get('j'), dict_handler.get('jobid')] if item is not None), None)
            files = next((item for item in [dict_handler.get('files')] if item is not None),       None)
        if key or type:
            resp = lxca_rest().get_managementserver(self.con.get_url(), self.con.get_session(), key, fixids, type)
        elif action:
            resp = lxca_rest().set_managementserver(self.con.get_url(), self.con.get_session(), action, files, jobid, fixids)

        try:
            py_obj = json.loads(resp.text)
        except AttributeError as ValueError:
            return resp
        py_obj['dummy']={'status':[]}
        return py_obj
Beispiel #5
0
    def get_configprofiles( self, dict_handler = None ):
        profileid = None
        profilename = None
        endpoint = None
        restart = None
        subcmd = None
        powerdown = None
        resetimm = None
        resetswitch = None
        force = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            profileid = next((item for item in [dict_handler.get  ('i') , dict_handler.get('id')] if item is not None),None)
            profilename = next((item for item in [dict_handler.get('n'), dict_handler.get('name')] if item is not None),
                             None)
            endpoint = next(
                (item for item in [dict_handler.get('e'), dict_handler.get('endpoint')] if item is not None), None)
            restart = next((item for item in [dict_handler.get('r'), dict_handler.get('restart')] if item is not None),
                           None)
            subcmd = next((item for item in [dict_handler.get('subcmd')] if item is not None),
                           None)
            powerdown = next((item for item in [dict_handler.get('p'), dict_handler.get('powerdown')] if item is not None),
                None)
            resetimm = next(
                (item for item in [dict_handler.get('resetimm')] if item is not None),
                None)
            resetswitch = next(
                (item for item in [dict_handler.get('resetswitch')] if item is not None),
                None)

            force = next((item for item in [dict_handler.get('f'), dict_handler.get('force')] if item is not None),
                         None)

        if subcmd == 'rename' and profilename:
            resp = lxca_rest().put_configprofiles(self.con.get_url(), self.con.get_session(), profileid, profilename)
        elif subcmd == 'activate' and endpoint and restart:
            resp = lxca_rest().post_configprofiles(self.con.get_url(), self.con.get_session(), profileid, endpoint, restart)
        elif subcmd == 'delete' and profileid:
            resp = lxca_rest().delete_configprofiles(self.con.get_url(), self.con.get_session(), profileid)
        elif subcmd == 'unassign' and profileid:
            resp = lxca_rest().unassign_configprofiles(self.con.get_url(), self.con.get_session(), profileid, powerdown, resetimm, resetswitch, force)
            if len(resp.text):
                py_obj = json.loads(resp.text)
                py_obj['dummy'] = {'status': []}
                return py_obj

        elif subcmd == 'list':
            resp = lxca_rest().get_configprofiles(self.con.get_url(),self.con.get_session(),profileid)

        try:
            if len(resp.text):
                py_obj = json.loads(resp.text)
                return py_obj
            elif resp.status_code == 204:   # Its success for rename of profile with empty text
                return { 'ID':profileid, 'name':profilename}
        except AttributeError as ValueError:
            return resp
Beispiel #6
0
    def get_set_rules(self, dict_handler=None):
        id = None
        name = None
        targetResourceType = None
        targetGroup = None
        content = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            id = next((item for item in [dict_handler.get('i'), dict_handler.get('id')] if item is not None),
                        None)
            name = next((item for item in [dict_handler.get('n'), dict_handler.get('name')] if item is not None),
                             None)
            targetResourceType = next((item for item in [dict_handler.get('t'), dict_handler.get('targetResourceType')] if item is not None),
                               None)
            targetGroup = next((item for item in [dict_handler.get('g'), dict_handler.get('targetGroup')] if item is not None),
                             None)
            content = next((item for item in [dict_handler.get('c'), dict_handler.get('content')] if item is not None),
                               None)

        if name:
            resp = lxca_rest().set_rules(self.con.get_url(), self.con.get_session(), name, targetResourceType, targetGroup, content)
        else:
            resp = lxca_rest().get_rules(self.con.get_url(), self.con.get_session(), id)
        py_obj = json.loads(resp.text)
        return py_obj
Beispiel #7
0
    def get_set_tasks(self, dict_handler=None):
        job_uuid = None
        includeChildren = False
        action = None
        status = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            job_uuid = next((item for item in [ dict_handler.get('jobUID')] if item is not None), None)
            includeChildren = next((item for item in [ dict_handler.get('children')] if item is not None), "false")
            if includeChildren != "false":
                includeChildren = 'true'
            action = next((item for item in [dict_handler.get('action')] if item is not None), None)
            updateList = next((item for item in [dict_handler.get('updateList')] if item is not None), None)
            #state = next((item for item in [dict_handler.get('state')] if item is not None), None)

        if job_uuid and action in ['cancel', 'delete']:
            resp = lxca_rest().put_tasks(self.con.get_url(), self.con.get_session(), job_uuid, action)
            py_obj = resp.status_code
        elif action in ['update']:
            resp = lxca_rest().put_tasks_update(self.con.get_url(), self.con.get_session(), updateList)
            py_obj = resp.status_code
        elif job_uuid:
            resp = lxca_rest().get_tasks_list(self.con.get_url(), self.con.get_session(), job_uuid, includeChildren)
            py_obj = json.loads(resp.text)
            py_obj = {'TaskList': py_obj[:]}
        else:
            resp = lxca_rest().get_tasks(self.con.get_url(), self.con.get_session())
            py_obj = json.loads(resp.text)
            py_obj = {'TaskList': py_obj[:]}
        return py_obj
Beispiel #8
0
    def get_switches( self, dict_handler = None ):
        uuid = None
        chassis_uuid = None
        port_name = None
        list_port = None
        action = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")
        
        if dict_handler:
            uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
            chassis_uuid = next((item for item in [dict_handler.get('c') , dict_handler.get('chassis')] if item is not None),None)
            port_name = next((item for item in [dict_handler.get('ports')] if item is not None),None)
            action = next((item for item in [dict_handler.get('action')] if item is not None),
                             None)
            #if "ports" in dict_handler: list_port = True
            if port_name: list_port = True

        if chassis_uuid:
            resp = lxca_rest().get_chassis(self.con.get_url(),self.con.get_session(),chassis_uuid,None)
            py_obj = json.loads(resp.text)
            py_obj = {'switchesList':py_obj["switches"]}
        elif list_port and (action==None):
            resp = lxca_rest().get_switches_port(self.con.get_url(), self.con.get_session(), uuid, list_port)
            py_obj = json.loads(resp.text)
        elif port_name and action:
            resp = lxca_rest().put_switches_port(self.con.get_url(), self.con.get_session(), uuid, port_name, action)
            py_obj = json.loads(resp.text)
        else:
            resp = lxca_rest().get_switches(self.con.get_url(),self.con.get_session(),uuid)
            py_obj = json.loads(resp.text)
        return py_obj
Beispiel #9
0
    def get_updaterepo( self, dict_handler = None ):
        key = None
        action = None
        mt = None
        scope = None
        fixids = None
        type = None
        
        if not self.con:
            raise ConnectionError("Connection is not Initialized.")
        
        if dict_handler:
            key = next((item for item in [dict_handler.get('k'), dict_handler.get('key')] if item is not None), None)
            action = next((item for item in [dict_handler.get('subcmd')] if item is not None), None)
            mt = next((item for item in [dict_handler.get('m'), dict_handler.get('mt')] if item is not None), None)
            scope = next((item for item in [dict_handler.get('s'), dict_handler.get('scope')] if item is not None), None)
            fixids = next((item for item in [dict_handler.get('f'), dict_handler.get('fixids')] if item is not None), None)
            type = next((item for item in [dict_handler.get('t'), dict_handler.get('type')] if item is not None), None)

        if key:
            resp = lxca_rest().get_updaterepo(self.con.get_url(),self.con.get_session(), key, mt, scope)
        elif action:
            resp = lxca_rest().put_updaterepo(self.con.get_url(), self.con.get_session(), action, fixids, mt, type, scope)
        else:
            raise Exception("Invalid argument")

        try:
            py_obj = json.loads(resp.text)
        except AttributeError as ValueError:
            return resp
        return py_obj
Beispiel #10
0
 def set_log_level(self, log_value):
     try:
         lxca_rest().set_log_level(log_value)
         logger.debug("Current Log Level is now set to " + str(logger.getEffectiveLevel()))
     except Exception as e:
         logger.error("Fail to set Log Level")
         return False
     return True
Beispiel #11
0
    def get_configprofiles( self, dict_handler = None ):
        profileid = None
        profilename = None
        endpoint = None
        restart = None
        delete = None
        unassign = None
        powerdown = None
        resetimm = None
        force = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            profileid = next((item for item in [dict_handler.get  ('i') , dict_handler.get('id')] if item is not None),None)
            profilename = next((item for item in [dict_handler.get('n'), dict_handler.get('name')] if item is not None),
                             None)
            endpoint = next(
                (item for item in [dict_handler.get('e'), dict_handler.get('endpoint')] if item is not None), None)
            restart = next((item for item in [dict_handler.get('r'), dict_handler.get('restart')] if item is not None),
                           None)
            delete = next((item for item in [dict_handler.get('d'), dict_handler.get('delete')] if item is not None),
                           None)
            unassign = next((item for item in [dict_handler.get('u'), dict_handler.get('unassign')] if item is not None),
                          None)
            powerdown = next((item for item in [dict_handler.get('p'), dict_handler.get('powerdown')] if item is not None),
                None)
            resetimm = next(
                (item for item in [dict_handler.get('resetimm')] if item is not None),
                None)
            force = next((item for item in [dict_handler.get('f'), dict_handler.get('force')] if item is not None),
                         None)

        if profilename:
            resp = lxca_rest().put_configprofiles(self.con.get_url(), self.con.get_session(), profileid, profilename)
        elif endpoint and restart:
            resp = lxca_rest().post_configprofiles(self.con.get_url(), self.con.get_session(), profileid, endpoint, restart)
        elif profileid and delete and delete.lower() == 'true':
                resp = lxca_rest().delete_configprofiles(self.con.get_url(), self.con.get_session(), profileid)
        elif profileid and unassign and unassign.lower() == 'true':
                resp = lxca_rest().unassign_configprofiles(self.con.get_url(), self.con.get_session(), profileid, powerdown, resetimm, force)
        else:
            resp = lxca_rest().get_configprofiles(self.con.get_url(),self.con.get_session(),profileid)

        try:
            if len(resp.text):
                py_obj = json.loads(resp.text)
                return py_obj
            elif resp.status_code == 204:   # Its success for rename of profile with empty text
                return { 'ID':profileid, 'name':profilename}
        except AttributeError as ValueError:
            return resp
Beispiel #12
0
    def do_configpatterns( self, dict_handler = None ):
        patternid = None
        patternname = None
        includeSettings = None
        endpoint = None
        restart = None
        etype = None
        pattern_update_dict = None
        subcmd = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            patternid = next((item for item in [dict_handler.get  ('i') , dict_handler.get('id')] if item is not None),None)
            patternname = next((item for item in [dict_handler.get('n'), dict_handler.get('name')] if item is not None),
                             None)
            includeSettings = next((item for item in [dict_handler.get('includeSettings')] if item is not None),None)
            endpoint = next((item for item in [dict_handler.get  ('e') , dict_handler.get('endpoint')] if item is not None),None)
            restart = next((item for item in [dict_handler.get  ('r') , dict_handler.get('restart')] if item is not None),None)
            etype = next((item for item in [dict_handler.get  ('t') , dict_handler.get('type')] if item is not None),None)
            pattern_update_dict = next((item for item in [dict_handler.get('pattern_update_dict')] if item is not None), None)
            subcmd = next((item for item in [dict_handler.get('subcmd')] if item is not None), None)
        if patternname and not patternid:
            # get all patterns and get id from name
            resp = lxca_rest().do_configpatterns(self.con.get_url(), self.con.get_session(), None, None,
                                                 None, None, None, None)
            py_obj = json.loads(resp.text)
            for item in py_obj['items']:
                if item['name'] == patternname:
                    patternid = item['id']
                    break
            if not patternid:
                raise Exception("Pattern Name %s not found" %patternname)
        if subcmd == 'status':
            resp = lxca_rest().get_configstatus(self.con.get_url(), self.con.get_session(), endpoint)
        else:
            resp = lxca_rest().do_configpatterns(self.con.get_url(),self.con.get_session(),patternid, includeSettings, endpoint, restart, etype, pattern_update_dict)

        try:
            # if endpoint:
            #     return resp
            # else:
            py_obj = json.loads(resp.text)
            return py_obj
        
        except AttributeError as ValueError:
            return resp
Beispiel #13
0
    def get_set_resourcegroups(self, dict_handler = None):
        '''
    
        '''
        
        uuid = name = desc = type = solutionVPD = members = criteria = None
        
        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        # parsing dict_handler to fetch parameter    
        if dict_handler:
            uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
            name = next((item for item in [dict_handler.get('n') , dict_handler.get('name')] if item is not None),None)
            desc = next((item for item in [dict_handler.get('d') , dict_handler.get('description')] if item is not None),None)
            type = next((item for item in [dict_handler.get('t') , dict_handler.get('type')] if item is not None),None)
            solutionVPD = next((item for item in [dict_handler.get('s') , dict_handler.get('solutionVPD')] if item is not None),None)
            members = next((item for item in [dict_handler.get('m') , dict_handler.get('members')] if item is not None),None)
            criteria = next((item for item in [dict_handler.get('c') , dict_handler.get('criteria')] if item is not None),None)
            
        resp = lxca_rest().get_set_resourcegroups(self.con.get_url(),self.con.get_session(),uuid,name,desc,type,solutionVPD,members,criteria)
        
        try:
            py_obj = json.loads(resp.text)
        except AttributeError as ValueError:
            return resp
        return py_obj
Beispiel #14
0
    def do_updatecomp( self, dict_handler = None ):
        mode = None
        action = None
        server = None
        switch = None
        cmm = None
        storage = None
        query = None
        dev_list = None
                
        if not self.con:
            raise ConnectionError("Connection is not Initialized.")
        
        if dict_handler:
            mode = next((item for item in [dict_handler.get  ('m') , dict_handler.get('mode')] if item is not None),None)
            action = next((item for item in [dict_handler.get  ('a') , dict_handler.get('action')] if item is not None),None)
            server = next((item for item in [dict_handler.get  ('s') , dict_handler.get('server')] if item is not None),None)
            storage = next((item for item in [dict_handler.get  ('t') , dict_handler.get('storage')] if item is not None),None)
            switch = next((item for item in [dict_handler.get  ('w') , dict_handler.get('switch')] if item is not None),None)
            cmm = next((item for item in [dict_handler.get  ('c') , dict_handler.get('cmm')] if item is not None),None)
            query = next((item for item in [dict_handler.get('q'), dict_handler.get('query')] if item is not None), None)
            dev_list = next((item for item in [dict_handler.get('l'), dict_handler.get('dev_list')] if item is not None), None)

        resp = lxca_rest().do_updatecomp(self.con.get_url(),self.con.get_session(), query, mode,action,server,switch,storage,cmm, dev_list)
        
        try:
            if mode == None and action == None and server == None and  switch == None and storage == None and cmm == None and dev_list == None :
                py_obj = json.loads(resp.text)
            else:
                py_obj = json.loads(resp._content)
            return py_obj
        except AttributeError as ValueError:
            return resp
        return py_obj
Beispiel #15
0
    def do_manage( self, dict_handler = None ):
        ip_addr = None
        user = None
        pw = None
        rpw = None
        jobid = None
        force = None
        storedcredential_id = None
        
        if not self.con:
            raise ConnectionError("Connection is not Initialized.")
        
        if dict_handler:
            ip_addr = next((item for item in [dict_handler.get  ('i') , dict_handler.get('ip')] if item is not None),None)
            user = next((item for item in [dict_handler.get  ('u') , dict_handler.get('user')] if item is not None),None)
            pw = next((item for item in [dict_handler.get  ('p') , dict_handler.get('pw')] if item is not None),None)
            rpw = next((item for item in [dict_handler.get  ('r') , dict_handler.get('rpw')] if item is not None),None)
            jobid = next((item for item in [dict_handler.get  ('j') , dict_handler.get('job')] if item is not None),None)
            storedcredential_id = next((item for item in [dict_handler.get  ('s') ,
                                dict_handler.get('storedcredential_id')] if item is not None),None)
            force = next((item for item in [dict_handler.get  ('f') , dict_handler.get('force')] if item is not None),None)

        resp = lxca_rest().do_manage(self.con.get_url(),self.con.get_session(),ip_addr,user,
                                     pw,rpw,force,jobid, storedcredential_id)
        
        try:
            py_obj = json.loads(resp.text)
            return py_obj
        except AttributeError as ValueError:
            return resp
Beispiel #16
0
 def get_jobs( self, dict_handler = None ):        
     jobid = None
     uuid = None
     state = None
     canceljobid = None
     deletejobid = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         jobid = next((item for item in [dict_handler.get  ('i') , dict_handler.get('id')] if item is not None),None)
         uuid = next((item for item in [dict_handler.get  ('u') , dict_handler.get('uuid')] if item is not None),False)
         state = next((item for item in [dict_handler.get  ('s') , dict_handler.get('state')] if item is not None),None)
         canceljobid = next((item for item in [dict_handler.get  ('c') , dict_handler.get('cancel')] if item is not None),None)
         deletejobid = next((item for item in [dict_handler.get  ('d') , dict_handler.get('delete')] if item is not None),None)
         
     resp = lxca_rest().get_jobs(self.con.get_url(),self.con.get_session(),jobid,uuid,state,canceljobid,deletejobid)
     
     try:
         if jobid:
             py_obj = json.loads(resp.text)
             py_obj = {'jobsList': [py_obj]}
             return py_obj
         if canceljobid or deletejobid:
             return resp
         else:
             py_obj = json.loads(resp.text)
             py_obj = {'jobsList':py_obj}
         return py_obj
     except AttributeError as ValueError:
         return resp
Beispiel #17
0
 def get_log_level(self, dict_handler=None):
     lvl = None
     if dict_handler:
         lvl =  dict_handler['l'] or dict_handler['lvl']
     if lvl == None:
         lvl = lxca_rest().get_log_level()
     else:
         return self.set_log_level(lvl)
     return lvl
Beispiel #18
0
 def get_log_level(self, dict_handler=None):
     lvl = None
     if dict_handler:
         lvl = next((item for item in [dict_handler.get('l') , dict_handler.get('lvl')] if item is not None),None)
     if lvl == None:
         lvl = lxca_rest().get_log_level()
     else:
         return self.set_log_level(lvl)
     return lvl
Beispiel #19
0
    def get_set_storedcredentials(self, dict_handler=None):
        """
        Stored credential api handler call rest api
        :param dict_handler:
        :return:
        """
        id = None
        user_name = None
        description = None
        password = None
        delete_id = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            id = next((item for item in [dict_handler.get('i'), dict_handler.get('id')] if item is not None),
                        None)
            user_name = next((item for item in [dict_handler.get('u'), dict_handler.get('user_name')] if item is not None),
                             None)
            description = next((item for item in [dict_handler.get('d'), dict_handler.get('description')] if item is not None),
                             None)
            password = next(
                (item for item in [dict_handler.get('p'), dict_handler.get('password')] if item is not None),
                None)
            delete_id = next(
                (item for item in [dict_handler.get('delete_id')] if item is not None),
                None)

        if delete_id:
            resp = lxca_rest().delete_storedcredentials(self.con.get_url(), self.con.get_session(), delete_id)
            resp = json.loads(resp.text)
        elif id and (user_name or password or description):
            resp = lxca_rest().put_storedcredentials(self.con.get_url(), self.con.get_session(), id, user_name, password, description)
            resp = json.loads(resp.text)
        elif user_name and password:
            resp = lxca_rest().post_storedcredentials(self.con.get_url(), self.con.get_session(), user_name, password, description)
            py_obj = json.loads(resp.text)
            resp = {'storedcredentialsList': [py_obj['response']]}
        else:
            resp = lxca_rest().get_storedcredentials(self.con.get_url(), self.con.get_session(), id)
            py_obj = json.loads(resp.text)
            resp = {'storedcredentialsList': py_obj['response']}
        return resp
Beispiel #20
0
    def get_set_compositeResults(self, dict_handler=None):
        id = None
        solutionGroup = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            id = next((item for item in [dict_handler.get('i'), dict_handler.get('id')] if item is not None),
                        None)
            solutionGroup = next((item for item in [dict_handler.get('s'), dict_handler.get('solutionGroup')] if item is not None),
                             None)

        if solutionGroup:
            resp = lxca_rest().set_compositeResults(self.con.get_url(), self.con.get_session(), solutionGroup)
        else:
            resp = lxca_rest().get_compositeResults(self.con.get_url(), self.con.get_session(), id)
        py_obj = json.loads(resp.text)
        return py_obj
Beispiel #21
0
    def get_set_rules(self, dict_handler=None):
        id = None
        rule = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            id = next((item for item in [dict_handler.get('i'), dict_handler.get('id')] if item is not None),
                        None)
            rule = next((item for item in [dict_handler.get('r'), dict_handler.get('rule')] if item is not None),
                             None)

        if rule:
            resp = lxca_rest().set_rules(self.con.get_url(), self.con.get_session(), rule)
        else:
            resp = lxca_rest().get_rules(self.con.get_url(), self.con.get_session(), id)
        py_obj = json.loads(resp.text)
        return py_obj
Beispiel #22
0
 def get_cmm( self, dict_handler = None ):
     uuid = None
     chassis_uuid = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
         chassis_uuid = next((item for item in [dict_handler.get('c') , dict_handler.get('chassis')] if item is not None),None)
         
     if chassis_uuid:
         resp = lxca_rest().get_chassis(self.con.get_url(),self.con.get_session(),chassis_uuid,None)
         py_obj = json.loads(resp.text)
         py_obj = {'cmmsList':py_obj["cmms"]}
     else:
         resp = lxca_rest().get_cmm(self.con.get_url(),self.con.get_session(),uuid)
         py_obj = json.loads(resp.text)
     return py_obj
Beispiel #23
0
    def get_set_resourcegroups(self, dict_handler = None):
        '''
    
        '''
        
        subcmd=uuid = name = desc = type = solutionVPD = members = criteria = None
        
        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        # parsing dict_handler to fetch parameter    
        if dict_handler:
            uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
            name = next((item for item in [dict_handler.get('n') , dict_handler.get('name')] if item is not None),None)
            desc = next((item for item in [dict_handler.get('d') , dict_handler.get('description')] if item is not None),None)
            type = next((item for item in [dict_handler.get('t') , dict_handler.get('type')] if item is not None),None)
            solutionVPD = next((item for item in [dict_handler.get('s') , dict_handler.get('solutionVPD')] if item is not None),None)
            members = next((item for item in [dict_handler.get('m') , dict_handler.get('members')] if item is not None),None)
            criteria = next((item for item in [dict_handler.get('c') , dict_handler.get('criteria')] if item is not None),None)
            subcmd = next(
                (item for item in [dict_handler.get('subcmd')] if item is not None), None)

        if 'list' in subcmd:
            resp = lxca_rest().list_resourcegroups(self.con.get_url(), self.con.get_session(), uuid)
        elif 'criteriaproperties' in subcmd:
            resp = lxca_rest().criteriaproperties_resourcegroups(self.con.get_url(), self.con.get_session())
            py_obj = json.loads(resp.text)
            py_obj = {'propertiesList': py_obj}
            return py_obj
        elif 'delete' in subcmd:
            resp = lxca_rest().delete_resourcegroups(self.con.get_url(), self.con.get_session(), uuid)
            if resp.status_code == 200:
                return "Deleted Successfully"
        elif 'create' in subcmd:
            if 'dynamic' in type:
                resp = lxca_rest().dynamic_resourcegroups(self.con.get_url(), self.con.get_session(), uuid, name, desc,
                                                  type, criteria)
            elif 'solution' in type:
                resp = lxca_rest().solution_resourcegroups(self.con.get_url(), self.con.get_session(), uuid, name,
                                                           desc, type, solutionVPD, members, criteria)
            else:
                raise Exception("Invalid argument: Type supported are dynamic and solution")
        elif 'update' in subcmd:
            if 'dynamic' in type:
                resp = lxca_rest().dynamic_resourcegroups(self.con.get_url(), self.con.get_session(), uuid, name,
                                                          desc,
                                                          type, criteria)
            elif 'solution' in type:
                resp = lxca_rest().solution_resourcegroups(self.con.get_url(), self.con.get_session(), uuid, name,
                                                           desc, type, solutionVPD, members, criteria)
            else:
                raise Exception("Invalid argument: Type supported are dynamic and solution")

        try:
            py_obj = json.loads(resp.text)
        except AttributeError as ValueError:
            return resp
        return py_obj
Beispiel #24
0
 def get_chassis( self, dict_handler = None ):
     uuid = None
     status = None
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         uuid = next((item for item in [dict_handler.get('u') , dict_handler.get('uuid')] if item is not None),None)
         status = next((item for item in [dict_handler.get('s') , dict_handler.get('status')] if item is not None),None)
     
     resp = lxca_rest().get_chassis(self.con.get_url(),self.con.get_session(),uuid,status)
     py_obj = json.loads(resp.text)
     return py_obj
Beispiel #25
0
    def get_set_tasks(self, dict_handler=None):
        job_uuid = None
        includeChildren = False
        action = None
        status = None
        cmd_updateList = None
        template = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")

        if dict_handler:
            job_uuid = next((item for item in [ dict_handler.get('jobUID')] if item is not None), None)
            includeChildren = next((item for item in [ dict_handler.get('children')] if item is not None), "true")
            action = next((item for item in [dict_handler.get('action')] if item is not None), None)
            updateList = next((item for item in [dict_handler.get('updateList')] if item is not None), None)
            template = next((item for item in [dict_handler.get('template')] if item is not None), None)
            #if updateList:
            #    updateList = updateList['taskList']


        if job_uuid and action in ['cancel']:
            resp = lxca_rest().put_tasks(self.con.get_url(), self.con.get_session(), job_uuid, action)
            py_obj = resp.status_code
        elif action in ['delete']:
            resp = lxca_rest().delete_tasks(self.con.get_url(), self.con.get_session(), job_uuid)
            py_obj = resp.status_code
        elif action in ['update']:
            resp = lxca_rest().put_tasks_update(self.con.get_url(), self.con.get_session(), updateList)
            py_obj = resp.status_code
        elif action in ['create']:
            resp = lxca_rest().post_tasks(self.con.get_url(), self.con.get_session(), template)
            py_obj = resp
        else:
            resp = lxca_rest().get_tasks(self.con.get_url(), self.con.get_session(), job_uuid, includeChildren)
            py_obj = json.loads(resp.text)
            py_obj = {'TaskList': py_obj[:]}
        return py_obj
Beispiel #26
0
    def get_scalablesystem( self, dict_handler = None ):
        complexid = None
        complextype = None

        if not self.con:
            raise ConnectionError("Connection is not Initialized.")
        
        if dict_handler:
            complexid = next((item for item in [dict_handler.get('i') , dict_handler.get('id')] if item is not None),None)
            complextype = next((item for item in [dict_handler.get('t') , dict_handler.get('type')] if item is not None),None)

        resp = lxca_rest().get_scalablesystem(self.con.get_url(),self.con.get_session(),complexid,complextype)
        py_obj = json.loads(resp.text)
        return py_obj
Beispiel #27
0
 def get_ffdc( self, dict_handler = None ): 
     uuid = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         uuid = next((item for item in [dict_handler.get  ('u') , dict_handler.get('uuid')] if item is not None),None)
         
     resp = lxca_rest().get_ffdc(self.con.get_url(),self.con.get_session(),uuid)
     
     try:
         py_obj = json.loads(resp.text)
     except AttributeError as ValueError:
         return resp
     return py_obj
Beispiel #28
0
 def get_lxcalog( self, dict_handler = None ):        
     filter = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         filter = next((item for item in [dict_handler.get  ('f') , dict_handler.get('filter')] if item is not None),None)
         
     resp = lxca_rest().get_lxcalog(self.con.get_url(),self.con.get_session(),filter)
     
     try:
         py_obj = json.loads(resp.text)
         py_obj = {'eventList':py_obj}
         return py_obj
     except AttributeError as ValueError:
         return resp
Beispiel #29
0
 def do_discovery( self, dict_handler = None ):
     ip_addr = None
     jobid = None
     
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         ip_addr = next((item for item in [dict_handler.get  ('i') , dict_handler.get('ip')] if item is not None),None)
         jobid = next((item for item in [dict_handler.get  ('j') , dict_handler.get('job')] if item is not None),None)
     
     resp = lxca_rest().do_discovery(self.con.get_url(),self.con.get_session(),ip_addr,jobid)
     
     try:
         py_obj = json.loads(resp.text)
         return py_obj
     except AttributeError as ValueError:
         return resp
Beispiel #30
0
 def get_set_manifests( self, dict_handler = None ):
     sol_id = None
     filepath = None
             
     if not self.con:
         raise ConnectionError("Connection is not Initialized.")
     
     if dict_handler:
         sol_id = next((item for item in [dict_handler.get('i') , dict_handler.get('id')] if item is not None),None)
         filepath = next((item for item in [dict_handler.get('f') , dict_handler.get('file')] if item is not None),None)
                     
     resp = lxca_rest().get_set_manifests(self.con.get_url(),self.con.get_session(),sol_id,filepath)
     
     try:
         py_obj = json.loads(resp._content)
         return py_obj
     except AttributeError as ValueError:
         return resp
     return py_obj