Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Feature/snapshot (#56)
Browse files Browse the repository at this point in the history
* feat(snapshot):added snapshot function

* feat(handler):fixed response createsnapshot

* feat(snapshot):added baseimtagetag
  • Loading branch information
dweinholz authored Jul 12, 2018
1 parent 03df98e commit 8efeb75
Show file tree
Hide file tree
Showing 4 changed files with 242 additions and 2 deletions.
9 changes: 9 additions & 0 deletions gen-py/VirtualMachineService/VirtualMachineHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,15 @@ def get_IP_PORT(self, openstack_id):

return {'IP': str(floating_ip)}

def create_snapshot(self,openstack_id,name,elixir_id,base_tag):
self.logger.info('Create Snapshot from Instance {0} with name {1} for {2}'.format(openstack_id,name,elixir_id))

snapshot_munch= self.conn.create_image_snapshot(server=openstack_id,name=name)
snapshot_id=snapshot_munch['id']
self.conn.image.add_tag(image=snapshot_id,tag=elixir_id)
self.conn.image.add_tag(image=snapshot_id,tag='snapshot_image:{0}'.format(base_tag))
return True


def add_floating_ip_to_server(self, openstack_id, network):

Expand Down
7 changes: 7 additions & 0 deletions gen-py/VirtualMachineService/VirtualMachineService-remote
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print(' start_server(string flavor, string image, string public_key, string servername, string elixir_id, string diskspace)')
print(' VM get_server(string openstack_id)')
print(' bool stop_server(string openstack_id)')
print(' bool create_snapshot(string openstack_id, string name, string elixir_id, string base_tag)')
print(' bool attach_volume_to_server(string openstack_id, int diskspace, string volume_id)')
print(' VM check_server_status(string openstack_id, int diskspace, string volume_id)')
print(' string setUserPassword(string user, string password)')
Expand Down Expand Up @@ -198,6 +199,12 @@ elif cmd == 'stop_server':
sys.exit(1)
pp.pprint(client.stop_server(args[0],))

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

elif cmd == 'attach_volume_to_server':
if len(args) != 3:
print('attach_volume_to_server requires 3 args')
Expand Down
226 changes: 224 additions & 2 deletions gen-py/VirtualMachineService/VirtualMachineService.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions portal_client.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ service VirtualMachineService {
* This Method unpause a VirtualMachine with a specific Openstack-ID.
*/

bool create_snapshot(1:string openstack_id, 2:string name,3: string elixir_id,4:string base_tag)



bool attach_volume_to_server(1:string openstack_id,2:int diskspace,3:string volume_id) throws (1:serverNotFoundException e),
Expand Down

0 comments on commit 8efeb75

Please sign in to comment.