Example #1
0
    def test_get_domain_children(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        for d in ds[0].children.domain:
            assert d.name
            dom = factory.fetch_resource(self.space, d.get('href'))
            assert dom.name
            assert dom.id

            us = dom.users.get()
            for u in us:
                user = factory.fetch_resource(self.space, u.get('href'))
                assert user
    def test_get_domain_children(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        for d in ds[0].children.domain:
            assert d.name
            dom = factory.fetch_resource(self.space, d.get('href'))
            assert dom.name
            assert dom.id

            us = dom.users.get()
            for u in us:
                user = factory.fetch_resource(self.space, u.get('href'))
                assert user
    def test_add_user_to_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        usrs = self.space.user_management.users.get(filter_={'name': 'space_ez'})
        assert len(usrs) > 0

        user_to_move = factory.make_resource(type_name='domain_management.user_ref',
                                        rest_end_point=self.space)
        user_to_move.href = usrs[0].href

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Assign user to test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                dom.users.post(user_to_move)
    def test_remove_user_from_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Remove user from test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                usrs = dom.users.get()

                assert len(usrs) == 1

                import pytest
                with pytest.raises(rest.RestException) as except_info:
                    usrs[0].delete()

                assert except_info.value.response.status_code == 412
Example #5
0
    def test_remove_user_from_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Remove user from test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                usrs = dom.users.get()

                assert len(usrs) == 1

                import pytest
                with pytest.raises(rest.RestException) as except_info:
                    usrs[0].delete()

                assert except_info.value.response.status_code == 412
Example #6
0
    def test_add_user_to_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        usrs = self.space.user_management.users.get(
            filter_={'name': 'space_ez'})
        assert len(usrs) > 0

        user_to_move = factory.make_resource(
            type_name='domain_management.user_ref', rest_end_point=self.space)
        user_to_move.href = usrs[0].href

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Assign user to test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                dom.users.post(user_to_move)
    def test_add_devices_to_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        global_devices = self.space.device_management.devices.get(filter_={'domain-id': ds[0].id})
        assert len(global_devices) > 0

        device_to_move = factory.make_resource(type_name='domain_management.device_ref',
                                        rest_end_point=self.space)
        device_to_move.href = global_devices[0].href

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Move one device to test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                report = dom.devices.post(device_to_move)
                assert report.status

                """ Move the device back to global domain """
                report = ds[0].devices.post(device_to_move)
                assert report.status
def process_device(spc, device):
    """
    Process inventory collection for a given device.
    """
    try:
        d = device.get()
        print("Processing device: ", device.name)
        me_href = d['managed-elements']['managed-element'].get('href')
        me = factory.fetch_resource(spc, me_href)

        # Fetch Physical Termination Points
        ptps = me.ptps.get()
        for p in ptps:
            p.get()

        # Fetch equipment inventory
        ehs = me.equipment_holders.get()
        for eh in ehs:
            eh.get()

        # Fetch software inventory
        me.software_identities.get()

        # Fetch relevant configuration
        try:
            device.configurations.expanded.post(xpaths=[
                '/configuration/version', '/configuration/routing-instances',
                '/configuration/access/radius-server',
                '/configuration/system/domain-name',
                '/configuration/routing-options/router-id',
                '/configuration/interfaces/interface[name="lo0"]'
            ])
        except:
            pass

        return device.name
    except:
        raise Exception("Failed to process %s due to %s" %
                        (device.name, sys.exc_info()[1]))
def process_device(spc, device):
    """
    Process inventory collection for a given device.
    """
    try:
        d = device.get();
        print("Processing device: ", device.name)
        me_href = d['managed-elements']['managed-element'].get('href')
        me = factory.fetch_resource(spc, me_href)

        # Fetch Physical Termination Points
        ptps = me.ptps.get()
        for p in ptps:
            p.get()

        # Fetch equipment inventory
        ehs = me.equipment_holders.get()
        for eh in ehs:
            eh.get()

        # Fetch software inventory
        me.software_identities.get()

        # Fetch relevant configuration
        try:
            device.configurations.expanded.post(xpaths=[
                    '/configuration/version',
                    '/configuration/routing-instances',
                    '/configuration/access/radius-server',
                    '/configuration/system/domain-name',
                    '/configuration/routing-options/router-id',
                    '/configuration/interfaces/interface[name="lo0"]'])
        except:
            pass

        return device.name
    except:
        raise Exception("Failed to process %s due to %s" % (device.name, sys.exc_info()[1]))
Example #10
0
    def test_add_devices_to_domain(self):
        ds = self.space.domain_management.domains.get()
        assert len(ds) >= 1

        global_devices = self.space.device_management.devices.get(
            filter_={'domain-id': ds[0].id})
        assert len(global_devices) > 0

        device_to_move = factory.make_resource(
            type_name='domain_management.device_ref',
            rest_end_point=self.space)
        device_to_move.href = global_devices[0].href

        for d in ds[0].children.domain:
            assert d.name
            if d.name == 'test_domain':
                """ Move one device to test_domain """
                dom = factory.fetch_resource(self.space, d.get('href'))
                report = dom.devices.post(device_to_move)
                assert report.status
                """ Move the device back to global domain """
                report = ds[0].devices.post(device_to_move)
                assert report.status