@@ -72,31 +72,31 @@ def build_node(node):
7272 node ['params' ].setdefault ('memory' , '512' )
7373 template = open ('/opt/deis/controller/contrib/vagrant/nodes_vagrantfile_template.rb' )
7474 raw = string .Template (template .read ())
75- result = raw .substitute ({ 'id' :uid , 'memory' :node ['params' ]['memory' ] })
75+ result = raw .substitute ({'id' : uid , 'memory' : node ['params' ]['memory' ]})
7676
7777 # Make a folder for the VM with its own Vagrantfile. Vagrant will then create a .vagrant folder
7878 # there too when it first gets booted.
7979 node_dir = HOST_NODES_DIR + '/' + uid
8080 mkdir = 'mkdir ' + node_dir
8181 cp_tpl = 'echo "' + result .replace ('"' , '\\ "' ) + '" > ' + node_dir + '/Vagrantfile'
82- _host_ssh (commands = [mkdir , cp_tpl ], creds = node ['creds' ])
82+ _host_ssh (commands = [mkdir , cp_tpl ], creds = node ['creds' ])
8383
8484 # Boot the VM
85- _run_vagrant_command (uid , args = ['up' ], creds = node ['creds' ])
85+ _run_vagrant_command (uid , args = ['up' ], creds = node ['creds' ])
8686
8787 # Copy the layer's public SSH key to the VM so that the Controller can access it.
8888 _run_vagrant_command (
8989 uid ,
90- args = [
90+ args = [
9191 'ssh' ,
9292 '-c' ,
9393 '"echo \\ "' + node ['ssh_public_key' ] + '\\ " >> /home/vagrant/.ssh/authorized_keys"'
9494 ],
95- creds = node ['creds' ],
95+ creds = node ['creds' ],
9696 )
9797
9898 provider_id = uid
99- fqdn = provider_id + '.local' # hostname is broadcast via avahi-daemon
99+ fqdn = provider_id + '.local' # hostname is broadcast via avahi-daemon
100100 metadata = {
101101 'id' : uid ,
102102 'fqdn' : fqdn ,
@@ -114,11 +114,11 @@ def destroy_node(node):
114114
115115 # This is useful if node creation failed. So that there's a record in the DB, but it has no
116116 # ID associated with it.
117- if node ['provider_id' ] == None :
117+ if node ['provider_id' ] is None :
118118 return
119119
120120 # Shut the VM down and destroy it
121- _run_vagrant_command (node ['provider_id' ], args = ['destroy' , '--force' ], creds = node ['creds' ])
121+ _run_vagrant_command (node ['provider_id' ], args = ['destroy' , '--force' ], creds = node ['creds' ])
122122 node_dir = HOST_NODES_DIR + '/' + node ['provider_id' ]
123123
124124 # Sanity check before `rm -rf`
@@ -128,21 +128,21 @@ def destroy_node(node):
128128 # Completely remove the folder that contained the VM
129129 rm_vagrantfile = 'rm ' + node_dir + '/Vagrantfile'
130130 rm_node_dir = 'rm -rf ' + node_dir
131- _host_ssh (commands = [rm_vagrantfile , rm_node_dir ], creds = node ['creds' ])
131+ _host_ssh (commands = [rm_vagrantfile , rm_node_dir ], creds = node ['creds' ])
132132
133133
134- def _run_vagrant_command (node_id , args = [], creds = {}):
134+ def _run_vagrant_command (node_id , args = [], creds = {}):
135135 """
136136 args: A tuple of arguments to a vagrant command line.
137137 e.g. ['up', 'my_vm_name', '--no-provision']
138138 """
139139
140140 cd = 'cd ' + HOST_NODES_DIR + '/' + node_id
141141 command = ['vagrant' ] + [arg for arg in args if arg is not None ]
142- return _host_ssh (commands = [cd , ' ' .join (command )], creds = creds )
142+ return _host_ssh (commands = [cd , ' ' .join (command )], creds = creds )
143143
144144
145- def _host_ssh (creds = {}, commands = []):
145+ def _host_ssh (creds = {}, commands = []):
146146 """
147147 Connect to the host machine. Namely the user's local machine.
148148 """
0 commit comments