Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. from keystoneauth1 import loading
  2. from keystoneauth1 import session
  3. from cinderclient import client
  4.  
  5.  
  6. class Cl_Session(object):
  7.     def __init__(self,project_id):
  8.         self.loader = loading.get_plugin_loader('password')
  9.         self.auth_url = 'http://10.10.33.140:35357/v3'
  10.         self.username = 'admin'
  11.         self.password = 'k3st0ne2017ZEtka'
  12.         self.project_id = project_id
  13.         self.user_domain_name = 'default'
  14.         self.auth = self.loader.load_from_options(auth_url=self.auth_url,username=self.username, password=self.password,
  15.                 project_id= self.project_id, user_domain_name=self.user_domain_name)
  16.         self.sess = session.Session(auth=self.auth)
  17.         self.cinder = client.Client('3', session=self.sess)
  18.  
  19.     def create_snapshot(self, volume_id, snap_name):
  20.         create_snapshot=self.cinder.volume_snapshots.create(volume_id=volume_id,force=True,name=snap_name)
  21.         return create_snapshot
  22.  
  23.     def get_snapshot(self, snapshot_id):
  24.         get_snapshot=self.cinder.volume_snapshots.get(snapshot_id)
  25.         return snapshot_id
  26.  
  27.     def create_backup(self, volume_id, snapshot_id, backup_name):
  28.         create_backup=self.cinder.backups.create(volume_id=volume_id,snapshot_id=snapshot_id,name=backup_name,force=True)
  29.         return create_backup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement