Changeset 449
- 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
| r446 |
r449 |
|
| 170 | 170 | elif argv[0] == 'client': |
|---|
| 171 | 171 | msg = mgr.update() |
|---|
| 172 | | msg.body = sys.argv[3:] |
|---|
| | 172 | msg.body = argv[1:] |
|---|
| 173 | 173 | elif argv[0] == 'group': |
|---|
| 174 | 174 | if argv[1] == '': |
|---|
| … | … | |
| 197 | 197 | msg = m.update_query() |
|---|
| 198 | 198 | elif argv[1] == 'in': |
|---|
| 199 | | if len(sys.argv) < 5: |
|---|
| | 199 | if len(argv) < 3: |
|---|
| 200 | 200 | print 'missing group name' |
|---|
| 201 | 201 | sys.exit(1) |
|---|
| 202 | 202 | msg = self.list_clients() |
|---|
| 203 | | msg.body = sys.argv[4] |
|---|
| | 203 | msg.body = argv[2] |
|---|
| 204 | 204 | else: |
|---|
| 205 | 205 | print 'unknown client list request' |
|---|
| … | … | |
| 266 | 266 | return mgr.query_server(msg, targets) |
|---|
| 267 | 267 | |
|---|
| | 268 | def 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 | |
|---|
| 268 | 285 | if __name__ == '__main__': |
|---|
| 269 | 286 | m = Manager('localhost') |
|---|
| … | … | |
| 290 | 307 | for result in res: |
|---|
| 291 | 308 | if result is not None: |
|---|
| | 309 | print result[1][0] |
|---|
| 292 | 310 | print result[0].msg |
|---|
| 293 | | print result[0].body |
|---|
| | 311 | print_body(result[0].body) |
|---|
| 294 | 312 | else: |
|---|
| 295 | 313 | if res is not None: |
|---|
| 296 | 314 | print res.msg |
|---|
| 297 | | print res.body |
|---|
| 298 | | |
|---|
| | 315 | print_body(res.body) |
|---|
| | 316 | |
|---|
| r448 |
r449 |
|
| 42 | 42 | return list |
|---|
| 43 | 43 | 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)) |
|---|
| 51 | 51 | raise ArgumentError |
|---|
| 52 | 52 | |
|---|
| … | … | |
| 254 | 254 | tlist = targetexpand(target) |
|---|
| 255 | 255 | 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)) |
|---|
| 257 | 257 | res = [] |
|---|
| 258 | 258 | for t in tlist: |
|---|
Download in other formats:
* Generating other formats may take time.