Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keystoneauth1 import loading
- from keystoneauth1 import session
- from cinderclient import client
- class Cl_Session(object):
- def __init__(self,project_id):
- self.loader = loading.get_plugin_loader('password')
- self.auth_url = 'http://10.10.33.140:35357/v3'
- self.username = 'admin'
- self.password = 'k3st0ne2017ZEtka'
- self.project_id = project_id
- self.user_domain_name = 'default'
- self.auth = self.loader.load_from_options(auth_url=self.auth_url,username=self.username, password=self.password,
- project_id= self.project_id, user_domain_name=self.user_domain_name)
- self.sess = session.Session(auth=self.auth)
- self.cinder = client.Client('3', session=self.sess)
- def create_snapshot(self, volume_id, snap_name):
- create_snapshot=self.cinder.volume_snapshots.create(volume_id=volume_id,force=True,name=snap_name)
- return create_snapshot
- def get_snapshot(self, snapshot_id):
- get_snapshot=self.cinder.volume_snapshots.get(snapshot_id)
- return snapshot_id
- def create_backup(self, volume_id, snapshot_id, backup_name):
- create_backup=self.cinder.backups.create(volume_id=volume_id,snapshot_id=snapshot_id,name=backup_name,force=True)
- return create_backup
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement