def delete(self, params): """Delete role from fuel fuel role --delete --role controller --rel 1 """ Role.delete(params.release, params.role) self.file_serializer.print_to_output( {}, "Role with id {0} successfully deleted.".format(params.role))
def update(self, params): """Update a role from file description fuel role --rel 1 --update --file some.yaml """ role = self.file_serializer.read_from_file(params.file) role = Role.update(params.release, role['name'], role) self.file_serializer.print_to_output( role, "Role successfully updated from {0}.".format(params.file))
def item(self, params): """Save full role description to file fuel role --rel 1 --role controller --file some.yaml """ role = Role.get_one(params.release, params.role) self.file_serializer.write_to_file(params.file, role) self.file_serializer.print_to_output( role, "Role successfully saved to {0}.".format(params.file))
def list(self, params): """Print all available roles fuel role --rel 1 """ roles = Role.get_all(params.release) acceptable_keys = ("name", ) self.serializer.print_to_output( roles, format_table(roles, acceptable_keys=acceptable_keys))
def list(self, params): """Print all available roles fuel role --rel 1 """ roles = Role.get_all(params.release) acceptable_keys = ("name", ) self.serializer.print_to_output( roles, format_table( roles, acceptable_keys=acceptable_keys ) )
import sys from fuelclient.objects.release import Release from fuelclient.objects.role import Role incompatible_roles = ["compute", "ironic", "cinder", "cinder-block-device"] restrictions = {u"condition": u"'network:neutron:core:nsx' in cluster:components", u"action": u"hide"} role_available_state = "available" nsx_component_name = u"network:neutron:core:nsx" clean = True if (len(sys.argv) > 1) else False try: for release in Release.get_all_data(): if release["state"] == role_available_state: for role in Role.get_all(release["id"]): if role["name"] in incompatible_roles: meta = role["meta"] if "restrictions" in meta.keys(): for restriction in meta["restrictions"]: if nsx_component_name in restriction["condition"]: if len(meta["restrictions"]) == 1 and clean: del meta["restrictions"] else: meta["restrictions"].remove(restriction) if not clean: meta["restrictions"].append(restrictions) else: if not clean: meta["restrictions"] = [restrictions] Role.update(release["id"], role["name"], role)
from fuelclient.objects.release import Release from fuelclient.objects.role import Role incompatible_roles = ["compute", "ironic", "cinder", "cinder-block-device"] restrictions = { u"condition": u"'network:neutron:core:nsx' in cluster:components", u"action": u"hide" } role_available_state = "available" nsx_component_name = u"network:neutron:core:nsx" clean = True if (len(sys.argv) > 1) else False try: for release in Release.get_all_data(): if release["state"] == role_available_state: for role in Role.get_all(release["id"]): if role["name"] in incompatible_roles: meta = role["meta"] if "restrictions" in meta.keys(): for restriction in meta["restrictions"]: if nsx_component_name in restriction["condition"]: if len(meta["restrictions"]) == 1 and clean: del meta["restrictions"] else: meta["restrictions"].remove(restriction) if not clean: meta["restrictions"].append(restrictions) else: if not clean: meta["restrictions"] = [restrictions] Role.update(release["id"], role["name"], role)