class RemoveDefaultSystemInfo(OrganizationAction): description = _("remove default custom info keynames for systems") def __init__(self): super(RemoveDefaultSystemInfo, self).__init__() self.system_info_keys_api = OrganizationSystemInfoKeysAPI() def setup_parser(self, parser): parser.add_option('--name', dest='name', help=_("organization name eg: foo.example.com (required)")) parser.add_option('--keyname', dest='keyname', help=_("name of the default custom info")) def check_options(self, validator): validator.require(('name', 'keyname')) def run(self): org_name = self.get_option('name') keyname = self.get_option('keyname') response = self.system_info_keys_api.destroy(org_name, keyname) if not keyname in response: print _("Successfully removed default custom info key [ %s ] for Org [ %s ]") % (keyname, org_name) else: print _("Could not remove default custom info key [ %s ] for Org [ %s ]") % (keyname, org_name)
class ApplyDefaultSystemInfo(OrganizationAction): description = _("apply default custom info keynames to all existing systems") def __init__(self): super(ApplyDefaultSystemInfo, self).__init__() self.system_info_keys_api = OrganizationSystemInfoKeysAPI() def setup_parser(self, parser): parser.add_option("--name", dest='name', help=_("organization name eg: foo.example.com (required)")) def check_options(self, validator): validator.require('name') def run(self): org_name = self.get_option('name') response = self.system_info_keys_api.apply(org_name) if response: print _("Successfully applied default custom info keys to [ %d ] systems in Org [ %s ]")\ % (len(response), org_name) elif len(response) == 0: print _("No default custom info keys to apply in Org [ %s ]") % org_name else: print _("Could not apply default custom info keys to systems in Org [ %s ]") % org_name
class AddDefaultSystemInfo(OrganizationAction): description = _("add default custom info keynames for systems") def __init__(self): super(AddDefaultSystemInfo, self).__init__() self.system_info_keys_api = OrganizationSystemInfoKeysAPI() def setup_parser(self, parser): parser.add_option('--name', dest='name', help=_("organization name eg: foo.example.com (required)")) parser.add_option('--keyname', dest='keyname', help=_("name of the default custom info (required)")) def check_options(self, validator): validator.require(('name', 'keyname')) def run(self): org_name = self.get_option('name') keyname = self.get_option('keyname') response = self.system_info_keys_api.create(org_name, keyname) if response: print _("Successfully added default custom info key [ %(keyname)s ] to Org [ %(org_name)s ]") \ % {'keyname':keyname, 'org_name':org_name} else: print _("Could not add default custom info key [ %(keyname)s ] to Org [ %(org_name)s ]") \ % {'keyname':keyname, 'org_name':org_name}
def __init__(self): super(ApplyDefaultSystemInfo, self).__init__() self.system_info_keys_api = OrganizationSystemInfoKeysAPI()