Skip to content

Commit

Permalink
Merge pull request #591 from deNBI/feat/metadata_get_script
Browse files Browse the repository at this point in the history
Feat/metadata get script
  • Loading branch information
vktrrdk authored Sep 18, 2024
2 parents 1ed2de9 + 3ef635d commit 59dd1e1
Show file tree
Hide file tree
Showing 9 changed files with 911 additions and 464 deletions.
23 changes: 19 additions & 4 deletions portal_client.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ typedef i32 int
const string VERSION= '1.0.0'


struct User {
1: optional string username,
2: required string user_id,
3: optional list<string> public_keys,
}

struct UserData {
2: required map<string, User> data = {},
}

struct VirtualMachineServerMetadata {
1: list<string> public_keys
2: string hashed_auth_token
3: string ip
1: required string ip,
2: required string hashed_auth_token,
3: optional UserData userdata,
}


struct Backend {
1: i64 id,
2: string owner,
Expand Down Expand Up @@ -466,6 +478,7 @@ service VirtualMachineService {
11:optional list<string> additional_security_group_ids,
12:optional string slurm_version,
13:optional string metadata_token,
14:optional string metadata_endpoint

)

Expand Down Expand Up @@ -500,6 +513,8 @@ service VirtualMachineService {
8:list<map<string,string>> volume_ids_path_attach,
9:optional list<string> additional_security_group_ids,
10:optional string metadata_token,
11:optional string metadata_endpoint


) throws (1:NameAlreadyUsedException e,2:ResourceNotAvailableException r,3: ImageNotFoundException i,4: FlavorNotFoundException f,5:DefaultException d)

Expand Down Expand Up @@ -558,7 +573,7 @@ service VirtualMachineService {
) throws (1:BackendNotFoundException b,2:DefaultException d)


void set_metadata_server_data(1:string ip,2:VirtualMachineServerMetadata metadata) throws (1:MetadataServerNotAvailableException m,2:MetadataServerNotAllowedException b)
void set_metadata_server_data(1:string ip,3:VirtualMachineServerMetadata metadata) throws (1:MetadataServerNotAvailableException m,2:MetadataServerNotAllowedException b)
void remove_metadata_server_data(1:string ip) throws (1:MetadataServerNotAvailableException m,2:MetadataServerNotAllowedException b)
void is_metadata_server_available() throws (1:MetadataServerNotAvailableException m,2:MetadataServerNotAllowedException b)

Expand Down
4 changes: 4 additions & 0 deletions simple_vm_client/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def start_server(
additional_security_group_ids: list[str],
slurm_version: str = None,
metadata_token: str = None,
metadata_endpoint: str = None,
) -> str:
if research_environment:
research_environment_metadata = (
Expand All @@ -405,6 +406,7 @@ def start_server(
additional_security_group_ids=additional_security_group_ids,
slurm_version=slurm_version,
metadata_token=metadata_token,
metadata_endpoint=metadata_endpoint,
)

def start_server_with_custom_key(
Expand All @@ -418,6 +420,7 @@ def start_server_with_custom_key(
volume_ids_path_attach: list[dict[str, str]],
additional_security_group_ids: list[str],
metadata_token: str = None,
metadata_endpoint: str = None,
) -> str:
if research_environment:
research_environment_metadata = (
Expand All @@ -437,6 +440,7 @@ def start_server_with_custom_key(
volume_ids_path_attach=volume_ids_path_attach,
additional_security_group_ids=additional_security_group_ids,
metadata_token=metadata_token,
metadata_endpoint=metadata_endpoint,
)
self.forc_connector.set_vm_wait_for_playbook(
openstack_id=openstack_id, private_key=private_key, name=servername
Expand Down
14 changes: 8 additions & 6 deletions simple_vm_client/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ if len(sys.argv) <= 1 or sys.argv[1] == "--help":
print(" void delete_security_group_rule(string openstack_id)")
print(" void delete_server(string openstack_id)")
print(
" string start_server(string flavor_name, string image_name, string public_key, string servername, metadata, volume_ids_path_new, volume_ids_path_attach, additional_keys, string research_environment, additional_security_group_ids, string slurm_version, string metadata_token)"
" string start_server(string flavor_name, string image_name, string public_key, string servername, metadata, volume_ids_path_new, volume_ids_path_attach, additional_keys, string research_environment, additional_security_group_ids, string slurm_version, string metadata_token, string metadata_endpoint)"
)
print(" bool is_bibigrid_available()")
print(" void detach_ip_from_server(string server_id, string floating_ip)")
print(
" string start_server_with_custom_key(string flavor_name, string image_name, string servername, metadata, string research_environment, volume_ids_path_new, volume_ids_path_attach, additional_security_group_ids, string metadata_token)"
" string start_server_with_custom_key(string flavor_name, string image_name, string servername, metadata, string research_environment, volume_ids_path_new, volume_ids_path_attach, additional_security_group_ids, string metadata_token, string metadata_endpoint)"
)
print(" bool exist_server(string name)")
print(
Expand Down Expand Up @@ -396,8 +396,8 @@ elif cmd == "delete_server":
)

elif cmd == "start_server":
if len(args) != 12:
print("start_server requires 12 args")
if len(args) != 13:
print("start_server requires 13 args")
sys.exit(1)
pp.pprint(
client.start_server(
Expand All @@ -413,6 +413,7 @@ elif cmd == "start_server":
eval(args[9]),
args[10],
args[11],
args[12],
)
)

Expand All @@ -434,8 +435,8 @@ elif cmd == "detach_ip_from_server":
)

elif cmd == "start_server_with_custom_key":
if len(args) != 9:
print("start_server_with_custom_key requires 9 args")
if len(args) != 10:
print("start_server_with_custom_key requires 10 args")
sys.exit(1)
pp.pprint(
client.start_server_with_custom_key(
Expand All @@ -448,6 +449,7 @@ elif cmd == "start_server_with_custom_key":
eval(args[6]),
eval(args[7]),
args[8],
args[9],
)
)

Expand Down
Loading

0 comments on commit 59dd1e1

Please sign in to comment.