def test_create_save_and_delete(self): """ Check that when you create a new group type that it is added """ host_group_type = HostGroupType.create(self.profiler, "TestType4057") host_group_type.save() HostGroupType.find_by_name(self.profiler, "TestType4057") host_group_type.delete() self.assertIsNone(host_group_type.id)
def test_create_save_and_delete(self): """ Check that when you create a new group type that it is added """ host_group_type = HostGroupType.create(self.profiler, "TestType4057") host_group_type.save() HostGroupType.find_by_name(self.profiler, "TestType4057") host_group_type.delete() self.assertIsNone(host_group_type.id)
def update_hostgroups(self, groups): """Replace existing HostGroupType with contents of groups dict.""" # First find any existing HostGroupType try: hgtype = HostGroupType.find_by_name(self.netprofiler, self.options.hostgroup) hgtype.config = [] hgtype.groups = {} print('Existing HostGroupType "{0}" found.' ''.format(self.options.hostgroup)) except RvbdException: print('No existing HostGroupType found, creating a new one.') hgtype = HostGroupType.create(self.netprofiler, self.options.hostgroup) # Add new values for group, cidrs in groups.items(): hg = HostGroup(hgtype, group) hg.add(cidrs) # Save to NetProfiler hgtype.save() print('HostGroupType "%s" configuration saved.' % self.options.hostgroup)
def update_hostgroups(self, groups): """Replace existing HostGroupType with contents of groups dict.""" # First find any existing HostGroupType try: hgtype = HostGroupType.find_by_name(self.netprofiler, self.options.hostgroup) hgtype.config = [] hgtype.groups = {} print('Existing HostGroupType "{0}" found.' ''.format(self.options.hostgroup)) except RvbdException: print('No existing HostGroupType found, creating a new one.') hgtype = HostGroupType.create(self.netprofiler, self.options.hostgroup) # Add new values for group, cidrs in groups.items(): hg = HostGroup(hgtype, group) hg.add(cidrs) # Save to NetProfiler hgtype.save() print ('HostGroupType "%s" configuration saved.' % self.options.hostgroup)
def setUp(self): try: # TestType4057 is reserved for these tests. 4057 has no significance # If we can find that host group for some reason in the netprofiler # then we must delete it before starting any of our tests. old_host_group_type = HostGroupType.find_by_name(self.profiler, 'TestType4057') old_host_group_type.delete() except RvbdException: return
def setUp(self): try: # TestType4057 is reserved for these tests. 4057 has no significance # If we can find that host group for some reason in the netprofiler # then we must delete it before starting any of our tests. old_host_group_type = HostGroupType.find_by_name( self.profiler, 'TestType4057') old_host_group_type.delete() except RvbdException: return
def netprofiler_hostgroups(form, id, field_kwargs, params): """ Query netprofiler for groups within a given hostgroup. """ netprofiler_device = form.get_field_value('netprofiler_device', id) if netprofiler_device == '': choices = [('', '<No netprofiler device>')] else: netprofiler = DeviceManager.get_device(netprofiler_device) if params is not None and 'hostgroup_type' in params: hgt = HostGroupType.find_by_name(netprofiler, params['hostgroup_type']) else: hostgroup_type = form.get_field_value('hostgroup_type', id) hgt = HostGroupType.find_by_name(netprofiler, hostgroup_type) choices = [(group, group) for group in hgt.groups.keys()] field_kwargs['label'] = 'HostGroup' field_kwargs['choices'] = choices
def netprofiler_hostgroups(form, id, field_kwargs, params): """ Query netprofiler for groups within a given hostgroup. """ netprofiler_device = form.get_field_value('netprofiler_device', id) if netprofiler_device == '': choices = [('', '<No netprofiler device>')] else: netprofiler = DeviceManager.get_device(netprofiler_device) if params is not None and 'hostgroup_type' in params: hgt = HostGroupType.find_by_name(netprofiler, params['hostgroup_type']) else: hostgroup_type = form.get_field_value('hostgroup_type', id) hgt = HostGroupType.find_by_name(netprofiler, hostgroup_type) choices = [(group, group) for group in hgt.groups.keys()] field_kwargs['label'] = 'HostGroup' field_kwargs['choices'] = choices
def test_find_by_name(self): """ Check that it finds ByLocation as a HostGroupType """ host_group_type = HostGroupType.find_by_name(self.profiler, "ByLocation") self.assertEqual(host_group_type.name, "ByLocation")
def test_find_by_name(self): """ Check that it finds ByLocation as a HostGroupType """ host_group_type = HostGroupType.find_by_name(self.profiler, "ByLocation") self.assertEqual(host_group_type.name, "ByLocation")