Skip to content

Commit

Permalink
various small bug fixes and tweaks to get it running with usegalaxy.no
Browse files Browse the repository at this point in the history
  • Loading branch information
brugger committed Mar 26, 2020
1 parent 85ea6c9 commit cf227be
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bin/ehosd.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def run_daemon( config_file:str="/usr/local/etc/ehos.yaml" ):
if ( nodes.node_total < config.daemon.nodes_min ):
logger.info("We are below the min number of nodes, creating {} nodes".format( config.daemon.nodes_min - nodes.node_total))

node_names = ehos.create_execute_nodes(instances, config, config.daemon.nodes_min - nodes.node_total)
node_names = ehos.create_execute_nodes(instances, config, nr=config.daemon.nodes_min - nodes.node_total)
log_nodes( node_names )
new_nodes += node_names

Expand Down
4 changes: 2 additions & 2 deletions ehos.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Type=simple
Restart=always
RestartSec=1
User=centos
ExecStart = /usr/local/bin/ehosd.py
ExecStart = /usr/local/bin/ehosd.py -l /var/log/ehos /usr/local/etc/ehos.yaml

[Install]
WantedBy = multi-user.target
WantedBy = multi-user.target
4 changes: 2 additions & 2 deletions ehos/ehos.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def remove_floating_ips(instances, node_names):



def create_execute_nodes(instances, config:Munch, execute_config_file:str, nr:int=1):
def create_execute_nodes(instances, config:Munch, execute_config_file:str=None, nr:int=1):
""" Create a number of execute nodes
Args:
Expand Down Expand Up @@ -238,7 +238,7 @@ def create_execute_nodes(instances, config:Munch, execute_config_file:str, nr:in
config.ehos.image= config.clouds[ cloud_name ].image

node_id = cloud.server_create( name=node_name,
userdata_file=userdata_file,
userdata_file=execute_config_file,
**config.ehos )

if ( 'scratch_size' in config.ehos and
Expand Down
2 changes: 1 addition & 1 deletion ehos/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def cloud_names(self) -> []:

return list(self._clouds.keys())

def add_node(self, id:str, name:str, image:str, cloud:str, vm_state:str = 'vm_booting', node_state='node_starting') -> None:
def add_node(self, id:str, name:str, image:str=None, cloud:str="default", vm_state:str = 'vm_booting', node_state='node_starting') -> None:
""" Adds a node to the class
Args:
Expand Down
34 changes: 20 additions & 14 deletions ehos/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,28 @@ def server_create(self, name:str, image:str, flavor:str, network:str, key:str, s
raise( RuntimeError("Image {} does not exist in the openstack instance".format(image)))

try:
user_data_fh = None
if ( userdata_file is not None):
user_data_fh = open( userdata_file, 'r')
server = self._connection.create_server(name,
image=image,
flavor=flavor,
network=network,
key_name=key,
security_groups=security_groups,
# Kind of breaks with the documentation, plus needs a filehandle, not commands or a filename.
# though the code looks like it should work with just a string of command(s).
# Cannot be bothered to get to the bottom of this right now.
userdata=user_data_fh,
wait=True,
auto_ip=True)


server = self._connection.create_server(name,
image=image,
flavor=flavor,
network=network,
key_name=key,
security_groups=security_groups,
userdata=user_data_fh,
wait=True,
auto_ip=True)
else:
server = self._connection.create_server(name,
image=image,
flavor=flavor,
network=network,
key_name=key,
security_groups=security_groups,
wait=True,
auto_ip=True)


logger.debug("Created server id:{} ip:{}".format( server.id, self.server_ip(server.id)))

Expand Down
1 change: 1 addition & 0 deletions ehos/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def find_config_file( filename:str, dirs:list=None) -> str:

default_dirs = ['/etc/ehos/',
'/usr/local/etc/ehos',
'/usr/local/etc/',
"{}/../etc".format( script_dir ),
'etc/',
'etc/ehos',
Expand Down

0 comments on commit cf227be

Please sign in to comment.