1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
'''
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__ = "pidge@toganlabs.com"
'''
from buildbot.steps.shell import ShellCommand
class DeleteGoogleVMs(ShellCommand):
haltOnFailure = True
flunkOnFailure = True
name = "Delete Google VMs"
def __init__(self, factory, argdict=None, **kwargs):
self.factory = factory
self.description = "Deleting Google VMs"
for k, v in argdict.iteritems():
if type(v) is bool:
setattr(self, k, str(v))
else:
setattr(self, k, v)
# Timeout needs to be passed to LoggingBuildStep as a kwarg
self.timeout = 1000
kwargs['timeout']=self.timeout
ShellCommand.__init__(self, **kwargs)
def start(self):
self.vmnames = self.getProperty("vmnames")
self.vmcount = self.getProperty("vmcount")
self.zone = self.getProperty("zone")
if self.vmnames is not None and self.vmnames != "":
self.command = "gcloud compute instances delete"
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"
self.command += " --quiet"
ShellCommand.start(self)
def describe(self, done=False):
description = ShellCommand.describe(self,done)
return description
|