def setup(self): payload = AttrDict() payload.name = self.name payload.destination = self.destination payload.partition = self.partition payload.profiles = [] for profile_name in self.profiles: profile = AttrDict() profile.name = profile_name payload.profiles.append(profile) resp = self.rstifc.post(URL_TM_LTM_VIRTUAL, payload) return resp
def setup(self): payload = AttrDict() payload.name = self.name payload.destination = self.destination payload.partition = self.partition payload.profiles = [] for profile_name in self.profiles: profile = AttrDict() profile.name = profile_name payload.profiles.append(profile) try: resp = self.api.post(URL_TM_LTM_VIRTUAL, payload) except EmapiResourceError as e: if 'illegally shares destination address' in e.msg: ret = self.api.get(URL_TM_LTM_VIRTUAL) for item in ret["items"]: if item.destination.endswith(self.destination) \ and item.partition == self.partition: self.api.delete(item.selfLink) resp = self.api.post(URL_TM_LTM_VIRTUAL, payload) else: raise CommandError("Unexpected error: %s" % e.msg) return resp