def main(): log_config.configure() logging.info("=== Starting vmdkops service ====") signal.signal(signal.SIGINT, signal_handler_stop) signal.signal(signal.SIGTERM, signal_handler_stop) try: port = 1019 opts, args = getopt.getopt(sys.argv[1:], 'hp:') except getopt.error as msg: if msg: logging.exception(msg) usage() return 1 for a, v in opts: if a == '-p': port = int(v) if a == '-h': usage() return 0 try: # Load and use DLL with vsocket shim to listen for docker requests load_vmci() kv.init() connectLocal() handleVmciRequests(port) except Exception as e: logging.exception(e)
def main(): log_config.configure() kv.init() if not vmdk_ops.is_service_available(): sys.exit('Unable to connect to the host-agent on this host, ensure the ESXi host agent is running before retrying.') args = parse_args() if args: args.func(args)
def main(): log_config.configure() logging.info("=== Starting vmdkops service ===") signal.signal(signal.SIGINT, signal_handler_stop) signal.signal(signal.SIGTERM, signal_handler_stop) try: kv.init() connectLocal() handleVmciRequests() except Exception, e: logging.exception(e)
self.assertPoliciesEqual() def test_double_create_fails(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) self.assertNotEqual(None, vsan_policy.create(self.name, self.content)) self.assertPoliciesEqual() def test_create_delete(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) self.assertPoliciesEqual() self.assertEqual(None, vsan_policy.delete(self.name)) self.assertFalse(os.path.isfile(self.policy_path)) def test_delete_nonexistent_policy_fails(self): log = log_config.get_logger('Delete_nonexistent_policy') log.info( "\nThis is a negative test to delete a non-existent vsan policy.\n" "Test is expected to raise exception log - Failed to remove the policy file error. \n" ) self.assertNotEqual(None, vsan_policy.delete(self.name)) def test_create_list(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) policies = vsan_policy.get_policies() self.assertTrue(self.content + '\n', policies[self.name]) if __name__ == '__main__': volume_kv.init() unittest.main()
policy_string = \ '(("hostFailuresToTolerate" i0) ("forceProvisioning" i1))' # same policy content with different space/tabs: same_policy = \ ' (( "hostFailuresToTolerate" \ti0) ("forceProvisioning" i1))' # different content: notsame_policy = \ '(("hostFailuresToTolerate" i0) ("forceProvisioning" i0))' err = vsan_info.set_policy(self.VMDK_PATH, policy_string) self.assertEqual(err, None, "failed to set") # get policy and check it p = vsan_info.get_policy(self.VMDK_PATH) self.assertTrue( vsan_info.same_policy(self.VMDK_PATH, p), "failed to compare with get_policy") self.assertTrue( vsan_info.same_policy(self.VMDK_PATH, policy_string), "failed to compare with original policy") self.assertTrue( vsan_info.same_policy(self.VMDK_PATH, same_policy), "failed to compare with same policy, different tabs") self.assertFalse( vsan_info.same_policy(self.VMDK_PATH, notsame_policy), "failed to compare with different policy") if __name__ == "__main__": log_config.configure() kv.init() unittest.main()
""" Test 'config' functionality """ def __init__(self, *args, **kwargs): super(TestConfig, self).__init__(*args, **kwargs) self.parser = vmdkops_admin.create_parser() def setUp(self): pass def tearDown(self): pass def test_config(self): '''Config testing''' # TBD: Init config and check status - should be NotConfigured args = self.parser.parse_args('config rm --local --confirm'.split()) self.assertEqual(vmdkops_admin.config_rm(args), None) args = self.parser.parse_args('config init --local'.split()) self.assertEqual(vmdkops_admin.config_init(args), None) # init # check status - should be MultiNode # init - should fail # init -f should succeed if __name__ == '__main__': kv.init() log_config.configure() unittest.main()
def main(argv): if argv == []: print 'vol_tests.py -d <test dir>' sys.exit(2) try: opts, args = getopt.getopt(argv, "hd:") except getopt.GetoptError: print 'vol_tests.py -d <test dir>' sys.exit(2) for opt, arg in opts: if opt == '-h': print 'vol_tests.py -v <vm config path> -d <volumes dir>' sys.exit() elif opt in ("-d"): volDir = arg # Init logging logfile = "%s/test.log" % volDir vmci.LogSetup(logfile) # Init KV kv.init() cmd = 'vim-cmd vmsvc/createdummyvm %s %s' % (vmName, volDir) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) s = proc.communicate()[0] vmId = s.rstrip() ret = proc.returncode atexit.register(cleanup, vmId) if ret != 0: print "Failed to power on VM, exiting", vmName sys.exit(0) # Start VM print "Starting VM %s with id %s ..." % (vmName, vmId) cmd = 'vim-cmd vmsvc/power.on %s' % vmId subprocess.call(cmd, shell=True) # Create volumes doCreate(volDir) # Attach/Re-attach volumes #doAttach(volDir, vmName) # Check volume meta-data #doVerifyVolMeta(volDir) # Detach volumes #doDetach(volDir, vmName) # Delete volumes doVolDelete(volDir)
def test_create(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) self.assertPoliciesEqual() def test_double_create_fails(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) self.assertNotEqual(None, vsan_policy.create(self.name, self.content)) self.assertPoliciesEqual() def test_create_delete(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) self.assertPoliciesEqual() self.assertEqual(None, vsan_policy.delete(self.name)) self.assertFalse(os.path.isfile(self.policy_path)) def test_delete_nonexistent_policy_fails(self): log = log_config.get_logger('Delete_nonexistent_policy') log.info("\nThis is a negative test to delete a non-existent vsan policy.\n" "Test is expected to raise exception log - Failed to remove the policy file error. \n") self.assertNotEqual(None, vsan_policy.delete(self.name)) def test_create_list(self): self.assertEqual(None, vsan_policy.create(self.name, self.content)) policies = vsan_policy.get_policies() self.assertTrue(self.content + '\n', policies[self.name]) if __name__ == '__main__': volume_kv.init() unittest.main()
def main(): kv.init() args = parse_args() if args: args.func(args)
def main(): kv.init() args = parse_args() args.func(args)
def main(): log_config.configure() kv.init() args = parse_args() if args: args.func(args)