ssh_public_keys -> ssh_authorized_keys rename (merge fix)

This commit is contained in:
forest 2021-02-15 19:44:26 -06:00
parent 8d0088ef13
commit 0a70c974ec
6 changed files with 19 additions and 19 deletions

View File

@ -159,7 +159,7 @@ def create():
elif os not in operating_systems: elif os not in operating_systems:
errors.append(f"Invalid os {os}") errors.append(f"Invalid os {os}")
posted_keys_count = int(request.form["ssh_public_key_count"]) posted_keys_count = int(request.form["ssh_authorized_key_count"])
posted_keys = list() posted_keys = list()
if posted_keys_count > 1000: if posted_keys_count > 1000:
@ -226,8 +226,8 @@ def create():
csrf_token = session["csrf-token"], csrf_token = session["csrf-token"],
capacity_avaliable=capacity_avaliable, capacity_avaliable=capacity_avaliable,
account_balance=format(account_balance, '.2f'), account_balance=format(account_balance, '.2f'),
ssh_public_keys=public_keys_for_account, ssh_authorized_keys=public_keys_for_account,
ssh_public_key_count=len(public_keys_for_account), ssh_authorized_key_count=len(public_keys_for_account),
no_ssh_public_keys=len(public_keys_for_account) == 0, no_ssh_public_keys=len(public_keys_for_account) == 0,
operating_systems=operating_systems, operating_systems=operating_systems,
cant_afford=len(affordable_vm_sizes) == 0, cant_afford=len(affordable_vm_sizes) == 0,

View File

@ -37,7 +37,7 @@ class MockHub(VirtualizationInterface):
def list_ids(self) -> list: def list_ids(self) -> list:
return get_model().all_non_deleted_vm_ids() return get_model().all_non_deleted_vm_ids()
def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_public_keys: list): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_authorized_keys: list):
validate_capsul_id(id) validate_capsul_id(id)
current_app.logger.info(f"mock create: {id} for {email}") current_app.logger.info(f"mock create: {id} for {email}")
sleep(1) sleep(1)
@ -177,7 +177,7 @@ class CapsulFlaskHub(VirtualizationInterface):
return to_return return to_return
def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_public_keys: list): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_authorized_keys: list):
validate_capsul_id(id) validate_capsul_id(id)
online_hosts = get_model().get_online_hosts() online_hosts = get_model().get_online_hosts()
payload = json.dumps(dict( payload = json.dumps(dict(
@ -187,7 +187,7 @@ class CapsulFlaskHub(VirtualizationInterface):
template_image_file_name=template_image_file_name, template_image_file_name=template_image_file_name,
vcpus=vcpus, vcpus=vcpus,
memory_mb=memory_mb, memory_mb=memory_mb,
ssh_public_keys=ssh_public_keys, ssh_authorized_keys=ssh_authorized_keys,
)) ))
op = self.asynchronous_operation(online_hosts, payload) op = self.asynchronous_operation(online_hosts, payload)
operation_id = op[0] operation_id = op[0]

View File

@ -33,7 +33,7 @@ class VirtualizationInterface:
def list_ids(self) -> list: def list_ids(self) -> list:
pass pass
def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory: int, ssh_public_keys: list): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory: int, ssh_authorized_keys: list):
pass pass
def destroy(self, email: str, id: str): def destroy(self, email: str, id: str):

View File

@ -101,7 +101,7 @@ def handle_create(operation_id, request_body):
current_app.logger.error(f"/hosts/operation returned 400: operation_id is required for create ") current_app.logger.error(f"/hosts/operation returned 400: operation_id is required for create ")
return abort(400, f"bad request; operation_id is required. try POST /spoke/operation/<id>") return abort(400, f"bad request; operation_id is required. try POST /spoke/operation/<id>")
parameters = ["email", "id", "template_image_file_name", "vcpus", "memory_mb", "ssh_public_keys"] parameters = ["email", "id", "template_image_file_name", "vcpus", "memory_mb", "ssh_authorized_keys"]
error_message = "" error_message = ""
for parameter in parameters: for parameter in parameters:
if parameter not in request_body: if parameter not in request_body:
@ -134,13 +134,13 @@ def handle_create(operation_id, request_body):
template_image_file_name=request_body['template_image_file_name'], template_image_file_name=request_body['template_image_file_name'],
vcpus=request_body['vcpus'], vcpus=request_body['vcpus'],
memory_mb=request_body['memory_mb'], memory_mb=request_body['memory_mb'],
ssh_public_keys=request_body['ssh_public_keys'], ssh_authorized_keys=request_body['ssh_authorized_keys'],
) )
except: except:
error_message = my_exec_info_message(sys.exc_info()) error_message = my_exec_info_message(sys.exc_info())
params = f"email='{request_body['email']}', id='{request_body['id']}', " params = f"email='{request_body['email']}', id='{request_body['id']}', "
params = f"{params}, template_image_file_name='{request_body['template_image_file_name']}', vcpus='{request_body['vcpus']}'" params = f"{params}, template_image_file_name='{request_body['template_image_file_name']}', vcpus='{request_body['vcpus']}'"
params = f"{params}, memory_mb='{request_body['memory_mb']}', ssh_public_keys='{request_body['ssh_public_keys']}'" params = f"{params}, memory_mb='{request_body['memory_mb']}', ssh_authorized_keys='{request_body['ssh_authorized_keys']}'"
current_app.logger.error(f"spoke_model.create({params}) failed: {error_message}") current_app.logger.error(f"spoke_model.create({params}) failed: {error_message}")
return jsonify(dict(assignment_status=assignment_status, error_message=error_message)) return jsonify(dict(assignment_status=assignment_status, error_message=error_message))

