smc-python icon indicating copy to clipboard operation
smc-python copied to clipboard

Object search in multi-domains context

Open sebbbastien opened this issue 6 years ago • 1 comments

Hi David,

I'm working on an SMC with domains. Some object are on the shared domain, others in domains.

When I'm connected to a specific domain, I can access to both domain objects and shared-domain objects, but I didn't found any solution to know when an object come from.

Objects are requested with Search.objects.filter function.

Do you have any idea to know to which domain an object come from, or how to filter search inside the current domain, ignoring shared?

Best regards,

Sébastien

sebbbastien avatar Jul 27 '19 21:07 sebbbastien

Ah this is a great question. If an element is in a specific (anything but Shared Domain), it will have an attribute 'admin_domain'. It looks like I need to add this to the base Element. I will do now, but in the meantime, here is an example:

Log in to specific domain and if the attribute exists, it's some domain other than Shared. If it doesn't then it's a Shared domain object:

session.login(url='http://172.18.1.26:8082', api_key='xxxxxxxxxx', domain=' newdomain')

for host in Search.objects.filter('testhost'):

if getattr(host, 'admin_domain', None):

    admin_domain = AdminDomain.from_href(host.admin_domain)

else:

    admin_domain = "Shared Domain"



print("Host: %s is in domain: %s" % (host, admin_domain))

I will add this attribute to the 0.7.0 develop branch and run some quick tests but the above will work!

David

On Sat, Jul 27, 2019 at 4:20 PM Sébastien [email protected] wrote:

Hi David,

I'm working on an SMC with domains. Some object are on the shared domain, others in domains.

When I'm connected to a specific domain, I can access to both domain objects and shared-domain objects, but I didn't found any solution to know when an object come from.

Objects are requested with Search.objects.filter function.

Do you have any idea to know to which domain an object come from, or how to filter search inside the current domain, ignoring shared? Best regards,

Sébastien

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gabstopper/smc-python/issues/66?email_source=notifications&email_token=ADRABVN3OX4T474LQLIEKJTQBS32DA5CNFSM4IHKWMB2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HB3YNSQ, or mute the thread https://github.com/notifications/unsubscribe-auth/ADRABVKKAUCODBJGFYO5K4TQBS32DANCNFSM4IHKWMBQ .

gabstopper avatar Aug 02 '19 02:08 gabstopper