Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben Schuller committed May 30, 2017
2 parents 7780b28 + 46c1362 commit 8e8aec5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
38 changes: 22 additions & 16 deletions idbiaas/idbiaas.py
Expand Up @@ -112,15 +112,18 @@ def machines(self):
for host in self.hosts:
logging.debug("LibvirtZone: retrieving nodes from %s", host.uri())

driver = libcloud.compute.providers.get_driver(
libcloud.compute.types.Provider.LIBVIRT)(uri=host.uri())

nodes = driver.list_nodes()
for node in nodes:
logging.debug("LibvirtZone: got node %s", node)
idb_machines.append(IDBMachine(
node.name, driver.ex_get_hypervisor_hostname(),
node.extra['vcpu_count'], node.extra['used_memory']))
try:
driver = libcloud.compute.providers.get_driver(
libcloud.compute.types.Provider.LIBVIRT)(uri=host.uri())

nodes = driver.list_nodes()
for node in nodes:
logging.debug("LibvirtZone: got node %s", node)
idb_machines.append(IDBMachine(
node.name, driver.ex_get_hypervisor_hostname(),
node.extra['vcpu_count'], node.extra['used_memory']))
except Exception as e:
logging.debug("LibvirtZone: %s, continuing with next host", e)

return idb_machines

Expand All @@ -139,13 +142,16 @@ def machines(self):
logging.debug("DigitalOceanZone: retrieving nodes")
idb_machines = []

driver = libcloud.compute.providers.get_driver(
libcloud.compute.types.Provider.DIGITAL_OCEAN)(self.token, api_version=self.version)
try:
driver = libcloud.compute.providers.get_driver(
libcloud.compute.types.Provider.DIGITAL_OCEAN)(self.token, api_version=self.version)

nodes = driver.list_nodes()
for node in nodes:
logging.debug("DigitalOceanZone: got node %s", node)
idb_machines.append(IDBMachine(node.name, "", node.extra["vcpus"], node.extra["memory"]))
nodes = driver.list_nodes()
for node in nodes:
logging.debug("DigitalOceanZone: got node %s", node)
idb_machines.append(IDBMachine(node.name, "", node.extra["vcpus"], node.extra["memory"]))
except Exception as e:
logging.debug("DigitalOceanZone: %s, continuing with next host", e)

return idb_machines

Expand Down Expand Up @@ -201,7 +207,7 @@ def grouper(self, iterable, n, fillvalue=None):

def json_machines(self, machines):
"""Converts machines list to IDB compatible json."""
return json.dumps({"create_machine": self.create, "machines": [x.dict() for x in machines]})
return json.dumps({"create_machine": self.create, "machines": [x.dict() for x in machines if x != None]})

def submit_machines(self, machines):
"""Submit machines to the IDB."""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -2,7 +2,7 @@

setup(
name="idbiaas",
version="0.0.2",
version="0.0.3",
description="IDB IAAS adapter",
packages=["idbiaas"],
author="bytemine GmbH",
Expand Down

0 comments on commit 8e8aec5

Please sign in to comment.