1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 15:45:23 +00:00
webvirtcloud/vrtManager/secrets.py

32 lines
1 KiB
Python
Raw Normal View History

2015-02-27 08:53:51 +00:00
import base64
from vrtManager.connection import wvmConnect
class wvmSecrets(wvmConnect):
def create_secret(self, ephemeral, private, secret_type, data):
xml = """<secret ephemeral='%s' private='%s'>
<usage type='%s'>""" % (ephemeral, private, secret_type)
if secret_type == 'ceph':
2019-09-10 06:48:31 +00:00
xml += """<name>%s</name>""" % data
2015-02-27 08:53:51 +00:00
if secret_type == 'volume':
2019-09-10 06:48:31 +00:00
xml += """<volume>%s</volume>""" % data
2015-02-27 08:53:51 +00:00
if secret_type == 'iscsi':
2019-09-10 06:48:31 +00:00
xml += """<target>%s</target>""" % data
2015-02-27 08:53:51 +00:00
xml += """</usage>
</secret>"""
self.wvm.secretDefineXML(xml)
def get_secret_value(self, uuid):
secrt = self.get_secret(uuid)
value = secrt.value()
return base64.b64encode(value)
def set_secret_value(self, uuid, value):
secrt = self.get_secret(uuid)
value = base64.b64decode(value)
secrt.setValue(value)
def delete_secret(self, uuid):
secrt = self.get_secret(uuid)
secrt.undefine()