|
23 | 23 | from .annotationhelper import _get_annotations, _set_annotations |
24 | 24 | from .bundle import BundleHandler, get_charm_series, is_local_charm |
25 | 25 | from .charmhub import CharmHub |
26 | | -from .charmstore import CharmStore |
27 | 26 | from .client import client, connector |
28 | 27 | from .client.overrides import Caveat, Macaroon |
29 | 28 | from .constraints import parse as parse_constraints |
@@ -484,52 +483,6 @@ async def resolve(self, url, architecture, app_name=None, channel=None, series=N |
484 | 483 | is_bundle=is_bundle, |
485 | 484 | ) |
486 | 485 |
|
487 | | - |
488 | | -class CharmStoreDeployType: |
489 | | - """CharmStoreDeployType defines a class for resolving and deploying charm |
490 | | - store charms and bundle. |
491 | | - """ |
492 | | - |
493 | | - def __init__(self, charmstore, get_series): |
494 | | - self.charmstore = charmstore |
495 | | - self.get_series = get_series |
496 | | - |
497 | | - @staticmethod |
498 | | - def _default_app_name(meta): |
499 | | - suggested_name = meta.get('charm-metadata', {}).get('Name') |
500 | | - return suggested_name or meta.get('id', {}).get('Name') |
501 | | - |
502 | | - async def resolve(self, url, architecture, app_name=None, channel=None, series=None, entity_url=None): |
503 | | - """resolve attempts to resolve charmstore charms or bundles. A request |
504 | | - to the charmstore is required to get more information about the |
505 | | - underlying identifier. |
506 | | - """ |
507 | | - |
508 | | - result = await self.charmstore.entity(str(url), |
509 | | - channel=channel, |
510 | | - include_stats=False) |
511 | | - |
512 | | - identifier = result['Id'] |
513 | | - is_bundle = url.series == "bundle" or url.parse(identifier).series == "bundle" |
514 | | - if not series: |
515 | | - series = "bundle" if is_bundle else self.get_series(entity_url, result) |
516 | | - |
517 | | - if app_name is None and not is_bundle: |
518 | | - app_name = self._default_app_name(result['Meta']) |
519 | | - |
520 | | - origin = client.CharmOrigin(source="charm-store", |
521 | | - architecture=architecture, |
522 | | - risk=channel, |
523 | | - series=series) |
524 | | - |
525 | | - return DeployTypeResult( |
526 | | - identifier=identifier, |
527 | | - app_name=app_name, |
528 | | - origin=origin, |
529 | | - is_bundle=is_bundle, |
530 | | - ) |
531 | | - |
532 | | - |
533 | 486 | class CharmhubDeployType: |
534 | 487 | """CharmhubDeployType defines a class for resolving and deploying charmhub |
535 | 488 | charms and bundles. |
@@ -618,11 +571,9 @@ def __init__( |
618 | 571 | self._watch_stopped.set() |
619 | 572 |
|
620 | 573 | self._charmhub = CharmHub(self) |
621 | | - self._charmstore = CharmStore() |
622 | 574 |
|
623 | 575 | self.deploy_types = { |
624 | 576 | "local": LocalDeployType(), |
625 | | - "cs": CharmStoreDeployType(self._charmstore, self._get_series), |
626 | 577 | "ch": CharmhubDeployType(self._resolve_charm), |
627 | 578 | } |
628 | 579 |
|
@@ -1107,10 +1058,6 @@ def charmhub(self): |
1107 | 1058 | """ |
1108 | 1059 | return self._charmhub |
1109 | 1060 |
|
1110 | | - @property |
1111 | | - def charmstore(self): |
1112 | | - return self._charmstore |
1113 | | - |
1114 | 1061 | @property |
1115 | 1062 | def name(self): |
1116 | 1063 | """Return the name of this model |
@@ -1653,21 +1600,6 @@ async def debug_log( |
1653 | 1600 | } |
1654 | 1601 | await self.connect(debug_log_conn=target, debug_log_params=params) |
1655 | 1602 |
|
1656 | | - def _get_series(self, entity_url, entity): |
1657 | | - # try to get the series from the provided charm URL |
1658 | | - parts = entity_url.split('/') |
1659 | | - |
1660 | | - if len(parts) > 1: |
1661 | | - # series was specified in the URL |
1662 | | - return parts[0] |
1663 | | - # series was not supplied at all, so use the newest |
1664 | | - # supported series according to the charm store |
1665 | | - ss = entity['Meta'].get('supported-series') |
1666 | | - if not ss: |
1667 | | - log.error("Entity {} has no 'supported-series' in {}".format(entity_url, entity)) |
1668 | | - raise JujuError("Unable to determine series for {}".format(entity_url)) |
1669 | | - return ss['SupportedSeries'][0] |
1670 | | - |
1671 | 1603 | async def deploy( |
1672 | 1604 | self, entity_url, application_name=None, bind=None, |
1673 | 1605 | channel=None, config=None, constraints=None, force=False, |
@@ -1733,7 +1665,7 @@ async def deploy( |
1733 | 1665 | architecture = await self._resolve_architecture(url) |
1734 | 1666 |
|
1735 | 1667 | if str(url.schema) not in self.deploy_types: |
1736 | | - raise JujuError("unknown deploy type {}, expected charmhub, charmstore or local".format(url.schema)) |
| 1668 | + raise JujuError("unknown deploy type {}, expected charmhub or local".format(url.schema)) |
1737 | 1669 |
|
1738 | 1670 | res = await self.deploy_types[str(url.schema)].resolve(url, architecture, application_name, channel, series, entity_url) |
1739 | 1671 |
|
@@ -1782,9 +1714,6 @@ async def deploy( |
1782 | 1714 | raise JujuError("cannot use num_units with subordinate application") |
1783 | 1715 | num_units = 0 |
1784 | 1716 |
|
1785 | | - if Schema.CHARM_STORE.matches(url.schema): |
1786 | | - resources = await self._add_store_resources(res.app_name, |
1787 | | - identifier) |
1788 | 1717 | else: |
1789 | 1718 | # We have a local charm dir that needs to be uploaded |
1790 | 1719 | charm_dir = os.path.abspath(os.path.expanduser(identifier)) |
@@ -1869,18 +1798,11 @@ async def _resolve_charm(self, url, origin): |
1869 | 1798 | # origin should be set (including the base) before calling this, |
1870 | 1799 | # though all tests need to run (in earlier versions too) before |
1871 | 1800 | # committing to make sure there's no regression |
1872 | | - if Schema.CHARM_STORE.matches(url.schema): |
1873 | | - source = "charm-store" |
1874 | | - else: |
1875 | | - source = "charm-hub" |
| 1801 | + source = "charm-hub" |
1876 | 1802 |
|
1877 | | - resolve_origin = { |
1878 | | - 'source': source, |
1879 | | - 'architecture': origin.architecture, |
1880 | | - 'track': origin.track, |
1881 | | - 'risk': origin.risk, |
1882 | | - } |
1883 | | - resolve_origin['base'] = origin.base |
| 1803 | + resolve_origin = {'source': source, 'architecture': origin.architecture, |
| 1804 | + 'track': origin.track, 'risk': origin.risk, |
| 1805 | + 'base': origin.base} |
1884 | 1806 |
|
1885 | 1807 | resp = await charms_facade.ResolveCharms(resolve=[{ |
1886 | 1808 | 'reference': str(url), |
@@ -1951,48 +1873,6 @@ async def _add_charmhub_resources(self, application, |
1951 | 1873 |
|
1952 | 1874 | return resource_map |
1953 | 1875 |
|
1954 | | - async def _add_store_resources(self, application, entity_url, |
1955 | | - overrides=None): |
1956 | | - entity = await self.charmstore.entity(entity_url, |
1957 | | - include_stats=False) |
1958 | | - resources = [ |
1959 | | - { |
1960 | | - 'description': resource['Description'], |
1961 | | - 'fingerprint': resource['Fingerprint'], |
1962 | | - 'name': resource['Name'], |
1963 | | - 'path': resource['Path'], |
1964 | | - 'revision': resource['Revision'], |
1965 | | - 'size': resource['Size'], |
1966 | | - 'type_': resource['Type'], |
1967 | | - 'origin': 'store', |
1968 | | - } for resource in entity['Meta'].get('resources', []) |
1969 | | - ] |
1970 | | - |
1971 | | - if overrides: |
1972 | | - names = {r['name'] for r in resources} |
1973 | | - unknown = overrides.keys() - names |
1974 | | - if unknown: |
1975 | | - raise JujuError('Unrecognized resource{}: {}'.format( |
1976 | | - 's' if len(unknown) > 1 else '', |
1977 | | - ', '.join(unknown))) |
1978 | | - for resource in resources: |
1979 | | - if resource['name'] in overrides: |
1980 | | - resource['revision'] = overrides[resource['name']] |
1981 | | - |
1982 | | - if not resources: |
1983 | | - return None |
1984 | | - |
1985 | | - resources_facade = client.ResourcesFacade.from_connection( |
1986 | | - self.connection()) |
1987 | | - response = await resources_facade.AddPendingResources( |
1988 | | - application_tag=tag.application(application), |
1989 | | - charm_url=entity_url, |
1990 | | - resources=[client.CharmResource(**resource) for resource in resources]) |
1991 | | - resource_map = {resource['name']: pid |
1992 | | - for resource, pid |
1993 | | - in zip(resources, response.pending_ids)} |
1994 | | - return resource_map |
1995 | | - |
1996 | 1876 | async def add_local_resources(self, application, entity_url, metadata, resources): |
1997 | 1877 | if not resources: |
1998 | 1878 | return None |
|
0 commit comments