Changeset d055eb1


Ignore:
Timestamp:
Apr 21, 2010 6:23:08 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
4c931af
Parents:
f7a54c6
Message:

Ftopo function returns the virtual to physical host mapping. Slight refactoring to support this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/fedd_client.py

    rf7a54c6 rd055eb1  
    419419
    420420       
    421 
    422 # Querying experiment data follows the same control flow regardless of the
    423 # specific data retrieved.  This class encapsulates that control flow.
    424 class exp_data(exp_data_base):
    425     def __init__(self):
    426         exp_data_base.__init__(self)
    427 
    428421    def __call__(self):
    429422        """
     
    482475            sys.exit("Error processing RPC: %s" % e)
    483476
     477        return (resp_dict, opts)
     478
     479
     480# Querying experiment data follows the same control flow regardless of the
     481# specific data retrieved.  This class encapsulates that control flow.
     482class exp_data(exp_data_base):
     483    def __init__(self):
     484        exp_data_base.__init__(self)
     485
     486    def __call__(self):
     487        """
     488        The control flow.  Compose the request and print the response.
     489        """
     490
     491        resp_dict, opts = exp_data_base.__call__(self)
     492
    484493        for d in opts.data:
    485494            key, output = self.params[d]
     
    490499                sys.exit("Bad response. %s" % e.message)
    491500
    492 class vtopo(exp_data):
     501class ftopo(exp_data_base):
     502    """
     503    ftopo returns the mapping from logical name to local hostname
     504    """
     505    def __init__(self):
     506        exp_data_base.__init__(self)
     507    def __call__(self):
     508        sys.argv.append('--data=experimentdescription')
     509        resp, opts = exp_data_base.__call__(self)
     510        if 'experimentdescription' in resp and \
     511                'topdldescription' in resp['experimentdescription']:
     512            top = \
     513                topdl.Topology(\
     514                **resp['experimentdescription']['topdldescription'])
     515
     516            for e in [ e for e in top.elements \
     517                    if isinstance(e, topdl.Computer)]:
     518                hn = e.get_attribute('hostname')
     519                tb = e.get_attribute('testbed')
     520                if hn and tb:
     521                    print ":".join([",".join(e.name), hn, tb])
     522
     523
     524
     525
     526class vtopo(exp_data_base):
    493527    """
    494528    vtopo is just an info --data=vtopo request, so this adds that parameter to
     
    496530    """
    497531    def __init__(self):
    498         exp_data.__init__(self)
     532        exp_data_base.__init__(self)
    499533    def __call__(self):
    500534        sys.argv.append('--data=vtopo')
    501         exp_data.__call__(self)
    502 
    503 
    504 class vis(exp_data):
     535        resp, opts = exp_data_base.__call__(self)
     536        if 'vtopo' in resp:
     537            self.print_vis_or_vtopo('vtopo')(resp['vtopo'])
     538
     539
     540class vis(exp_data_base):
    505541    """
    506542    vis is just an info --data=vis request, so this adds that parameter to
     
    508544    """
    509545    def __init__(self):
    510         exp_data.__init__(self)
     546        exp_data_base.__init__(self)
    511547    def __call__(self):
    512548        sys.argv.append('--data=vis')
    513         exp_data.__call__(self)
    514 
    515 class status(exp_data):
     549        resp, opts = exp_data_base.__call__(self)
     550        if 'vis' in resp:
     551            self.print_vis_or_vtopo('vis')(resp['vis'])
     552
     553class status(exp_data_base):
    516554    """
    517555    status is just an info --data=status request, so this adds that parameter
     
    519557    """
    520558    def __init__(self):
    521         exp_data.__init__(self)
     559        exp_data_base.__init__(self)
    522560    def __call__(self):
    523561        sys.argv.append('--data=status')
    524         exp_data.__call__(self)
     562        resp, opts = exp_data_base.__call__(self)
     563        if 'experimentStatus' in resp:
     564            self.print_string(resp['experimentStatus'])
    525565
    526566class multi_exp_data(exp_data_base):
     
    18341874        'split': split(),\
    18351875        'access': access(),\
     1876        'ftopo': ftopo(),\
    18361877        'vtopo': vtopo(),\
    18371878        'vis': vis(),\
Note: See TracChangeset for help on using the changeset viewer.