Lines 688-693
class Node(PersistentCached):
|
Link Here
|
---|
|
688 |
try: |
688 |
try: |
689 |
domStat = self.domains[uuid] |
689 |
domStat = self.domains[uuid] |
690 |
domStat.update( dom ) |
690 |
domStat.update( dom ) |
|
|
691 |
self.write_novnc_tokens() |
691 |
except KeyError: |
692 |
except KeyError: |
692 |
# during migration events are not ordered causal |
693 |
# during migration events are not ordered causal |
693 |
pass |
694 |
pass |
Lines 735-741
class Node(PersistentCached):
|
Link Here
|
---|
|
735 |
for name in self.conn.listDefinedDomains(): |
736 |
for name in self.conn.listDefinedDomains(): |
736 |
yield self.conn.lookupByName(name) |
737 |
yield self.conn.lookupByName(name) |
737 |
|
738 |
|
738 |
novnc_mapping = {} |
|
|
739 |
for dom in all_domains(): |
739 |
for dom in all_domains(): |
740 |
uuid = dom.UUIDString() |
740 |
uuid = dom.UUIDString() |
741 |
if uuid in self.domains: |
741 |
if uuid in self.domains: |
Lines 753-759
class Node(PersistentCached):
|
Link Here
|
---|
|
753 |
curMem += domStat.pd.curMem |
753 |
curMem += domStat.pd.curMem |
754 |
maxMem += domStat.pd.maxMem |
754 |
maxMem += domStat.pd.maxMem |
755 |
cpu_usage += domStat._cpu_usage |
755 |
cpu_usage += domStat._cpu_usage |
756 |
self.get_novnc_mapping(domStat, novnc_mapping) |
|
|
757 |
for uuid in cached_domains: |
756 |
for uuid in cached_domains: |
758 |
# Remove obsolete domains |
757 |
# Remove obsolete domains |
759 |
del self.domains[uuid] |
758 |
del self.domains[uuid] |
Lines 769-792
class Node(PersistentCached):
|
Link Here
|
---|
|
769 |
self._cache_id = cache_id |
768 |
self._cache_id = cache_id |
770 |
except IOError, ex: |
769 |
except IOError, ex: |
771 |
logger.exception("Failed to write cached node %s: %s" % (self.pd.uri, ex)) |
770 |
logger.exception("Failed to write cached node %s: %s" % (self.pd.uri, ex)) |
772 |
self.write_novnc_tokens(novnc_mapping) |
771 |
self.write_novnc_tokens() |
773 |
|
772 |
|
774 |
def get_novnc_mapping(self, domStat, mapping): |
773 |
def write_novnc_tokens(self): |
775 |
try: |
|
|
776 |
gfx = domStat.pd.graphics[0] |
777 |
except (AttributeError, IndexError), ex: |
778 |
pass |
779 |
else: |
780 |
if gfx.type == Graphic.TYPE_VNC and gfx.listen == '0.0.0.0' and gfx.port > 0: |
781 |
mapping[domStat.pd.uuid] = (self.pd.name, gfx.port) |
782 |
|
783 |
def write_novnc_tokens(self, mapping): |
784 |
path = os.path.join(self.cache_dir, 'novnc.tokens', uri_encode(self.pd.uri)) |
774 |
path = os.path.join(self.cache_dir, 'novnc.tokens', uri_encode(self.pd.uri)) |
785 |
logger.debug("Writing noVNC tokens to '%s'", path) |
775 |
logger.debug("Writing noVNC tokens to '%s'", path) |
786 |
tmp_path = path + '.new' |
776 |
tmp_path = path + '.new' |
787 |
with open(tmp_path, 'w') as token_file: |
777 |
with open(tmp_path, 'w') as token_file: |
788 |
for uuid, (host, port) in mapping.iteritems(): |
778 |
for uuid, domStat in self.domains.iteritems(): |
789 |
print >> token_file, '%s: %s:%d' % (uuid, host, port) |
779 |
try: |
|
|
780 |
gfx = domStat.pd.graphics[0] |
781 |
except (AttributeError, IndexError): |
782 |
continue |
783 |
if gfx.type != Graphic.TYPE_VNC: |
784 |
continue |
785 |
if gfx.listen != '0.0.0.0': |
786 |
continue |
787 |
if gfx.port <= 0: |
788 |
continue |
789 |
print >> token_file, '%s: %s:%d' % (uuid, self.pd.name, gfx.port) |
790 |
os.rename(tmp_path, path) |
790 |
os.rename(tmp_path, path) |
791 |
|
791 |
|
792 |
def wait_update(self, domain, state_key, timeout=10): |
792 |
def wait_update(self, domain, state_key, timeout=10): |