View File

@ -33,7 +33,7 @@ class MockSpoke(VirtualizationInterface):
def list_ids(self) -> list: def list_ids(self) -> list:
return get_model().all_non_deleted_vm_ids() return get_model().all_non_deleted_vm_ids()
def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_public_keys: list): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_authorized_keys: list):
validate_capsul_id(id) validate_capsul_id(id)
current_app.logger.info(f"mock create: {id} for {email}") current_app.logger.info(f"mock create: {id} for {email}")
sleep(1) sleep(1)
@ -107,15 +107,15 @@ class ShellScriptSpoke(VirtualizationInterface):
self.validate_completed_process(completedProcess) self.validate_completed_process(completedProcess)
return list(map(lambda x: x.decode("utf-8"), completedProcess.stdout.splitlines() )) return list(map(lambda x: x.decode("utf-8"), completedProcess.stdout.splitlines() ))
def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_public_keys: list): def create(self, email: str, id: str, template_image_file_name: str, vcpus: int, memory_mb: int, ssh_authorized_keys: list):
validate_capsul_id(id) validate_capsul_id(id)
if not re.match(r"^[a-zA-Z0-9/_.-]+$", template_image_file_name): if not re.match(r"^[a-zA-Z0-9/_.-]+$", template_image_file_name):
raise ValueError(f"template_image_file_name \"{template_image_file_name}\" must match \"^[a-zA-Z0-9/_.-]+$\"") raise ValueError(f"template_image_file_name \"{template_image_file_name}\" must match \"^[a-zA-Z0-9/_.-]+$\"")
for ssh_public_key in ssh_public_keys: for ssh_authorized_key in ssh_authorized_keys:
if not re.match(r"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$", ssh_public_key): if not re.match(r"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$", ssh_authorized_key):
raise ValueError(f"ssh_public_key \"{ssh_public_key}\" must match \"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$\"") raise ValueError(f"ssh_authorized_key \"{ssh_authorized_key}\" must match \"^(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$\"")
if vcpus < 1 or vcpus > 8: if vcpus < 1 or vcpus > 8:
raise ValueError(f"vcpus \"{vcpus}\" must match 1 <= vcpus <= 8") raise ValueError(f"vcpus \"{vcpus}\" must match 1 <= vcpus <= 8")
@ -123,7 +123,7 @@ class ShellScriptSpoke(VirtualizationInterface):
if memory_mb < 512 or memory_mb > 16384: if memory_mb < 512 or memory_mb > 16384:
raise ValueError(f"memory_mb \"{memory_mb}\" must match 512 <= memory_mb <= 16384") raise ValueError(f"memory_mb \"{memory_mb}\" must match 512 <= memory_mb <= 16384")
ssh_keys_string = "\n".join(ssh_public_keys) ssh_keys_string = "\n".join(ssh_authorized_keys)
completedProcess = run([ completedProcess = run([
join(current_app.root_path, 'shell_scripts/create.sh'), join(current_app.root_path, 'shell_scripts/create.sh'),
@ -143,7 +143,7 @@ class ShellScriptSpoke(VirtualizationInterface):
template_image_file_name={template_image_file_name} template_image_file_name={template_image_file_name}
vcpus={str(vcpus)} vcpus={str(vcpus)}
memory={str(memory_mb)} memory={str(memory_mb)}
ssh_public_keys={ssh_keys_string} ssh_authorized_keys={ssh_keys_string}
""" """
if not status == "success": if not status == "success":

View File

@ -53,10 +53,10 @@
</select> </select>
</div> </div>
<div class="row justify-start"> <div class="row justify-start">
<input type="hidden" name="ssh_public_key_count" value="{{ ssh_public_key_count}}"/> <input type="hidden" name="ssh_authorized_key_count" value="{{ ssh_authorized_key_count}}"/>
<label class="align" for="ssh_keys">SSH Public Keys</label> <label class="align" for="ssh_keys">SSH Public Keys</label>
<div id="ssh_keys"> <div id="ssh_keys">
{% for key in ssh_public_keys %} {% for key in ssh_authorized_keys %}
<label for="ssh_key_{{ loop.index - 1 }}"> <label for="ssh_key_{{ loop.index - 1 }}">
<input type="checkbox" id="ssh_key_{{ loop.index - 1 }}" name="ssh_key_{{ loop.index - 1 }}" value="{{ key['name'] }}"/> <input type="checkbox" id="ssh_key_{{ loop.index - 1 }}" name="ssh_key_{{ loop.index - 1 }}" value="{{ key['name'] }}"/>
{{ key['name'] }} {{ key['name'] }}