Changeset 449

Show
Ignore:
Timestamp:
05/09/08 13:05:56 (8 months ago)
Author:
jmowery
Message:

update to argv processing
fixme corrected for resolving group lists

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/trunk-pmd-intproto/mgmt/manager.py

    r446 r449  
    170170        elif argv[0] == 'client': 
    171171                msg = mgr.update() 
    172                 msg.body = sys.argv[3:] 
     172                msg.body = argv[1:] 
    173173        elif argv[0] == 'group': 
    174174                if argv[1] == '': 
     
    197197                        msg = m.update_query() 
    198198                elif argv[1] == 'in': 
    199                         if len(sys.argv) < 5
     199                        if len(argv) < 3
    200200                                print 'missing group name' 
    201201                                sys.exit(1) 
    202202                        msg = self.list_clients() 
    203                         msg.body = sys.argv[4
     203                        msg.body = argv[2
    204204                else: 
    205205                        print 'unknown client list request' 
     
    266266        return mgr.query_server(msg, targets) 
    267267 
     268def print_body(body): 
     269        if body.__class__ == [].__class__: 
     270                for item in body: 
     271                        if item.__class__ == ().__class__: 
     272                                tmp_str = '' 
     273                                for val in item: 
     274                                        tmp_str += str(val) 
     275                                        tmp_str += '\t\t' 
     276                                print tmp_str 
     277                        else: 
     278                                print item 
     279        elif body.__class__ == {}.__class__: 
     280                for key, val in body.items(): 
     281                        print str(key) +'\t\t'+ str(val) 
     282        else: 
     283                print body 
     284 
    268285if __name__ == '__main__': 
    269286        m = Manager('localhost') 
     
    290307                for result in res: 
    291308                        if result is not None: 
     309                                print result[1][0] 
    292310                                print result[0].msg 
    293                                 print result[0].body 
     311                                print_body(result[0].body) 
    294312        else: 
    295313                if res is not None: 
    296314                        print res.msg 
    297                         print res.body 
    298  
     315                        print_body(res.body) 
     316 
  • branches/trunk-pmd-intproto/server/master.py

    r448 r449  
    4242                return list 
    4343        elif(type == "group"): 
    44                 # FIXME: Jeremy: How do I get the hosts in a group, modify 
    45                 #        This function as needed. 
    46                 ''' look up the hosts based on the list of groups passed in. 
    47                     Currently unimplemented. 
    48                 ''' 
    49                 print "Not yet implemented" 
    50                 raise ArgumentError 
     44                ''' look up the hosts based on the list of groups passed in.''' 
     45                client_list = [] 
     46                for group in list: 
     47                       l = storage.Layer(os.path.join(os.path.dirname(storage_root), group)) 
     48                       client_list.append(l.list_nodes()) 
     49                       l.update() 
     50                return list(set(client_list)) 
    5151        raise ArgumentError 
    5252 
     
    254254                        tlist = targetexpand(target) 
    255255                        for t in tlist: 
    256                                 self.clients.send_key(func((mgr, info), deepcopy(msg), t))  
     256                                self.clients.send_key(func((mgr, info), deepcopy(msg), t)) 
    257257                        res = [] 
    258258                        for t in tlist: