def pod_delete(uuid): LOG.debug("pod_delete %s" % uuid) try: out, err = utils.trycmd('kubectl', 'delete', 'pod', uuid) if err: return False except Exception as e: LOG.error("Couldn't delete pod %s due to error %s" % (uuid, e)) return False return True
def rc_delete(self, master_address, name): LOG.debug("rc_delete %s" % name) try: out, err = utils.trycmd('kubectl', 'delete', 'rc', name, '-s', master_address) if err: return False except Exception as e: LOG.error("Couldn't delete rc %s due to error %s" % (name, e)) return False return True
def pod_create(contents): LOG.debug("pod_create contents %s" % contents) try: out, err = utils.trycmd('kubectl', 'create', '-f', contents) if err: return False except Exception as e: LOG.error("Couldn't create pod with contents %s due to error %s" % (contents, e)) return False return True
def service_delete(uuid): LOG.debug("service_delete %s" % uuid) try: out, err = utils.trycmd('kubectl', 'delete', 'service', uuid) if err: return False except Exception as e: LOG.error("Couldn't delete service %s due to error %s" % (uuid, e)) return False return False
def service_create(uuid, contents): LOG.debug("service_create %s contents %s" % (uuid, contents)) try: out, err = utils.trycmd('kubectl', 'create', '-f', contents) if err: return False except Exception as e: LOG.error("Couldn't create service with contents %s \ due to error %s" % (contents, e)) return False return True
def rc_delete(self, api_address, name): LOG.debug("rc_delete %s" % name) try: out, err = utils.trycmd('kubectl', 'delete', 'rc', name, '-s', api_address) if err: return False except Exception as e: LOG.error(_LE("Couldn't delete rc %(rc)s due to error %(error)s") % {'rc': name, 'error': e}) return False return True
def service_delete(self, api_address, name): LOG.debug("service_delete %s" % name) try: out, err = utils.trycmd('kubectl', 'delete', 'service', name, '-s', api_address) if err: return False except Exception as e: LOG.error(_LE("Couldn't delete service %(service)s due to error " "%(error)s") % {'service': name, 'error': e}) return False return True
def pod_delete(self, api_address, name): LOG.debug("pod_delete %s" % name) try: out, err = utils.trycmd('kubectl', 'delete', 'pod', name, '-s', api_address,) except Exception as e: LOG.error(_LE("Couldn't delete pod %(pod)s due to error " "%(error)s") % {'pod': name, 'error': e}) return False if err: if ('"%s" not found' % name) in err: raise exception.PodNotFound(pod=name) else: return False return True
def _k8s_update_with_path(api_address, resource_file): return utils.trycmd('kubectl', 'update', '-s', api_address, '-f', resource_file)
def _k8s_create_with_path(master_address, resource_file): return utils.trycmd('kubectl', 'create', '-s', master_address, '-f', resource_file)