[yocto] [PATCH 01/13] buildsteps: Add ProvisionGoogleVM.py

California Sullivan californialsullivan at gmail.com
Tue Sep 23 10:35:42 PDT 2014


See https://bugzilla.yoctoproject.org/show_bug.cgi?id=5975

On Tue, Sep 23, 2014 at 10:13 AM, <californialsullivan at gmail.com> wrote:

> From: California Sullivan <california.l.sullivan at intel.com>
>
> This build step provisions a Google VM using the gcloud command line tool.
>
> Signed-off-by: California Sullivan <california.l.sullivan at intel.com>
> ---
>  .../autobuilder/buildsteps/ProvisionGoogleVM.py    | 85
> ++++++++++++++++++++++
>  1 file changed, 85 insertions(+)
>  create mode 100644
> lib/python2.7/site-packages/autobuilder/buildsteps/ProvisionGoogleVM.py
>
> diff --git
> a/lib/python2.7/site-packages/autobuilder/buildsteps/ProvisionGoogleVM.py
> b/lib/python2.7/site-packages/autobuilder/buildsteps/ProvisionGoogleVM.py
> new file mode 100644
> index 0000000..fb667dd
> --- /dev/null
> +++
> b/lib/python2.7/site-packages/autobuilder/buildsteps/ProvisionGoogleVM.py
> @@ -0,0 +1,85 @@
> +'''
> +Created on Aug 13, 2014
> +
> +__author__ = "California Sullivan"
> +__copyright__ = "Copyright 2014, Intel Corp."
> +__credits__ = ["California Sullivan"]
> +__license__ = "GPL"
> +__version__ = "2.0"
> +__maintainer__ = "Elizabeth Flanagan"
> +__email__ = "elizabeth.flanagan at intel.com"
> +'''
> +
> +from buildbot.steps.shell import ShellCommand
> +
> +class ProvisionGoogleVM(ShellCommand):
> +    haltOnFailure = True
> +    flunkOnFailure = True
> +    name = "Provision Google VM"
> +    def __init__(self, factory, argdict=None, **kwargs):
> +        self.vmname=None
> +        self.vmcount=1
> +        self.startupscript=None
> +        self.metadata=None
> +        self.zone="us-central1-a"
> +        self.image=None
> +        self.machine=None
> +        self.network=None
> +        self.disksize=None
> +        self.factory = factory
> +        self.description = "Provision Google VM"
> +        for k, v in argdict.iteritems():
> +            if type(v) is bool:
> +                setattr(self, k, str(v))
> +            else:
> +                setattr(self, k, v)
> +
> +        if self.vmname is None or self.vmname == "":
> +            self.finished(FAILURE)
> +        else:
> +            self.command = "gcloud compute instances create"
> +            self.vmnames = ""
> +            for x in range(0, self.vmcount):
> +                self.vmnames += " " + self.vmname + "-" + str(x)
> +            self.command += self.vmnames
> +            if self.zone is not None and self.zone in ["us-central1-a",
> "us-central1-b", "us-central1-f", "europe-west1-a", "europe-west1-b",
> "asia-east1-a", "asia-east1-b", "asia-east1-b"]:
> +                self.command += " --zone " + self.zone
> +            else:
> +                self.command += " --zone us-central1-a"
> +            if self.disksize is not None and self.disksize != "":
> +                self.command += " --boot-disk-size " + self.disksize
> +            else:
> +                self.command += " --boot-disk-size 200GB"
> +            if self.image is None:
> +                self.command += " --image debian-7"
> +            else:
> +                self.command += " --image " + self.image
> +
> +            if self.machine is not None and self.machine in ["g1-small",
> "f1-micro", "n1-standard-1", "n1-standard-2", "n1-standard-4",
> "n1-standard-8", "n1-standard-16", "n1-highmem-2", "n1-highmem-4"]:
> +                self.command += " --machine-type " + self.machine
> +            else:
> +                self.command += " --machine-type n1-standard-1"
> +            if self.network is not None and self.network != "":
> +                self.command += " --network " + self.network
> +            if self.startupscript is not None and self.startupscript !=
> "":
> +                self.command += " --metadata-from-file startup-script=" +
> self.startupscript
> +                if self.metadata is not None and self.metadata != "":
> +                    self.command += " --metadata " + self.scriptargs
> +            self.command += " 1> /dev/null";
> +
> +            # Timeout needs to be passed to LoggingBuildStep as a kwarg
> +            self.timeout = 1000
> +            kwargs['timeout']=self.timeout
> +            ShellCommand.__init__(self, **kwargs)
> +
> +    def describe(self, done=False):
> +        description = ShellCommand.describe(self,done)
> +        return description
> +
> +    def commandComplete(self, cmd):
> +        if not cmd.didFail():
> +            self.setProperty("vmnames", self.vmnames)
> +            self.setProperty("zone", self.zone)
> +            self.setProperty("vmcount", self.vmcount)
> +
> +
> --
> 1.9.1
>
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20140923/ec669263/attachment.html>


More information about the yocto mailing list