def test_configure_new_cluster_8_1_1(self, fake_configure_new_8_1_cluster, fake_vSphereConsole, fake_sleep): """``configure_new_cluster`` executes the correct function for OneFS 8.1.1.x""" fake_logger = MagicMock() setup_onefs.configure_new_cluster(version='8.1.1.2', compliance=False, logger=fake_logger) called = fake_configure_new_8_1_cluster.call_count expected = 1 self.assertEqual(called, expected)
def test_configure_new_cluster(self, fake_vSphereConsole, fake_sleep): """``configure_new_cluster`` returns None""" fake_logger = MagicMock() output = setup_onefs.configure_new_cluster( version='8.1.1.1', logger=fake_logger, console_url='https://someHTMLconsole.com', cluster_name='mycluster', int_netmask='255.255.255.0', int_ip_low='8.6.7.5', int_ip_high='8.6.7.50', ext_netmask='255.255.255.0', ext_ip_low='3.0.9.2', ext_ip_high='3.0.9.20', gateway='3.0.9.1', dns_servers='1.1.1.1', encoding='utf-8', sc_zonename='myzone.foo.org', compliance=False, smartconnect_ip='3.0.9.21') expected = None self.assertEqual(output, expected)
def test_configure_new_cluster_compliance(self, fake_get_compliance_license, fake_vSphereConsole, fake_sleep): """``configure_new_cluster`` Obtains a license when compliance is True""" fake_logger = MagicMock() output = setup_onefs.configure_new_cluster( version='8.1.1.1', logger=fake_logger, console_url='https://someHTMLconsole.com', cluster_name='mycluster', int_netmask='255.255.255.0', int_ip_low='8.6.7.5', int_ip_high='8.6.7.50', ext_netmask='255.255.255.0', ext_ip_low='3.0.9.2', ext_ip_high='3.0.9.20', gateway='3.0.9.1', dns_servers='1.1.1.1', encoding='utf-8', sc_zonename='myzone.foo.org', compliance=True, smartconnect_ip='3.0.9.21') self.assertTrue(fake_get_compliance_license.called)
def config(self, cluster_name, name, username, version, int_netmask, int_ip_low, int_ip_high, ext_netmask, ext_ip_low, ext_ip_high, gateway, dns_servers, encoding, sc_zonename, smartconnect_ip, join_cluster, compliance, txn_id): """Turn a blank OneFS node into a usable device :Returns: Dictionary :param cluster_name: The name of the OneFS cluster :type cluster_name: String :param name: The name of the OneFS node :type name: String :param int_netmask: The subnet mask for the internal OneFS network :type int_netmask: String :param int_ip_low: The smallest IP to assign to an internal NIC :type int_ip_low: String (IPv4 address) :param int_ip_high: The largest IP to assign to an internal NIC :type int_ip_high: String (IPv4 address) :param ext_ip_low: The smallest IP to assign to an external/public NIC :type ext_ip_low: String (IPv4 address) :param ext_ip_high: The largest IP to assign to an external/public NIC :type ext_ip_high: String (IPv4 address) :param gateway: The IP address for the default gateway :type gateway: String (IPv4 address) :param dns_servers: A common separated list of IPs of the DNS servers to use :type dns_servers: String :param encoding: The filesystem encoding to use. :type encoding: String :param sc_zonename: The SmartConnect Zone name to use. Skipped if None. :type sc_zonename: String :param smartconnect_ip: The IPv4 address to use as the SIP :type smartconnect_ip: String (IPv4 address) :param join_cluster: Add the node to an existing cluster :type join_cluster: Boolean :param compliance: Set to True when creating a Compliance mode cluster :type compliance: Boolean :param txn_id: A unique string supplied by the client to track the call through logs :type txn_id: String """ logger = get_task_logger(txn_id=txn_id, task_id=self.request.id, loglevel=const.VLAB_ONEFS_LOG_LEVEL.upper()) resp = {'content': {}, 'error': None, 'params': {}} logger.info('Task starting') nodes = vmware.show_onefs(username) node = nodes.get(name, None) if not node: error = "No node named {} found".format(name) resp['error'] = error logger.error(error) return resp elif node['meta']['configured']: error = "Cannot configure a node that's already configured" resp['error'] = error logger.error(error) else: # Lets set it up! logger.info('Found node') console_url = node['console'] if join_cluster: logger.info('Joining node to cluster {}'.format(cluster_name)) setup_onefs.join_existing_cluster(console_url, cluster_name, compliance, logger) else: logger.info('Setting up new cluster named {}'.format(cluster_name)) setup_onefs.configure_new_cluster(version=version, console_url=console_url, cluster_name=cluster_name, int_netmask=int_netmask, int_ip_low=int_ip_low, int_ip_high=int_ip_high, ext_netmask=ext_netmask, ext_ip_low=ext_ip_low, ext_ip_high=ext_ip_high, gateway=gateway, dns_servers=dns_servers, encoding=encoding, sc_zonename=sc_zonename, smartconnect_ip=smartconnect_ip, compliance=compliance, logger=logger) node['meta']['configured'] = True vmware.update_meta(username, name, node['meta']) logger.info('Task complete') return resp