Skip to content

Commit

Permalink
release 1.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Canux CHENG authored and Canux CHENG committed Nov 2, 2019
1 parent 99ef933 commit 45918cb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/virtualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class virConnect::
// network
listAllNetworks(self, flags=0)
listDefinedNetworks(self)
listNetworks(self)
listNetworks(self) // inactive not show up.
networkCreateXML(self, xmlDesc) # temporary
networkDefineXML(self, xml) # persistent
networkLookupByName(self, name)
networkLookupByName(self, name) // not exist will raise exception.

// interface
listAllInterfaces(self, flags=0)
Expand Down
2 changes: 1 addition & 1 deletion super_devops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
DESCRIPTION:
"""

__version__ = "1.8.3"
__version__ = "1.8.4"
__author__ = "Canux CHENG"
15 changes: 14 additions & 1 deletion super_devops/virtualization/libvirt_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,22 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
self.connection.close()

def list_all_networks(self):
try:
networks = self.connection.listAllNetworks()
names = [
net.name()
for net in networks
]
except Exception as e:
logger.error("List all networks failed.")
else:
logger.debug("all networks: {}".format(names))
return names

def network_exist(self, name):
try:
if name in self.connection.listNetworks():
if name in self.list_all_networks():
logger.debug("network {} exist.".format(name))
return True
else:
Expand Down
10 changes: 5 additions & 5 deletions super_devops/virtualization/vbox_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,18 @@ def attach_storage(self, vm):
rc = process.returncode
except Exception as e:
logger.error(
"attach storage for vm {} error: {}.".format(name, e.args)
"attach storage for vm {} error: {}.".format(vm, e.args)
)
raise
else:
if rc:
logger.error(
"attach storage for vm {} failed with exit_code: {}".format(
name, rc)
vm, rc)
)
return False
else:
logger.info("attach storage for vm {} succeed.".format(name))
logger.info("attach storage for vm {} succeed.".format(vm))
return True

def list_vm(self, running=False):
Expand Down Expand Up @@ -615,8 +615,8 @@ def linux_shell(self, vm, username, password, shell):
stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
output, error = process.communicate()
output = output.decode("utf-8")
error = error.decode("utf-8")
# output = output.decode("utf-8")
# error = error.decode("utf-8")
logger.debug("output: {}".format(output))
logger.debug("error: {}".format(error))
rc = process.returncode
Expand Down

0 comments on commit 45918cb

Please sign in to comment.