def addnode(ctx, name, types, ip, ram, cpus, cluster): """ Create a new VM in the cluster being managed. Another cluster can be specified with "--cluster". :param name: New VM name """ switched = True if cluster else False if not cluster: cluster = ss.svars['cluster'] try: nodes.add_node(name, ip, ram, types, cpus, cluster=cluster) count = services.auto_install_node(name, cluster) except (ex.LoadError, ex.CreationError) as e: print_with_color(e.message, 'red') if e.type == 'NoConfFile': click.echo('Use "repair" to regenerate `jumbo_config`.') switched = False else: click.echo('Machine "{}" added to cluster "{}". {}' .format(name, cluster, '{} clients auto installed on "{}".' .format(count, name) if count else '')) finally: if switched: set_context(ctx, cluster)
def add_with_same_ip(self): print('Trying to create node 2...') nodes.add_node(name=self.m_name + '-2', ip='10.10.10.11', ram=2048, types=['master'], cpus=1, cluster=self.c_name)
def test_add_node_same_ip(self): print('Test add_node_same_ip') nodes.add_node(name=self.m_name, ip='10.10.10.11', ram=2048, types=['master'], cpus=1, cluster=self.c_name) print('Machine 1 created') self.assertRaises(ex.CreationError, self.add_with_same_ip)
def test_add_remove_node(self): print('Test add_remove_node') nodes.add_node(name=self.m_name, ip='10.10.10.11', ram=2048, types=['master'], cpus=1, cluster=self.c_name) print('Machine created') print('Deleting node...') nodes.remove_node(cluster=self.c_name, node=self.m_name) self.assertFalse( nodes.check_node(cluster=self.c_name, node=self.m_name))
def setUp(self): self.c_name = 'unittest' + ''.join( random.choices(string.ascii_letters + string.digits, k=5)) self.m_names = [ 'master', 'master', 'sidemaster_edge', 'worker', 'ldap' ] clusters.create_cluster(domain=None, cluster=self.c_name) print('\n\nCluster "%s" created' % self.c_name) for i, n in enumerate(self.m_names): nodes.add_node(name=n + str(i), ip='10.10.10.1%d' % (i + 1), ram=2048, types=n.split('_'), cpus=1, cluster=self.c_name) print('%d nodes created' % i)
def test_add_node(self): print('Test "add_node"') print('Creating node...') nodes.add_node(name=self.m_name, ip='10.10.10.11', ram=2048, types=['master'], cpus=1, cluster=self.c_name) test01 = { 'name': self.m_name, 'ip': '10.10.10.11', 'ram': 2048, 'types': ['master'], 'cpus': 1, 'components': [], 'groups': [] } all_nodes = ss.svars['nodes'] node = [m for m in all_nodes if m['name'] == self.m_name][0] self.assertEqual(node, test01)