Are there Python3 libraries for the net commands and etc?

Richard Sharpe realrichardsharpe at gmail.com
Mon Mar 28 19:44:46 UTC 2022


On Mon, Mar 28, 2022 at 12:44 PM John Mulligan
<phlogistonjohn at asynchrono.us> wrote:
>
> On Monday, March 28, 2022 12:11:18 PM EDT Jeremy Allison via samba-technical
> wrote:
> > On Sun, Mar 27, 2022 at 09:21:38AM -0700, Richard Sharpe via samba-technical
> wrote:
> > >Hi folks,
> > >
> > >A lot of system management scripts these days are implemented in
> > >Python and I am sick of using popen and system in python to run Samba
> > >commands and then grub through the output to figure out what I need.
> > >
> > >Are there any Python3 libraries that provide the functionality of the
> > >net commands?
> >
> > I don't think so. The only python SMB stuff I'm aware of is:
> >
> > https://pysmb.readthedocs.io/en/latest/
> >
> > I think only Samba does the management stuff. However,
> > most of our management stuff is drivable directly from
> > python, as that's how we do much of the testing.
> >
> > Talk to David Mulder from SuSE or some of the Catalyst
> > Team as they know much more about this than I.
>
>
> There's also https://github.com/hamano/pysmbc that I used in past projects. It
> uses libsmbclient, rather than being pure python.
>
> However, I do think Richard Sharpe meant management stuff. I am also very
> interested in doing less fork/exec/parse and make more use of samba library
> bindings for our `sambacc` project. Personally, I keep meaning to spend some
> time digging around in the samba-tool code. Since there's some overlap there
> with `net` around things like domain join, even for non-AD-DC servers, I think
> there *are* some existing libs to do a lot of these actions. However, the
> documentation is missing/not obvious. One of my big stumbling blocks when I
> see a package/api that seems to be something I want there's often a lack of
> clarity around how to make use of it due to stuff like undocumented arguments &
> some magic numeric constants, etc. However, its been some months since I last
> looked so things may have improved too... so take this with a grain of salt.
>
> There was also an effort to add JSON to some of the commands. If smbstatus and/
> or other commands had JSON output we don't have to do low-level parsing of
> output, even if we still need to fork/exec/read. My team was interested in
> this but we didn't have sufficient bandwidth to actively pursue it ourselves.
> However, a teammate alerted me to a new MR on the subject earlier today:
> https://gitlab.com/samba-team/samba/-/merge_requests/2449
>
> Anyway, I just wanted to reply to say that Richard isn't the only person
> interested in this kind of thing. :-)

To be more specific, here is what I am interested in:

A python (3) library that provides things like:

smb_mgmt_net_ads_join/smb_mgmt_net_ads_leave
smb_mgmt_net_ads_status
smb_mgmt_net_conf_list
smb_mgmt_net_conf_setparm

and every thing else :-)

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)(传说杜康是酒的发明者)



More information about the samba-technical mailing list