Skip to content

Commit

Permalink
Merge pull request #414 from deNBI/feat/ports
Browse files Browse the repository at this point in the history
Feat/ports
  • Loading branch information
vktrrdk authored Nov 2, 2023
2 parents d6bcef2 + 9b207c6 commit fde8a67
Show file tree
Hide file tree
Showing 6 changed files with 937 additions and 1 deletion.
11 changes: 11 additions & 0 deletions portal_client.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ exception ServerNotFoundException {
2: string name_or_id
}

exception SecurityGroupRuleNotFoundException {
/** Server not found. */
1: string message
2: string name_or_id
}

exception FlavorNotFoundException {
1: string message
Expand Down Expand Up @@ -388,6 +393,12 @@ service VirtualMachineService {

void resize_volume(1:string volume_id,2:int size) throws(1:VolumeNotFoundException v)

/**
* Creates/Updates a security group for a vm with a specific port range for a project
*/
string open_port_range_for_vm_in_project(1:int range_start,2:int range_stop,3:string openstack_id,4: string ethertype = "IPv4",5:string protocol ="TCP") throws (1:ServerNotFoundException e,2: DefaultException v,3:OpenStackConflictException o)

void delete_security_group_rule(1:string openstack_id) throws (1:SecurityGroupRuleNotFoundException e,2:DefaultException f)


/**
Expand Down
21 changes: 21 additions & 0 deletions simple_vm_client/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,27 @@ def delete_user_from_backend(self, backend_id: str, user_id: str) -> dict[str, s
def get_allowed_templates(self) -> list[ResearchEnvironmentTemplate]:
return self.forc_connector.template.get_allowed_templates()

def delete_security_group_rule(self, openstack_id):
return self.openstack_connector.delete_security_group_rule(
openstack_id=openstack_id
)

def open_port_range_for_vm_in_project(
self,
range_start,
range_stop,
openstack_id,
ethertype: str = "IPv4",
protocol: str = "TCP",
) -> str:
return self.openstack_connector.open_port_range_for_vm_in_project(
range_start=range_start,
range_stop=range_stop,
openstack_id=openstack_id,
ethertype=ethertype,
protocol=protocol,
)

def add_udp_security_group(self, server_id: str) -> None:
return self.openstack_connector.add_udp_security_group(server_id=server_id)

Expand Down
28 changes: 28 additions & 0 deletions simple_vm_client/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ if len(sys.argv) <= 1 or sys.argv[1] == "--help":
print(" Volume get_volume(string volume_id)")
print(" get_volumes_by_ids( volume_ids)")
print(" void resize_volume(string volume_id, int size)")
print(
" string open_port_range_for_vm_in_project(int range_start, int range_stop, string openstack_id, string ethertype, string protocol)"
)
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)"
Expand Down Expand Up @@ -334,6 +338,30 @@ elif cmd == "resize_volume":
)
)

elif cmd == "open_port_range_for_vm_in_project":
if len(args) != 5:
print("open_port_range_for_vm_in_project requires 5 args")
sys.exit(1)
pp.pprint(
client.open_port_range_for_vm_in_project(
eval(args[0]),
eval(args[1]),
args[2],
args[3],
args[4],
)
)

elif cmd == "delete_security_group_rule":
if len(args) != 1:
print("delete_security_group_rule requires 1 args")
sys.exit(1)
pp.pprint(
client.delete_security_group_rule(
args[0],
)
)

elif cmd == "delete_server":
if len(args) != 1:
print("delete_server requires 1 args")
Expand Down
Loading

0 comments on commit fde8a67

Please sign in to comment.