<s> import libcloud . compute . base as compute_base <EOL> import libcloud . dns . base as dns_base <EOL> import libcloud . loadbalancer . base as lb_base <EOL> import libcloud . container . base as container_base <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> class FieldLists ( object ) : <EOL> """<STR_LIT>""" <EOL> NODE = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:state>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:size>' , '<STR_LIT:image>' ] <EOL> NODE_SIZE = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> NODE_IMAGE = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> LOCATION = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT>' ] <EOL> NODE_KEY = [ '<STR_LIT>' ] <EOL> NODE_PASSWORD = [ '<STR_LIT:password>' , '<STR_LIT>' ] <EOL> STORAGE_VOLUME = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:size>' , '<STR_LIT:state>' ] <EOL> VOLUME_SNAPSHOT = [ '<STR_LIT:id>' , '<STR_LIT:size>' , '<STR_LIT:state>' ] <EOL> ZONE = [ '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT:type>' , '<STR_LIT>' ] <EOL> RECORD = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:type>' , '<STR_LIT:data>' , '<STR_LIT>' ] <EOL> MEMBER = [ '<STR_LIT:id>' , '<STR_LIT>' , '<STR_LIT:port>' , '<STR_LIT>' ] <EOL> BALANCER = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:state>' , '<STR_LIT:port>' ] <EOL> CONTAINER = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:state>' ] <EOL> CONTAINER_IMAGE = [ '<STR_LIT:id>' , '<STR_LIT:name>' , '<STR_LIT:path>' , '<STR_LIT:version>' ] <EOL> CONTAINER_CLUSTER = [ '<STR_LIT:id>' , '<STR_LIT:name>' ] <EOL> class ResultSets ( object ) : <EOL> def selector ( self , output ) : <EOL> if isinstance ( output , compute_base . Node ) : <EOL> return self . parse ( output , FieldLists . NODE ) <EOL> elif isinstance ( output , compute_base . NodeSize ) : <EOL> return self . parse ( output , FieldLists . NODE_SIZE ) <EOL> elif isinstance ( output , compute_base . NodeImage ) : <EOL> return self . parse ( output , FieldLists . NODE_IMAGE ) <EOL> elif isinstance ( output , compute_base . NodeLocation ) : <EOL> return self . parse ( output , FieldLists . LOCATION ) <EOL> elif isinstance ( output , compute_base . NodeAuthSSHKey ) : <EOL> return self . parse ( output , FieldLists . NODE_KEY ) <EOL> elif isinstance ( output , compute_base . NodeAuthPassword ) : <EOL> return self . parse ( output , FieldLists . NODE_PASSWORD ) <EOL> elif isinstance ( output , compute_base . StorageVolume ) : <EOL> return self . parse ( output , FieldLists . STORAGE_VOLUME ) <EOL> elif isinstance ( output , compute_base . VolumeSnapshot ) : <EOL> return self . parse ( output , FieldLists . VOLUME_SNAPSHOT ) <EOL> elif isinstance ( output , dns_base . Zone ) : <EOL> return self . parse ( output , FieldLists . ZONE ) <EOL> elif isinstance ( output , dns_base . Record ) : <EOL> return self . parse ( output , FieldLists . RECORD ) <EOL> elif isinstance ( output , lb_base . Member ) : <EOL> return self . parse ( output , FieldLists . MEMBER ) <EOL> elif isinstance ( output , lb_base . LoadBalancer ) : <EOL> return self . parse ( output , FieldLists . BALANCER ) <EOL> elif isinstance ( output , container_base . Container ) : <EOL> return self . parse ( output , FieldLists . CONTAINER ) <EOL> elif isinstance ( output , container_base . ContainerImage ) : <EOL> return self . parse ( output , FieldLists . CONTAINER_IMAGE ) <EOL> elif isinstance ( output , container_base . ContainerCluster ) : <EOL> return self . parse ( output , FieldLists . CONTAINER_CLUSTER ) <EOL> else : <EOL> return output <EOL> def formatter ( self , output ) : <EOL> formatted = [ ] <EOL> if isinstance ( output , list ) : <EOL> for o in output : <EOL> formatted . append ( self . selector ( o ) ) <EOL> else : <EOL> formatted = self . selector ( output ) <EOL> return formatted <EOL> def _getval ( self , obj , field ) : <EOL> return self . selector ( getattr ( obj , field ) ) <EOL> def parse ( self , output , field_list ) : <EOL> instance_data = { field : self . _getval ( output , field ) for field in field_list } <EOL> return instance_data </s>
