def _update(self, argv): # First, get entity res = self._get_entity(argv) # Check if function exist if "_get_value_argument" in dir(self): value = self._get_value_argument(argv) if value != None and res.schema.multiline != True: # Update entity res.value = value res.update(self._config.options.force) res.show(as_json=self._config.options.raw) exit() cur_name = res.name # Prune entity fields (all may not be updatable) self._prune_json_update(res) updater = JsonUpdater(self._config.options) item = updater.update(res) # Check if name has changed if "name" in item: new_name = item["name"] if cur_name != new_name: res.rename(new_name) # Update entity res.set_json(item) res.update(self._config.options.force) res.show(as_json=self._config.options.raw)
def change(self, settings): settings_list = settings.list() updater = JsonUpdater(self._config.options) updated_list = updater.update(JsonWrapper([s.get_json() for s in settings_list])) updated_settings = [settings._new(data) for data in updated_list] actions = self._build_actions(settings_list, updated_settings) if len(actions) > 0: self._print_actions(actions) if self._config.options.force or (prompt.confirm(prompt = "Do you want to proceed?", resp = False)): settings.change(updated_settings, self._config.options.no_delete) else: print("No change detected, ignoring")
def _create_image(self, argv): image = Image() image.create_distribution = False host = self._client.get_host(argv[0], argv[1], argv[2]) platform = self._client.get_platform(argv[0], host.platform_name) image.settings = [ self._build_setting(param) for param in platform.image_parameters() ] updater = JsonUpdater(self._config.options, ignore_not_modified=True) updated_json = updater.update(image) image.set_json(updated_json) instance = self._get_entity(argv) instance.create_image(image)
def _update(self, argv): # First, get entity res = self._get_entity(argv) cur_name = res.name # Prune entity fields (all may not be updatable) self._prune_json_update(res) updater = JsonUpdater(self._config.options) item = updater.update(res) # Check if name has changed if "name" in item: new_name = item["name"] if cur_name != new_name: res.rename(new_name) # Update entity res.set_json(item) res.update(self._config.options.force) res.show(as_json=self._config.options.raw)