<s> from lib . action import BaseVMsAction <EOL> from lib . formatters import to_server_dict <EOL> __all__ = [ <EOL> '<STR_LIT>' <EOL> ] <EOL> class GetVMIPsAction ( BaseVMsAction ) : <EOL> def run ( self , count = None , region = None , metadata = None ) : <EOL> if region : <EOL> cs = self . pyrax . connect_to_cloudservers ( region = region ) <EOL> else : <EOL> cs = self . pyrax . cloudservers <EOL> servers = cs . list ( ) <EOL> result = [ ] <EOL> for server in servers : <EOL> item = to_server_dict ( server = server ) <EOL> if metadata : <EOL> include = self . _metadata_intersection ( server = item , <EOL> metadata = metadata ) <EOL> if not include : <EOL> continue <EOL> public_ips = item . get ( '<STR_LIT>' , [ ] ) <EOL> result . extend ( public_ips ) <EOL> if count : <EOL> return result [ <NUM_LIT:0> : count ] <EOL> else : <EOL> return result </s>
