def touch_manifest(self, fmri, intent=None): """Touch a manifest. This operation does not return the manifest's content. The FMRI is given as fmri. An optional intent string may be supplied as intent.""" failures = tx.TransportFailures() pub_prefix = fmri.get_publisher() pub = self.__img.get_publisher(pub_prefix) mfst = fmri.get_url_path() retry_count = global_settings.PKG_CLIENT_MAX_TIMEOUT header = self.__build_header(intent=intent, uuid=self.__get_uuid(pub)) for d in self.__gen_origins(pub, retry_count): # If a transport exception occurs, # save it if it's retryable, otherwise # raise the error to a higher-level handler. try: d.touch_manifest(mfst, header) return except tx.TransportException, e: if e.retryable: failures.append(e) else: raise
def get_manifest(self, fmri, excludes=misc.EmptyI, intent=None): """Given a fmri, and optional excludes, return a manifest object.""" retry_count = global_settings.PKG_CLIENT_MAX_TIMEOUT failures = tx.TransportFailures() pub_prefix = fmri.get_publisher() pub = self.__img.get_publisher(pub_prefix) mfst = fmri.get_url_path() mcontent = None header = self.__build_header(intent=intent, uuid=self.__get_uuid(pub)) # If captive portal test hasn't been executed, run it # prior to this operation. self.captive_portal_test() for d in self.__gen_origins(pub, retry_count): repostats = self.stats[d.get_url()] try: resp = d.get_manifest(mfst, header) mcontent = resp.read() m = manifest.CachedManifest( fmri, self.__img.pkgdir, self.__img.cfg_cache.preferred_publisher, excludes, mcontent) return m except tx.TransportException, e: if e.retryable: failures.append(e) mcontent = None else: raise except MalformedActionError, e: repostats.record_error() te = tx.TransferContentException(d.get_url(), reason=str(e)) failures.append(te)
def test_11_htbui(self): """We can perform a series of HTTP requests against the BUI.""" fmris = self.pkgsend_bulk(self.dcs[1].get_repo_url(), self.new_pkg) self.depotconfig("") self.start_depot() fmri = pkg.fmri.PkgFmri(fmris[0]) esc_full_fmri = fmri.get_url_path() conf = {"prefix": "default", "esc_full_fmri": esc_full_fmri} # a series of BUI paths we should be able to access paths = [ "/", "/default/test1", "/default/en", "/default/en/index.shtml", "/default/en/catalog.shtml", "/default/p5i/0/new.p5i", "/default/info/0/%(esc_full_fmri)s", "/default/test1/info/0/%(esc_full_fmri)s", "/default/manifest/0/%(esc_full_fmri)s", "/default/en/search.shtml", "/noodles/test2/en/catalog.shtml", "/depot/default/en/search.shtml?token=pkg&action=Search" ] for p in paths: url_path = "%s%s" % (self.ac.url, p % conf) try: url_obj = urllib2.urlopen(url_path) self.assert_(url_obj.code == 200, "Failed to open %s: %s" % (url_path, url_obj.code)) except urllib2.HTTPError, e: self.debug("Failed to open %s: %s" % (url_path, e)) raise
def get_manifest(self, fmri, excludes=misc.EmptyI, intent=None): """Given a fmri, and optional excludes, return a manifest object.""" retry_count = global_settings.PKG_CLIENT_MAX_TIMEOUT failures = tx.TransportFailures() pub_prefix = fmri.get_publisher() pub = self.__img.get_publisher(pub_prefix) mfst = fmri.get_url_path() mcontent = None header = self.__build_header(intent=intent, uuid=self.__get_uuid(pub)) # If captive portal test hasn't been executed, run it # prior to this operation. self.captive_portal_test() for d in self.__gen_origins(pub, retry_count): repostats = self.stats[d.get_url()] try: resp = d.get_manifest(mfst, header) mcontent = resp.read() m = manifest.CachedManifest( fmri, self.__img.pkgdir, self.__img.cfg_cache.preferred_publisher, excludes, mcontent ) return m except tx.TransportException, e: if e.retryable: failures.append(e) mcontent = None else: raise except MalformedActionError, e: repostats.record_error() te = tx.TransferContentException(d.get_url(), reason=str(e)) failures.append(te)