def do_setup(self, context): if self.nms_protocol == 'auto': protocol, auto = 'http', True else: protocol, auto = self.nms_protocol, False self.nms = jsonrpc.NexentaJSONProxy( protocol, self.nms_host, self.nms_port, '/rest/nms', self.nms_user, self.nms_password, auto=auto)
def do_setup(self, context): if self.nms_protocol == 'auto': protocol, auto = 'http', True else: protocol, auto = self.nms_protocol, False self.nms = jsonrpc.NexentaJSONProxy(protocol, self.nms_host, self.nms_port, '/rest/nms', self.nms_user, self.nms_password, self.verify_ssl, auto=auto) license = self.nms.appliance.get_license_info() signature = license.get('machine_sig') LOG.debug('NexentaStor Host Signature: %(signature)s', {'signature': signature}) plugin = 'nms-rsf-cluster' plugins = self.nms.plugin.get_names('') if isinstance(plugins, list) and plugin in plugins: names = self.nms.rsf_plugin.get_names('') if isinstance(names, list) and len(names) == 1: name = names[0] prop = 'machinesigs' props = self.nms.rsf_plugin.get_child_props(name, '') if isinstance(props, dict) and prop in props: signatures = json.loads(props.get(prop)) if isinstance(signatures, dict) and \ signature in signatures.values(): signature = ':'.join(sorted(signatures.values())) LOG.debug( 'NexentaStor HA Cluster Signature: ' '%(signature)s', {'signature': signature}) else: LOG.debug( 'HA Cluster plugin %(plugin)s is not ' 'configured for NexentaStor Host ' '%(signature)s: %(signatures)s', { 'plugin': plugin, 'signature': signature, 'signatures': signatures }) else: LOG.debug('HA Cluster plugin %(plugin)s is misconfigured', {'plugin': plugin}) else: LOG.debug( 'HA Cluster plugin %(plugin)s is not configured ' 'or is misconfigured', {'plugin': plugin}) else: LOG.debug('HA Cluster plugin %(plugin)s is not installed', {'plugin': plugin}) self.lock = hashlib.md5(signature).hexdigest() LOG.debug('NMS coordination lock: %(lock)s', {'lock': self.lock})
def setUp(self): super(TestNexentaJSONRPC, self).setUp() self.proxy = jsonrpc.NexentaJSONProxy( 'http', self.HOST, 2000, '/', self.USER, self.PASSWORD, auto=True) self.mox.StubOutWithMock(urllib2, 'Request', True) self.mox.StubOutWithMock(urllib2, 'urlopen') self.resp_mock = self.mox.CreateMockAnything() self.resp_info_mock = self.mox.CreateMockAnything() self.resp_mock.info().AndReturn(self.resp_info_mock) urllib2.urlopen(self.REQUEST).AndReturn(self.resp_mock)
def _get_nms_for_url(self, url): """Returns initialized nms object for url.""" auto, scheme, user, password, host, port, path =\ utils.parse_nms_url(url) return jsonrpc.NexentaJSONProxy(scheme, host, port, path, user, password, auto=auto)
def do_setup(self, context): protocol = self.configuration.nexenta_rest_protocol auto = protocol == 'auto' if auto: protocol = 'http' url = '%s://%s:%s/rest/nms/' % (protocol, self.configuration.nexenta_host, self.configuration.nexenta_rest_port) self.nms = jsonrpc.NexentaJSONProxy( url, self.configuration.nexenta_user, self.configuration.nexenta_password, auto=auto)
def do_setup(self, context): protocol = CONF.nexenta_rest_protocol auto = protocol == 'auto' if auto: protocol = 'http' self.nms = jsonrpc.NexentaJSONProxy( '%s://%s:%s/rest/nms/' % (protocol, CONF.nexenta_host, CONF.nexenta_rest_port), CONF.nexenta_user, CONF.nexenta_password, auto=auto)
def do_setup(self, context): protocol = self.configuration.nexenta_rest_protocol auto = protocol == 'auto' if auto: protocol = 'http' self.nms = jsonrpc.NexentaJSONProxy( '%s://%s:%s/rest/nms/' % (protocol, self.configuration.san_ip, self.configuration.nexenta_rest_port), self.configuration.san_login, self.configuration.san_password, auto=auto)
def _get_nms_for_url(self, nms_url): pr = urlparse.urlparse(nms_url) scheme = pr.scheme auto = scheme == 'auto' if auto: scheme = 'http' user = '******' password = '******' if '@' not in pr.netloc: host_and_port = pr.netloc else: user_and_password, host_and_port = pr.netloc.split('@', 1) if ':' in user_and_password: user, password = user_and_password.split(':') else: user = user_and_password if ':' in host_and_port: host, port = host_and_port.split(':', 1) else: host, port = host_and_port, '2000' url = '%s://%s:%s/rest/nms/' % (scheme, host, port) return jsonrpc.NexentaJSONProxy(url, user, password, auto=auto)