def _setupVdsConnection(self): if self._mode == "file": return self.remoteHost = self._dst.split(":")[0] self.remotePort = self._vm.cif.serverPort try: self.remotePort = self._dst.split(":")[1] except: pass serverAddress = self.remoteHost + ":" + self.remotePort if config.getboolean("vars", "ssl"): self.destServer = vdscli.connect( serverAddress, useSSL=True, TransportClass=kaxmlrpclib.TcpkeepSafeTransport ) else: self.destServer = kaxmlrpclib.Server("http://" + serverAddress) self.log.debug("Destination server is: " + serverAddress) try: self.log.debug("Initiating connection with destination") status = self.destServer.getVmStats(self._vm.id) if not status["status"]["code"]: self.log.error("Machine already exists on the destination") self.status = errCode["exist"] except: self.log.error(traceback.format_exc()) self.status = errCode["noConPeer"]
class getISCSIid: def __init__(self): self.useSSL = None self.truststore = None self.host = None self.iqn = None def do_connect(self, server, port): print "Trying to connect to vdsmd host (%s).." % server # Connection Validation sk = socket.socket() # Timeout 8 sec sk.settimeout(8) try: sk.connect((server, int(VDSM_PORT))) except Exception, e: print "Unable to connect %s" % server sk.close() return -1 self.s = vdscli.connect(server + ':' + port, self.useSSL, self.truststore) print "OK, Connected to vdsmd!" return 0
line = line + ' %s |' % (adding) print '%s' % (line) row += 1 self._printRowSep(rowSep, columnNum) def show(self): '''Show the Storage Table''' try: depth = 0 self._printTableSegment(0, alignCenter=True, printHeader=True) for depth in range(0, len(self.tbl['Domains'])): self._printTableSegment(depth) return 0, '' except: return 1, traceback.format_exc() if __name__ == '__main__': import vdscli import sys rc, msg = StorageTable(vdscli.connect()).show() if rc: print >>sys.stderr, msg sys.exit(rc)
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking import vdscli s = vdscli.connect() res = s.list(True) if res["status"]["code"] == 0: if not [ v for v in res["vmList"] if v.get("vmId") != os.environ.get("vmId") and hooking.tobool(v.get("custom", {}).get("sap_agent", False)) ]: subprocess.call(["/usr/bin/sudo", "-n", "/sbin/service", "vhostmd", "stop"])
line = line + ' %s |' % (adding) print '%s' % (line) row += 1 self._printRowSep(rowSep, columnNum) def show(self): '''Show the Storage Table''' try: depth = 0 self._printTableSegment(0, alignCenter=True, printHeader=True) for depth in range(0, len(self.tbl['Domains'])): self._printTableSegment(depth) return 0, '' except: return 1, traceback.format_exc() if __name__ == '__main__': import vdscli import sys rc, msg = StorageTable(vdscli.connect()).show() if rc: print >> sys.stderr, msg sys.exit(rc)
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking import vdscli s = vdscli.connect() res = s.list(True) if res['status']['code'] == 0: if not [ v for v in res['vmList'] if v.get('vmId') != os.environ.get('vmId') and hooking.tobool(v.get('custom', {}).get('sap_agent', False)) ]: subprocess.call( ['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'stop'])