cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Zhang <Frank.Zh...@citrix.com>
Subject RE: git commit: refs/heads/4.1 - CloudStack CLOUDSTACK-774 Supporting kickstart in CloudStack baremetal
Date Sat, 02 Mar 2013 00:22:15 GMT
Oh, I am sorry. I forgot the last day of Feb is 28 ... didn't notice today is 3/1

> -----Original Message-----
> From: David Nalley [mailto:david@gnsa.us]
> Sent: Friday, March 01, 2013 3:10 PM
> To: cloudstack-dev@incubator.apache.org
> Cc: cloudstack-commits@incubator.apache.org
> Subject: Re: git commit: refs/heads/4.1 - CloudStack CLOUDSTACK-774
> Supporting kickstart in CloudStack baremetal
> 
> Why did this hit 4.1?
> 
> 
> 
> On Fri, Mar 1, 2013 at 6:04 PM,  <frankzhang@apache.org> wrote:
> > Updated Branches:
> >   refs/heads/4.1 a47f32343 -> 75aad6763
> >
> >
> > CloudStack CLOUDSTACK-774
> > Supporting kickstart in CloudStack baremetal
> >
> > make kikcstart working with ubuntu
> >
> >
> > Project:
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
> > Commit:
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/75a
> > ad676
> > Tree:
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/75aad
> > 676
> > Diff:
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/75aad
> > 676
> >
> > Branch: refs/heads/4.1
> > Commit: 75aad6763b57ab2ebbe79101888368a3bd8f4185
> > Parents: a47f323
> > Author: Frank Zhang <Frank.Zhang@citrix.com>
> > Authored: Fri Mar 1 15:03:10 2013 -0800
> > Committer: Frank Zhang <Frank.Zhang@citrix.com>
> > Committed: Fri Mar 1 15:03:33 2013 -0800
> >
> > ----------------------------------------------------------------------
> >  .../BaremetalKickStartPxeResource.java             |    2 +-
> >  .../BaremetalKickStartServiceImpl.java             |   33 ++++++++-
> >  .../PrepareKickstartPxeServerCommand.java          |   31 +++++---
> >  .../ping/prepare_kickstart_kernel_initrd.py        |   55 ++++++++-------
> >  4 files changed, 80 insertions(+), 41 deletions(-)
> > ----------------------------------------------------------------------
> >
> >
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/75aad
> >
> 676/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservi
> > ce/BaremetalKickStartPxeResource.java
> > ----------------------------------------------------------------------
> > diff --git
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartPxeResource.java
> >
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartPxeResource.java
> > index 2b9b140..58c6e86 100755
> > ---
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartPxeResource.java
> > +++
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkser
> > +++ vice/BaremetalKickStartPxeResource.java
> > @@ -175,7 +175,7 @@ public class BaremetalKickStartPxeResource
> extends BaremetalPxeResourceBase {
> >              }
> >
> >              String copyTo = String.format("%s/%s", _tftpDir,
> cmd.getTemplateUuid());
> > -            String script = String.format("python
> /usr/bin/prepare_kickstart_kernel_initrd.py %s %s", cmd.getRepo(),
> copyTo);
> > +            String script = String.format("python
> > + /usr/bin/prepare_kickstart_kernel_initrd.py %s %s %s",
> > + cmd.getKernel(), cmd.getInitrd(), copyTo);
> >
> >              if (!SSHCmdHelper.sshExecuteCmd(sshConnection, script)) {
> >                  return new Answer(cmd, false, "prepare kickstart at
> > pxe server " + _ip + " failed, command:" + script);
> >
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/75aad
> >
> 676/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservi
> > ce/BaremetalKickStartServiceImpl.java
> > ----------------------------------------------------------------------
> > diff --git
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartServiceImpl.java
> >
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartServiceImpl.java
> > index ba5fb0d..8a5ac78 100755
> > ---
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /BaremetalKickStartServiceImpl.java
> > +++
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkser
> > +++ vice/BaremetalKickStartServiceImpl.java
> > @@ -95,11 +95,36 @@ public class BaremetalKickStartServiceImpl extends
> BareMetalPxeServiceBase imple
> >          try {
> >              String tpl = profile.getTemplate().getUrl();
> >              assert tpl != null : "How can a null template get here!!!";
> > -            String[] tpls = tpl.split(";");
> > -            assert tpls.length == 2 : "Template is not correctly encoded. " + tpl;
> > +            String[] tpls = tpl.split(";");
> > +            CloudRuntimeException err = new
> CloudRuntimeException(String.format("template url[%s] is not correctly
> encoded. it must be in format of
> ks=http_link_to_kickstartfile;kernel=nfs_path_to_pxe_kernel;initrd=nfs_pa
> th_to_pxe_initrd", tpl));
> > +            if (tpls.length != 3) {
> > +                throw err;
> > +            }
> > +
> > +            String ks = null;
> > +            String kernel = null;
> > +            String initrd = null;
> > +
> > +            for (String t : tpls) {
> > +                String[] kv = t.split("=");
> > +                if (kv.length != 2) {
> > +                    throw err;
> > +                }
> > +                if (kv[0].equals("ks")) {
> > +                    ks = kv[1];
> > +                } else if (kv[0].equals("kernel")) {
> > +                    kernel = kv[1];
> > +                } else if (kv[0].equals("initrd")) {
> > +                    initrd = kv[1];
> > +                } else {
> > +                    throw err;
> > +                }
> > +            }
> > +
> >              PrepareKickstartPxeServerCommand cmd = new
> PrepareKickstartPxeServerCommand();
> > -            cmd.setKsFile(tpls[0]);
> > -            cmd.setRepo(tpls[1]);
> > +            cmd.setKsFile(ks);
> > +            cmd.setInitrd(initrd);
> > +            cmd.setKernel(kernel);
> >              cmd.setMac(nic.getMacAddress());
> >              cmd.setTemplateUuid(template.getUuid());
> >              Answer aws = _agentMgr.send(pxeVo.getHostId(), cmd);
> >
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/75aad
> >
> 676/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservi
> > ce/PrepareKickstartPxeServerCommand.java
> > ----------------------------------------------------------------------
> > diff --git
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /PrepareKickstartPxeServerCommand.java
> >
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /PrepareKickstartPxeServerCommand.java
> > index 8951547..25dfeb7 100755
> > ---
> >
> a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice
> > /PrepareKickstartPxeServerCommand.java
> > +++
> b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkser
> > +++ vice/PrepareKickstartPxeServerCommand.java
> > @@ -22,10 +22,11 @@ import com.cloud.agent.api.Command;
> >
> >  public class PrepareKickstartPxeServerCommand extends Command {
> >      private String ksFile;
> > -    private String repo;
> >      private String templateUuid;
> >      private String mac;
> > -    private String ksDevice;
> > +    private String ksDevice;
> > +    private String kernel;
> > +    private String initrd;
> >
> >      @Override
> >      public boolean executeInSequence() { @@ -39,15 +40,23 @@ public
> > class PrepareKickstartPxeServerCommand extends Command {
> >      public void setKsFile(String ksFile) {
> >          this.ksFile = ksFile;
> >      }
> > -
> > -    public String getRepo() {
> > -        return repo;
> > -    }
> > -
> > -    public void setRepo(String repo) {
> > -        this.repo = repo;
> > -    }
> > -
> > +
> > +    public String getKernel() {
> > +        return kernel;
> > +    }
> > +
> > +    public void setKernel(String kernel) {
> > +        this.kernel = kernel;
> > +    }
> > +
> > +    public String getInitrd() {
> > +        return initrd;
> > +    }
> > +
> > +    public void setInitrd(String initrd) {
> > +        this.initrd = initrd;
> > +    }
> > +
> >      public String getTemplateUuid() {
> >          return templateUuid;
> >      }
> >
> > http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/75aad
> > 676/scripts/network/ping/prepare_kickstart_kernel_initrd.py
> > ----------------------------------------------------------------------
> > diff --git a/scripts/network/ping/prepare_kickstart_kernel_initrd.py
> > b/scripts/network/ping/prepare_kickstart_kernel_initrd.py
> > index b234a62..ff61848 100755
> > --- a/scripts/network/ping/prepare_kickstart_kernel_initrd.py
> > +++ b/scripts/network/ping/prepare_kickstart_kernel_initrd.py
> > @@ -21,50 +21,55 @@ import tempfile
> >  import os.path
> >  import os
> >
> > -iso_folder = ''
> > -copy_to = ''
> > +kernel = None
> > +initrd = None
> > +copy_to = None
> >
> >  def cmd(cmdstr, err=True):
> > +    print cmdstr
> >      if os.system(cmdstr) != 0 and err:
> >          raise Exception("Failed to run shell command: %s" % cmdstr)
> >
> >  def prepare():
> > +    global kernel, initrd, copy_to
> >      try:
> > -        kernel = os.path.join(copy_to, "vmlinuz")
> > -        initrd = os.path.join(copy_to, "initrd.img")
> > -        if os.path.exists(kernel) and os.path.exists(initrd):
> > +        k = os.path.join(copy_to, "vmlinuz")
> > +        i = os.path.join(copy_to, "initrd.img")
> > +        if os.path.exists(k) and os.path.exists(i):
> >              print "Having template(%s) prepared already, skip copying" %
> copy_to
> >              return 0
> >          else:
> >              if not os.path.exists(copy_to):
> >                  os.makedirs(copy_to)
> >
> > -        mnt_path = tempfile.mkdtemp()
> > -        try:
> > -            mnt = "mount %s %s" % (iso_folder, mnt_path)
> > -            cmd(mnt)
> > -
> > -            kernel = os.path.join(mnt_path, "vmlinuz")
> > -            initrd = os.path.join(mnt_path, "initrd.img")
> > -            cp = "cp -f %s %s/" % (kernel, copy_to)
> > -            cmd(cp)
> > -            cp = "cp -f %s %s/" % (initrd, copy_to)
> > -            cmd(cp)
> > -        finally:
> > -            umnt = "umount %s" % mnt_path
> > -            cmd(umnt, False)
> > -            rm = "rm -r %s" % mnt_path
> > -            cmd(rm, False)
> > -        return 0
> > +
> > +        def copy_from_nfs(src, dst):
> > +            mnt_path = tempfile.mkdtemp()
> > +            try:
> > +                nfs_path = os.path.dirname(src)
> > +                filename = os.path.basename(src)
> > +                t = os.path.join(mnt_path, filename)
> > +                mnt = "mount %s %s" % (nfs_path, mnt_path)
> > +                cmd(mnt)
> > +                cp = "cp -f %s %s" % (t, dst)
> > +                cmd(cp)
> > +            finally:
> > +                umnt = "umount %s" % mnt_path
> > +                cmd(umnt, False)
> > +                rm = "rm -r %s" % mnt_path
> > +                cmd(rm, False)
> > +
> > +        copy_from_nfs(kernel, copy_to)
> > +        copy_from_nfs(initrd, copy_to)
> >      except Exception, e:
> >          print e
> >          return 1
> >
> >  if __name__ == "__main__":
> > -    if len(sys.argv) < 3:
> > -        print "Usage: prepare_kickstart_kerneal_initrd.py
> path_to_kernel_initrd_iso path_kernel_initrd_copy_to"
> > +    if len(sys.argv) < 4:
> > +        print "Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel
> path_to_initrd path_kernel_initrd_copy_to"
> >         sys.exit(1)
> >
> > -    (iso_folder, copy_to) = sys.argv[1:]
> > +    (kernel, initrd, copy_to) = sys.argv[1:]
> >      sys.exit(prepare())
> >
> >

Mime
View raw message