Skip to content

Commit

Permalink
Merge branch 'dev' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Nov 2, 2023
2 parents bfe8a64 + fde8a67 commit 0783583
Show file tree
Hide file tree
Showing 8 changed files with 940 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-yaml

- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.10.1
hooks:
- id: black
- repo: https://github.com/sondrelg/pep585-upgrade
Expand Down
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
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ Click==8.1.7
ansible==8.5.0
flake8==6.1.0
paramiko==2.12.0
ruamel.yaml==0.17.36
ruamel.yaml==0.18.4
pyvim==3.0.3
redis==5.0.1
requests==2.31.0
pyyaml==6.0.1
pre-commit==3.5.0
types-PyYAML==6.0.12.12
sympy==1.12
types-redis==4.6.0.7
types-redis==4.6.0.8
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 0783583

Please sign in to comment.