def run(self): debug("run start") ChallengeBase.run(self) if self.check() is False: self.usage() sys.exit(-1) log("Creating new DNS zone %s" % self.domain_name) self.domain=self.dns.create(name=self.domain_name, emailAddress="*****@*****.**", ttl=300, comment="challenge9 domain") log("Creating cloud server ...(please wait the build can take a while)") self.server=self.cs.servers.create(name=self.fqdn_name, flavor=self.flavor_id, image=self.image_id) wait = WaitingForTask(self.check_cs_build, self.server) if wait.wait_for_tasks() == False: log("Cloud server build failed, deleting created objects") self.server.delete() self.domain.delete() sys.exit(-1) # get all public IPs net = [ i["addr"] for i in self.server.addresses["public"] ] self.net = utils.get_ipv4net(net) cname_rec = {"type": "A", "name": self.fqdn_name, "data": self.net, "ttl": 300, "comment": "challenge9 rec"} self.recs = self.domain.add_record(cname_rec) log("DNS zone %s has been udpated and a new A record created" % (self.domain_name)) log("rec A: %s -> %s" % (self.fqdn_name, self.net))
def wait_for_instance_build(self): debug("wait_for_instance_build start") wait = WaitingForTask(self.check_db_instance, [self.db_instance_name]) if wait.wait_for_tasks() == False: self.db_instance.delete() sys.exit()
def wait_for_lb_change(self): debug("wait_for_lb_change start") wait = WaitingForTask(self.check_lb, [self.lb_name], sleep_time=5, max_timeout=1) if wait.wait_for_tasks() == False: log("Aborting as the build of lb is taking too long; all created objects will be deleted") for s in self.servers : s.delete() self.lb.delete() sys.exit(-1)
def wait_for_storage_to_be_attached(self): debug("wait_for_storage_to_be_attached start") wait = WaitingForTask(self.check_storage, self.volumes, sleep_time=30, max_timeout=5) if wait.wait_for_tasks() == False: log("Aborting as the build of block images is taking too long") for s in self.servers : s.delete() for v in self.volumes : v.delete() self.lb.delete() sys.exit(-1)
def run(self): debug("run start") ChallengeBase.run(self) if self.check() is False: self.usage() sys.exit(-1) log("Building %d cloud servers" % self.cs_count) mycs=CloudServers(self.cs_count, "challenge7") self.servers = mycs.get_servers() log("Building and configuring lb ...") self.build_lb() wait = WaitingForTask(self.check_lb, [self.lb_name], sleep_time=5, max_timeout=1) if wait.wait_for_tasks() == False: log("Aborting as the build of lb is taking too long; created lb and cloud servers will be deleted") self.delete_all() sys.exit(-1) self.show()