[Lxc-users] How to start the network services so as to get the IP address using lxc-execute???
Brian K. White
brian at aljex.com
Thu Dec 8 21:32:52 UTC 2011
This isn't meant as an insult but you seem to be trying to do things
backwards and expecting, worse, demanding, a low level tool to contain
high level features that really should be provided by your own
scripting, or by other tools that already exist for that purpose.
If you want to assign container ip addresses in some particular order,
then simply do so. You can ensure container IP's get set whatever way
you want by any number of means. You can write a start script that
writes IP's into the container config files and/or rewrites them
dynamically every time it's started up, you can tell the containers to
use dhcp and you can control the dhcp server. If you want to read the
containers IP, you can get it from the hosts dhcp server state/log file
or possibly from the arp table on the host or by directly reading files
from the containers "filesystem".
Someone already gave you a good example of a simple bit of shell
scripting that takes the container name and uses that to produce the ip
address as long as the container names adhered to a consistent pattern.
If that's not what you wanted then what? Chronological order? That's
sort of meaningless since containers can be stopped and restarted.
If you want the ip's to be assigned chronologically, ie, the first
container to be started gets ip #1, that's trivial too, just write the
start script to keep count in a temp file every time it is started, or
have it parse the list of all running containers and add one to whatever
is the current highest number running before starting a new container.
But then this points out how meaningless this request is from the
beginning. What happens after containers have been stopped and
restarted? Do you want a restarted container to get a new next-highest
number? or remember it's original number? If you want it to get a new
number, then what happens when the always incrementing number gets to
the end of the netmask? If you want it to remember the number that it
got originally then what why not just write that number in it's config
file from the beginning? If you want it to reuse IP's dynamically from a
pool then that is already what a dhcp server does.
I really don't understand what you are trying to do or trying to avoid
doing or why, that isn't easily answered by a little shell scripting
and/or a dhcp server.
--
bkw
On 12/8/2011 7:59 AM, nishant mungse wrote:
>
> Hi Greg,
>
> Thanks 4 reply.
>
> I just want the IP addresses of the containers. And one more thing can I
> get the IP address of containers in sequence for eg. container1 ::
> 198.208.168.1 container 2 :: 198.208.168.2 and like this.
>
> Please help me ASAP.
>
> Regards,
> Nishant
>
> On Thu, Dec 8, 2011 at 5:09 PM, Greg Kurz <gkurz at fr.ibm.com
> <mailto:gkurz at fr.ibm.com>> wrote:
>
> On Thu, 2011-12-08 at 16:03 +0530, nishant mungse wrote:
> > Hi,
> >
> > I want to manually invoke a networking setup to start the network
> > service to get the IP address of container , But the problem is i
> > don't want to start the container and want to use lxc-execute.
> >
> > When I tried these things happened::
> >
> > command :: lxc-execute -n base
> > -f /home/nishant/ubuntu.conf
> /var/lib/lxc/base1/rootfs/etc/init.d/networking start
>
> Ok... this can't work. lxc-execute is for application containers only:
> it runs lxc-init instead of standard /sbin/init. The networking script
> you invoke needs upstart to be already running in the container... You
> seem to have a system container here, it _MUST_ be started with
> lxc-start.
>
> >
> > O/P
> >
> > Rather than invoking init scripts through /etc/init.d, use the
> > service(8)
> > utility, e.g. service networking start
> >
> > Since the script you are attempting to invoke has been converted
> to an
> > Upstart job, you may also use the start(8) utility, e.g. start
> > networking
> > start: Unable to connect to Upstart: Failed to connect to
> > socket /com/ubuntu/upstart: Connection refused
> >
> >
> > How to start the network services so as to get the IP addresses of
> > containers?
> >
>
> What's your true need here ? Controlling the containers network services
> from the host or just knowing the addresses used by the containers ? I
> guess both are doable in a variety of ways.
>
> Cheers.
>
> >
> > Regards,
> > Nishant
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Cloud Services Checklist: Pricing and Packaging Optimization
> > This white paper is intended to serve as a reference, checklist
> and point of
> > discussion for anyone considering optimizing the pricing and
> packaging model
> > of a cloud services business. Read Now!
> > http://www.accelacomm.com/jaw/sfnl/114/51491232/
> > _______________________________________________ Lxc-users mailing
> list Lxc-users at lists.sourceforge.net
> <mailto:Lxc-users at lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/lxc-users
>
> --
> Gregory Kurz gkurz at fr.ibm.com <mailto:gkurz at fr.ibm.com>
> Software Engineer @ IBM/Meiosys http://www.ibm.com
> Tel +33 (0)534 638 479 <tel:%2B33%20%280%29534%20638%20479>
> Fax +33 (0)561 400 420
> <tel:%2B33%20%280%29561%20400%20420>
>
> "Anarchy is about taking complete responsibility for yourself."
> Alan Moore.
>
>
>
>
> ------------------------------------------------------------------------------
> Cloud Services Checklist: Pricing and Packaging Optimization
> This white paper is intended to serve as a reference, checklist and point of
> discussion for anyone considering optimizing the pricing and packaging model
> of a cloud services business. Read Now!
> http://www.accelacomm.com/jaw/sfnl/114/51491232/
>
>
>
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users
More information about the lxc-users
mailing list