<s> """<STR_LIT>""" <EOL> from libcloud . interface import INodeDriver <EOL> from libcloud . base import ConnectionKey , NodeDriver , NodeSize , NodeLocation <EOL> from libcloud . base import NodeImage , Node <EOL> from libcloud . types import Provider , NodeState <EOL> from zope . interface import implements <EOL> import uuid <EOL> class DummyConnection ( ConnectionKey ) : <EOL> """<STR_LIT>""" <EOL> def connect ( self , host = None , port = None ) : <EOL> pass <EOL> class DummyNodeDriver ( NodeDriver ) : <EOL> """<STR_LIT>""" <EOL> name = "<STR_LIT>" <EOL> type = Provider . DUMMY <EOL> implements ( INodeDriver ) <EOL> def __init__ ( self , creds ) : <EOL> self . creds = creds <EOL> self . nl = [ <EOL> Node ( id = <NUM_LIT:1> , <EOL> name = '<STR_LIT>' , <EOL> state = NodeState . RUNNING , <EOL> public_ip = [ '<STR_LIT:127.0.0.1>' ] , <EOL> private_ip = [ ] , <EOL> driver = self , <EOL> extra = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) , <EOL> Node ( id = <NUM_LIT:2> , <EOL> name = '<STR_LIT>' , <EOL> state = NodeState . RUNNING , <EOL> public_ip = [ '<STR_LIT:127.0.0.1>' ] , <EOL> private_ip = [ ] , <EOL> driver = self , <EOL> extra = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) , <EOL> ] <EOL> self . connection = DummyConnection ( self . creds ) <EOL> def get_uuid ( self , unique_field = None ) : <EOL> return str ( uuid . uuid4 ( ) ) <EOL> def list_nodes ( self ) : <EOL> return self . nl <EOL> def reboot_node ( self , node ) : <EOL> node . state = NodeState . REBOOTING <EOL> return True <EOL> def destroy_node ( self , node ) : <EOL> node . state = NodeState . TERMINATED <EOL> self . nl . remove ( node ) <EOL> return True <EOL> def list_images ( self , location = None ) : <EOL> return [ <EOL> NodeImage ( id = <NUM_LIT:1> , name = "<STR_LIT>" , driver = self ) , <EOL> NodeImage ( id = <NUM_LIT:2> , name = "<STR_LIT>" , driver = self ) , <EOL> NodeImage ( id = <NUM_LIT:3> , name = "<STR_LIT>" , driver = self ) , <EOL> ] <EOL> def list_sizes ( self , location = None ) : <EOL> return [ <EOL> NodeSize ( id = <NUM_LIT:1> , <EOL> name = "<STR_LIT>" , <EOL> ram = <NUM_LIT> , <EOL> disk = <NUM_LIT:4> , <EOL> bandwidth = <NUM_LIT> , <EOL> price = <NUM_LIT:4> , <EOL> driver = self ) , <EOL> NodeSize ( id = <NUM_LIT:2> , <EOL> name = "<STR_LIT>" , <EOL> ram = <NUM_LIT> , <EOL> disk = <NUM_LIT:16> , <EOL> bandwidth = <NUM_LIT> , <EOL> price = <NUM_LIT:8> , <EOL> driver = self ) , <EOL> NodeSize ( id = <NUM_LIT:3> , <EOL> name = "<STR_LIT>" , <EOL> ram = <NUM_LIT> , <EOL> disk = <NUM_LIT:32> , <EOL> bandwidth = <NUM_LIT> , <EOL> price = <NUM_LIT:32> , <EOL> driver = self ) , <EOL> NodeSize ( id = <NUM_LIT:4> , <EOL> name = "<STR_LIT>" , <EOL> ram = <NUM_LIT> * <NUM_LIT:2> , <EOL> disk = <NUM_LIT:32> * <NUM_LIT:4> , <EOL> bandwidth = <NUM_LIT> * <NUM_LIT:3> , <EOL> price = <NUM_LIT:32> * <NUM_LIT:2> , <EOL> driver = self ) , <EOL> ] <EOL> def list_locations ( self ) : <EOL> return [ <EOL> NodeLocation ( id = <NUM_LIT:1> , <EOL> name = "<STR_LIT>" , <EOL> country = '<STR_LIT>' , <EOL> driver = self ) , <EOL> NodeLocation ( id = <NUM_LIT:1> , <EOL> name = "<STR_LIT>" , <EOL> country = '<STR_LIT>' , <EOL> driver = self ) , <EOL> NodeLocation ( id = <NUM_LIT:1> , <EOL> name = "<STR_LIT>" , <EOL> country = '<STR_LIT>' , <EOL> driver = self ) , <EOL> ] <EOL> def create_node ( self , ** kwargs ) : <EOL> l = len ( self . nl ) + <NUM_LIT:1> <EOL> n = Node ( id = l , <EOL> name = '<STR_LIT>' % l , <EOL> state = NodeState . RUNNING , <EOL> public_ip = [ '<STR_LIT>' % l ] , <EOL> private_ip = [ ] , <EOL> driver = self , <EOL> extra = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . nl . append ( n ) <EOL> return n </s>
