def __init__(self, options): self.username = options["cloud_user_name"] self.apikey = options["cloud_api_key"] self.authenticated = False self.hostname = socket.gethostname() self.instance_id = options["instance_id"] self.region = options["region"] log.debug("Authenticating with Rackspace") log.debug("My hostname: %s" % (self.hostname)) self.rksp = RackspaceCtrl(self.username, self.apikey) self.authenticated = self.rksp.authenticate()
class Rackspace(object): def __init__(self, options): self.username = options["cloud_user_name"] self.apikey = options["cloud_api_key"] self.authenticated = False self.hostname = socket.gethostname() self.instance_id = options["instance_id"] self.region = options["cloud_region"] log.debug("Authenticating with Rackspace") log.debug("My hostname: %s" % (self.hostname)) self.rksp = RackspaceCtrl(self.username, self.apikey) self.authenticated = self.rksp.authenticate() def _find_my_instance(self): if self.authenticated == False: log.critical("Not authenticated against rackspace!!!!") for region in self.rksp.list_regions(): log.debug("Rackspace regions: %s" % (region)) log.debug("Checking region: %s" % (self.region)) self.rksp.set_region(self.region) for server in self.rksp.list_instances(): log.debug("Checking server: %s" % (server.name)) if server.id == self.instance_id: log.info("Found matching instance: %s" % (server.id)) log.info("Startup id: %s" % (self.instance_id)) return server def terminate(self): server = self._find_my_instance() log.warning("Sending termination") self.rksp.delete_instance(server)
class Rackspace(object): def __init__(self, options): self.username = options["cloud_user_name"] self.apikey = options["cloud_api_key"] self.authenticated = False self.hostname = socket.gethostname() self.instance_id = options["instance_id"] self.region = options["region"] log.debug("Authenticating with Rackspace") log.debug("My hostname: %s" % (self.hostname)) self.rksp = RackspaceCtrl(self.username, self.apikey) self.authenticated = self.rksp.authenticate() def _find_my_instance(self): if self.authenticated == False: log.critical("Not authenticated against rackspace!!!!") for region in self.rksp.list_regions(): log.debug("Rackspace regions: %s" % (region)) log.debug("Checking region: %s" % (self.region)) self.rksp.set_region(self.region) for server in self.rksp.list_instances(): log.debug("Checking server: %s" % (server.name)) if server.name.lower() == self.hostname.lower( ) and server.id == self.instance_id: log.info("Found matching instance: %s" % (server.id)) log.info("Startup id: %s" % (self.instance_id)) return server def terminate(self): server = self._find_my_instance() log.warning("Sending termination") self.rksp.delete_instance(server)
def __init__(self, options): self.username = options["cloud_user_name"] self.apikey = options["cloud_api_key"] self.authenticated = False self.hostname = socket.gethostname() self.instance_id = options["instance_id"] self.region = options["cloud_region"] log.debug("Authenticating with Rackspace") log.debug("My hostname: %s" % (self.hostname)) self.rksp = RackspaceCtrl(self.username, self.apikey) self.authenticated = self.rksp.authenticate()