|
12 | 12 | from toposort import toposort_flatten |
13 | 13 |
|
14 | 14 | from .client import client |
15 | | -from .constraints import parse as parse_constraints, parse_storage_constraint, parse_device_constraint |
| 15 | +from .constraints import parse as parse_constraints |
16 | 16 | from .errors import JujuError |
17 | 17 | from . import utils, jasyncio |
18 | 18 | from .origin import Channel, Source |
@@ -288,7 +288,7 @@ async def fetch_plan(self, bundle_url, origin, overlays=[]): |
288 | 288 | _yaml_data.append(yaml.dump(overlay).replace('null', '')) |
289 | 289 | yaml_data = "---\n".join(_yaml_data) |
290 | 290 |
|
291 | | - self.plan = await self.bundle_facade.GetChanges( |
| 291 | + self.plan = await self.bundle_facade.GetChangesMapArgs( |
292 | 292 | bundleurl=entity_id, |
293 | 293 | yaml=yaml_data) |
294 | 294 |
|
@@ -488,10 +488,12 @@ def sorted(self): |
488 | 488 | class ChangeInfo: |
489 | 489 | _toPy = {} |
490 | 490 |
|
491 | | - def __init__(self, change_id, requires): |
| 491 | + def __init__(self, change_id, requires, params=None): |
492 | 492 | self.change_id = change_id |
493 | 493 | self.requires = requires |
494 | 494 |
|
| 495 | + type(self).from_dict(self, params) |
| 496 | + |
495 | 497 | @classmethod |
496 | 498 | def from_dict(cls, self, data): |
497 | 499 | """from_dict converts a data bag into fields on a class instance. |
@@ -538,39 +540,6 @@ class AddApplicationChange(ChangeInfo): |
538 | 540 | :local_resources: identifies the path to the local resource of the |
539 | 541 | application's charm. |
540 | 542 | """ |
541 | | - |
542 | | - def __init__(self, change_id, requires, params=None): |
543 | | - super(AddApplicationChange, self).__init__(change_id, requires) |
544 | | - |
545 | | - if isinstance(params, list): |
546 | | - self.charm = params[0] |
547 | | - self.series = params[1] |
548 | | - self.application = params[2] |
549 | | - self.options = params[3] |
550 | | - self.constraints = params[4] |
551 | | - self.storage = {k: parse_storage_constraint(v) for k, v in params[5].items()} |
552 | | - self.channel = None |
553 | | - if len(params) == 8: |
554 | | - # Juju 2.4 and below only sends the endpoint bindings and resources |
555 | | - self.endpoint_bindings = params[6] |
556 | | - self.resources = params[7] |
557 | | - self.devices = None |
558 | | - self.num_units = None |
559 | | - else: |
560 | | - # Juju 2.5+ sends devices before endpoint bindings, as well as num_units |
561 | | - # There might be placement but we need to ignore that. |
562 | | - self.devices = {k: parse_device_constraint(v) for k, v in params[6].items()} |
563 | | - self.endpoint_bindings = params[7] |
564 | | - self.resources = params[8] |
565 | | - self.num_units = params[9] |
566 | | - if len(params) > 10: |
567 | | - self.channel = params[10] |
568 | | - |
569 | | - elif isinstance(params, dict): |
570 | | - AddApplicationChange.from_dict(self, params) |
571 | | - else: |
572 | | - raise Exception("unexpected params type") |
573 | | - |
574 | 543 | @staticmethod |
575 | 544 | def method(): |
576 | 545 | """method returns an associated ID for the Juju API call. |
@@ -685,26 +654,6 @@ class AddCharmChange(ChangeInfo): |
685 | 654 | not sufficient. |
686 | 655 | :channel: preferred channel for obtaining the charm. |
687 | 656 | """ |
688 | | - |
689 | | - def __init__(self, change_id, requires, params=None): |
690 | | - super(AddCharmChange, self).__init__(change_id, requires) |
691 | | - |
692 | | - if isinstance(params, list): |
693 | | - self.charm = params[0] |
694 | | - self.series = params[1] |
695 | | - if len(params) > 2 and params[2] != "": |
696 | | - self.channel = params[2] |
697 | | - else: |
698 | | - self.channel = None |
699 | | - if len(params) > 3 and params[3] != "": |
700 | | - self.architecture = params[3] |
701 | | - else: |
702 | | - self.architecture = None |
703 | | - elif isinstance(params, dict): |
704 | | - AddCharmChange.from_dict(self, params) |
705 | | - else: |
706 | | - raise Exception("unexpected params type") |
707 | | - |
708 | 657 | @staticmethod |
709 | 658 | def method(): |
710 | 659 | """method returns an associated ID for the Juju API call. |
@@ -787,21 +736,6 @@ class AddMachineChange(ChangeInfo): |
787 | 736 | "lxc" or kvm"). It is not specified for top level machines. |
788 | 737 | :parent_id: id of the parent machine. |
789 | 738 | """ |
790 | | - |
791 | | - def __init__(self, change_id, requires, params=None): |
792 | | - super(AddMachineChange, self).__init__(change_id, requires) |
793 | | - # this one is weird, as it returns a set of parameters inside a list. |
794 | | - if isinstance(params, list): |
795 | | - options = params[0] or {} |
796 | | - self.series = options.get("series") |
797 | | - self.constraints = options.get("constraints") |
798 | | - self.container_type = options.get("containerType") |
799 | | - self.parent_id = options.get("parentId") |
800 | | - elif isinstance(params, dict): |
801 | | - AddMachineChange.from_dict(self, params) |
802 | | - else: |
803 | | - raise Exception("unexpected params type") |
804 | | - |
805 | 739 | @staticmethod |
806 | 740 | def method(): |
807 | 741 | """method returns an associated ID for the Juju API call. |
@@ -879,18 +813,6 @@ class AddRelationChange(ChangeInfo): |
879 | 813 | application, and the interface is optional. Examples are |
880 | 814 | "$deploy-42:web", "$deploy-42", "mysql:db". |
881 | 815 | """ |
882 | | - |
883 | | - def __init__(self, change_id, requires, params=None): |
884 | | - super(AddRelationChange, self).__init__(change_id, requires) |
885 | | - |
886 | | - if isinstance(params, list): |
887 | | - self.endpoint1 = params[0] |
888 | | - self.endpoint2 = params[1] |
889 | | - elif isinstance(params, dict): |
890 | | - AddRelationChange.from_dict(self, params) |
891 | | - else: |
892 | | - raise Exception("unexpected params type") |
893 | | - |
894 | 816 | @staticmethod |
895 | 817 | def method(): |
896 | 818 | """method returns an associated ID for the Juju API call. |
@@ -941,18 +863,6 @@ class AddUnitChange(ChangeInfo): |
941 | 863 | :to: optional location where to add the unit, as a placeholder |
942 | 864 | pointing to another unit change or to a machine change. |
943 | 865 | """ |
944 | | - |
945 | | - def __init__(self, change_id, requires, params=None): |
946 | | - super(AddUnitChange, self).__init__(change_id, requires) |
947 | | - |
948 | | - if isinstance(params, list): |
949 | | - self.application = params[0] |
950 | | - self.to = params[1] |
951 | | - elif isinstance(params, dict): |
952 | | - AddUnitChange.from_dict(self, params) |
953 | | - else: |
954 | | - raise Exception("unexpected params type") |
955 | | - |
956 | 866 | @staticmethod |
957 | 867 | def method(): |
958 | 868 | """method returns an associated ID for the Juju API call. |
@@ -1010,19 +920,6 @@ class CreateOfferChange(ChangeInfo): |
1010 | 920 | offer. |
1011 | 921 | :offer_name: describes the offer name. |
1012 | 922 | """ |
1013 | | - |
1014 | | - def __init__(self, change_id, requires, params=None): |
1015 | | - super(CreateOfferChange, self).__init__(change_id, requires) |
1016 | | - |
1017 | | - if isinstance(params, list): |
1018 | | - self.application = params[0] |
1019 | | - self.endpoints = params[1] |
1020 | | - self.offer_name = params[2] |
1021 | | - elif isinstance(params, dict): |
1022 | | - CreateOfferChange.from_dict(self, params) |
1023 | | - else: |
1024 | | - raise Exception("unexpected params type") |
1025 | | - |
1026 | 923 | @staticmethod |
1027 | 924 | def method(): |
1028 | 925 | """method returns an associated ID for the Juju API call. |
@@ -1065,18 +962,6 @@ class ConsumeOfferChange(ChangeInfo): |
1065 | 962 | :url: contains the location of the offer |
1066 | 963 | :application_name: describes the application name on offer. |
1067 | 964 | """ |
1068 | | - |
1069 | | - def __init__(self, change_id, requires, params=None): |
1070 | | - super(ConsumeOfferChange, self).__init__(change_id, requires) |
1071 | | - |
1072 | | - if isinstance(params, list): |
1073 | | - self.url = params[0] |
1074 | | - self.application_name = params[1] |
1075 | | - elif isinstance(params, dict): |
1076 | | - ConsumeOfferChange.from_dict(self, params) |
1077 | | - else: |
1078 | | - raise Exception("unexpected params type") |
1079 | | - |
1080 | 965 | @staticmethod |
1081 | 966 | def method(): |
1082 | 967 | """method returns an associated ID for the Juju API call. |
@@ -1121,18 +1006,6 @@ class ExposeChange(ChangeInfo): |
1121 | 1006 | that should be able to access the port ranges that the application |
1122 | 1007 | has opened for each endpoint. |
1123 | 1008 | """ |
1124 | | - |
1125 | | - def __init__(self, change_id, requires, params=None): |
1126 | | - super(ExposeChange, self).__init__(change_id, requires) |
1127 | | - |
1128 | | - self.exposed_endpoints = None |
1129 | | - if isinstance(params, list): |
1130 | | - self.application = params[0] |
1131 | | - elif isinstance(params, dict): |
1132 | | - ExposeChange.from_dict(self, params) |
1133 | | - else: |
1134 | | - raise Exception("unexpected params type") |
1135 | | - |
1136 | 1009 | @staticmethod |
1137 | 1010 | def method(): |
1138 | 1011 | """method returns an associated ID for the Juju API call. |
@@ -1171,18 +1044,6 @@ class ScaleChange(ChangeInfo): |
1171 | 1044 | :application: placeholder name of the application to be scaled. |
1172 | 1045 | :scale: is the new scale value to use. |
1173 | 1046 | """ |
1174 | | - |
1175 | | - def __init__(self, change_id, requires, params=None): |
1176 | | - super(ScaleChange, self).__init__(change_id, requires) |
1177 | | - |
1178 | | - if isinstance(params, list): |
1179 | | - self.application = params[0] |
1180 | | - self.scale = params[1] |
1181 | | - elif isinstance(params, dict): |
1182 | | - ScaleChange.from_dict(self, params) |
1183 | | - else: |
1184 | | - raise Exception("unexpected params type") |
1185 | | - |
1186 | 1047 | @staticmethod |
1187 | 1048 | def method(): |
1188 | 1049 | """method returns an associated ID for the Juju API call. |
@@ -1224,19 +1085,6 @@ class SetAnnotationsChange(ChangeInfo): |
1224 | 1085 | :entity_type: type of the entity, "application" or "machine". |
1225 | 1086 | :ennotations: annotations as key/value pairs. |
1226 | 1087 | """ |
1227 | | - |
1228 | | - def __init__(self, change_id, requires, params=None): |
1229 | | - super(SetAnnotationsChange, self).__init__(change_id, requires) |
1230 | | - |
1231 | | - if isinstance(params, list): |
1232 | | - self.id = params[0] |
1233 | | - self.entity_type = params[1] |
1234 | | - self.annotations = params[2] |
1235 | | - elif isinstance(params, dict): |
1236 | | - SetAnnotationsChange.from_dict(self, params) |
1237 | | - else: |
1238 | | - raise Exception("unexpected params type") |
1239 | | - |
1240 | 1088 | @staticmethod |
1241 | 1089 | def method(): |
1242 | 1090 | """method returns an associated ID for the Juju API call. |
|
0 commit comments