diff --git a/opennebula_api/models.py b/opennebula_api/models.py index c4943c3e..447a7f75 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -67,12 +67,12 @@ class OpenNebulaManager(): except WrongNameError as wrong_name_err: opennebula_user = self.oneadmin_client.call(oca.User.METHODS['allocate'], email, password, 'core') + return opennebula_user except ConnectionRefusedError: print('Could not connect to host: {host} via protocol {protocol}'.format( host=settings.OPENNEBULA_DOMAIN, protocol=settings.OPENNEBULA_PROTOCOL) ) - return opennebula_user def _get_user_pool(self): try: user_pool = oca.UserPool(self.oneadmin_client) @@ -84,6 +84,13 @@ class OpenNebulaManager(): ) return user_pool def create_template(self, name, cores, memory, disk_size): + """Create and add a new template to opennebula. + :param name: A string representation describing the template. + Used as label in view. + :param cores: Amount of virtual cpu cores for the VM. + :param memory: Amount of RAM for the VM (MB) + :param disk_size: Amount of disk space for VM (MB) + """ template_string_formatter = """