def main(): with open(os.path.join(HERE, 'generator_options.yaml'), 'r') as fh: options = yaml.load(fh) # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'appfw') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, options['nitro_api_defines']) if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'appfwjsoncontenttype.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('appfwjsoncontenttype', main_object_attributes) ) print(json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='appfwjsoncontenttype', main_object_put_id='jsoncontenttypevalue', attributes_config_list=attributes_config_list, )
def main(): # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'appfw') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, '..', 'nitro_api_defines/kamet/appfw') if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'appfwfieldtype.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes, skip_attributes=['newname']) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('appfwfieldtype', main_object_attributes, skip_attributes=['newname'])) print(json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='appfwfieldtype', main_object_put_id='name', attributes_config_list=attributes_config_list, )
def append_bindings(json_file, binding_dict): with open(json_file, 'r') as fh: attributes = json.load(fh) key = binding_dict['binding_key'] binding_dict.update({ 'attributes_config_list': calculate_attributes_config_dict(key, attributes), }) bindings.append(binding_dict) attributes_config_list.append(binding_dict['attributes_config_list'])
def main(): with open(os.path.join(HERE, 'generator_options.yaml'), 'r') as fh: options = yaml.load(fh) # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'appfw') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, options['nitro_api_defines']) if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'appfwpolicylabel.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes, skip_attributes=['newname']) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('appfwpolicylabel', main_object_attributes, skip_attributes=['newname'])) # Add the bindings objects bindings = [] def append_bindings(json_file, binding_dict): with open(json_file, 'r') as fh: attributes = json.load(fh) key = binding_dict['binding_key'] binding_dict.update({ 'attributes_config_list': calculate_attributes_config_dict(key, attributes), }) bindings.append(binding_dict) attributes_config_list.append(binding_dict['attributes_config_list']) print(json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='appfwpolicylabel', main_object_put_id='name', attributes_config_list=attributes_config_list, bindings=bindings, )
def append_bindings(json_file, binding_dict): with open(json_file, 'r') as fh: attributes = json.load(fh) key = binding_dict['binding_key'] binding_dict.update({ 'attributes_config_list': calculate_attributes_config_dict(key, attributes), }) doc_list = copy.deepcopy(binding_dict['attributes_config_list']['attributes']) doc_list.remove(binding_dict['link_to_main']['bind_key']) binding_dict['doc_list'] = calculate_doc_list(attributes) binding_dict bindings.append(binding_dict) attributes_config_list.append(binding_dict['attributes_config_list'])
def main(): # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'citrix_adm') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, '..', 'nitro_api_defines/kamet/appfw') if not os.path.exists(json_dir): raise Exception('Cannot find json dir') yaml_dir = os.path.join(HERE, '..', 'citrix_adm_api_defines', 'kamet') if not os.path.exists(yaml_dir): raise Exception('Cannot find json dir') main_yaml_file = os.path.join(yaml_dir, 'mpsuser.yaml') with open(main_yaml_file, 'r') as fh: main_object_attributes = yaml.load(fh) # permission of mpsuser is not implemented in the API main_object_attributes = [ item for item in main_object_attributes if item['option_name'] != 'permission'] #del main_object_attributes['permission'] main_object_doc_list = calculate_doc_list(main_object_attributes) print('main_object_doc_list %s' % json.dumps(main_object_doc_list, indent=4)) attributes_config_list = [] main_data = calculate_attributes_config_dict('mpsuser', main_object_attributes) main_data['transforms'] = OrderedDict([ ('enable_session_timeout', 'lambda v: "true" if v else "false"'), ('external_authentication', 'lambda v: "true" if v else "false"'), ]) attributes_config_list.append(main_data) print('attributes_config_list: %s' % json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='mpsuser', main_object_put_id='id', attributes_config_list=attributes_config_list, )
def main(): # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'citrix_adm') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, '..', 'nitro_api_defines/kamet/appfw') if not os.path.exists(json_dir): raise Exception('Cannot find json dir') yaml_dir = os.path.join(HERE, '..', 'citrix_adm_api_defines', 'kamet') if not os.path.exists(yaml_dir): raise Exception('Cannot find json dir') main_yaml_file = os.path.join(yaml_dir, 'mpsgroup.yaml') with open(main_yaml_file, 'r') as fh: main_object_attributes = yaml.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes) print('main_object_doc_list %s' % json.dumps(main_object_doc_list, indent=4)) attributes_config_list = [] main_data = calculate_attributes_config_dict('mpsgroup', main_object_attributes) main_data['transforms'] = OrderedDict([ ('enable_session_timeout', 'lambda v: "true" if v else "false"'), ('allow_application_only', 'lambda v: "true" if v else "false"'), ('assign_all_apps', 'lambda v: "true" if v else "false"'), ('assign_all_devices', 'lambda v: "true" if v else "false"'), ]) attributes_config_list.append(main_data) print('attributes_config_list: %s' % json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='mpsgroup', main_object_put_id='id', attributes_config_list=attributes_config_list, )
def main(): # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'citrix_adm') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, '..', 'nitro_api_defines/kamet/appfw') if not os.path.exists(json_dir): raise Exception('Cannot find json dir') yaml_dir = os.path.join(HERE, '..', 'citrix_adm_api_defines', 'kamet') if not os.path.exists(yaml_dir): raise Exception('Cannot find json dir') main_yaml_file = os.path.join(yaml_dir, 'stylebook.yaml') with open(main_yaml_file, 'r') as fh: main_object_attributes = yaml.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes) for item in main_object_doc_list: if item['option_name'] in ('version', 'name', 'namespace'): item['required'] = True print('main_object_doc_list %s' % json.dumps(main_object_doc_list, indent=4)) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('stylebook', main_object_attributes) ) print('attributes_config_list: %s' % json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='stylebook', main_object_put_id='id', attributes_config_list=attributes_config_list, )
def main(): with open(os.path.join(HERE, 'generator_options.yaml'), 'r') as fh: options = yaml.load(fh) # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'appfw') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, options['nitro_api_defines']) if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'appfwconfidfield.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes) # Remove state attribute documentation # In its place the disabled attribute is included in the template main_object_doc_list = [ item for item in main_object_doc_list if item['option_name'] != 'state' ] print('main_object_doc_list %s' % json.dumps(main_object_doc_list, indent=4)) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('appfwconfidfield', main_object_attributes)) print('attributes_config_list: %s' % json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='appfwconfidfield', main_object_put_id='fieldname', attributes_config_list=attributes_config_list, )
def main(): # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'citrix_adm') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, '..', 'nitro_api_defines/kamet/appfw') if not os.path.exists(json_dir): raise Exception('Cannot find json dir') yaml_dir = os.path.join(HERE, '..', 'citrix_adm_api_defines', 'kamet') if not os.path.exists(yaml_dir): raise Exception('Cannot find json dir') main_yaml_file = os.path.join(yaml_dir, 'dns_domain_entry.yaml') with open(main_yaml_file, 'r') as fh: main_object_attributes = yaml.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes) print('main_object_doc_list %s' % json.dumps(main_object_doc_list, indent=4)) attributes_config_list = [] main_data = calculate_attributes_config_dict('dns_domain_entry', main_object_attributes) attributes_config_list.append(main_data) print('attributes_config_list: %s' % json.dumps(attributes_config_list, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='dns_domain_entry', main_object_put_id='id', attributes_config_list=attributes_config_list, )
def main(): with open(os.path.join(HERE, 'generator_options.yaml'), 'r') as fh: options = yaml.load(fh) # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'appfw') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, options['nitro_api_defines']) if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'appfwprofile.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes, skip_attributes=['newname']) attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('appfwprofile', main_object_attributes, skip_attributes=['newname'])) # Add the bindings objects bindings = [] def append_bindings(json_file, binding_dict): with open(json_file, 'r') as fh: attributes = json.load(fh) key = binding_dict['binding_key'] binding_dict.update({ 'attributes_config_list': calculate_attributes_config_dict(key, attributes), }) doc_list = copy.deepcopy( binding_dict['attributes_config_list']['attributes']) doc_list.remove(binding_dict['link_to_main']['bind_key']) binding_dict['doc_list'] = doc_list bindings.append(binding_dict) attributes_config_list.append(binding_dict['attributes_config_list']) # contenttype bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_contenttype_binding.json'), binding_dict={ 'binding_key': 'contenttype_bindings', 'description': 'contenttype bindings', 'binding_object': 'appfwprofile_contenttype_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # cookieconsistency append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_cookieconsistency_binding.json'), binding_dict={ 'binding_key': 'cookieconsistency_bindings', 'description': 'cookieconsistency bindings', 'binding_object': 'appfwprofile_cookieconsistency_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # creditcardnumber append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_creditcardnumber_binding.json'), binding_dict={ 'binding_key': 'creditcardnumber_bindings', 'description': 'creditcardnumber bindings', 'binding_object': 'appfwprofile_creditcardnumber_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # crosssitescripting append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_crosssitescripting_binding.json'), binding_dict={ 'binding_key': 'crosssitescripting_bindings', 'description': 'crosssitescripting bindings', 'binding_object': 'appfwprofile_crosssitescripting_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # csrftag append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_csrftag_binding.json'), binding_dict={ 'binding_key': 'csrftag_bindings', 'description': 'csrftag bindings', 'binding_object': 'appfwprofile_csrftag_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # denyurl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_denyurl_binding.json'), binding_dict={ 'binding_key': 'denyurl_bindings', 'description': 'denyurl bindings', 'binding_object': 'appfwprofile_denyurl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # excluderescontenttype bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_excluderescontenttype_binding.json'), binding_dict={ 'binding_key': 'excluderescontenttype_bindings', 'description': 'excluderescontenttype bindings', 'binding_object': 'appfwprofile_excluderescontenttype_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # fieldconsistency bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_fieldconsistency_binding.json'), binding_dict={ 'binding_key': 'fieldconsistency_bindings', 'description': 'fieldconsistency bindings', 'binding_object': 'appfwprofile_fieldconsistency_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # fieldformat bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_fieldformat_binding.json'), binding_dict={ 'binding_key': 'fieldformat_bindings', 'description': 'fieldformat bindings', 'binding_object': 'appfwprofile_fieldformat_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # FIXME file bug for as_expression -> expression # safeobject bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_safeobject_binding.json'), binding_dict={ 'binding_key': 'safeobject_bindings', 'description': 'safeobject bindings', 'binding_object': 'appfwprofile_safeobject_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # sqlinjection bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_sqlinjection_binding.json'), binding_dict={ 'binding_key': 'sqlinjection_bindings', 'description': 'sqlinjection bindings', 'binding_object': 'appfwprofile_sqlinjection_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # starturl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_starturl_binding.json'), binding_dict={ 'binding_key': 'starturl_bindings', 'description': 'starturl bindings', 'binding_object': 'appfwprofile_starturl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # trustedlearningclients bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_trustedlearningclients_binding.json'), binding_dict={ 'binding_key': 'trustedlearningclients_bindings', 'description': 'trustedlearningclients bindings', 'binding_object': 'appfwprofile_trustedlearningclients_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmlattachmenturl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_xmlattachmenturl_binding.json'), binding_dict={ 'binding_key': 'xmlattachmenturl_bindings', 'description': 'xmlattachmenturl bindings', 'binding_object': 'appfwprofile_xmlattachmenturl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmldosurl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_xmldosurl_binding.json'), binding_dict={ 'binding_key': 'xmldosurl_bindings', 'description': 'xmldosurl bindings', 'binding_object': 'appfwprofile_xmldosurl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmlsqlinjection bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_xmlsqlinjection_binding.json'), binding_dict={ 'binding_key': 'xmlsqlinjection_bindings', 'description': 'xmlsqlinjection bindings', 'binding_object': 'appfwprofile_xmlsqlinjection_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmlvalidationurl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_xmlvalidationurl_binding.json'), binding_dict={ 'binding_key': 'xmlvalidationurl_bindings', 'description': 'xmlvalidationurl bindings', 'binding_object': 'appfwprofile_xmlvalidationurl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmlwsiurl bindings append_bindings(json_file=os.path.join( json_dir, 'appfwprofile_xmlwsiurl_binding.json'), binding_dict={ 'binding_key': 'xmlwsiurl_bindings', 'description': 'xmlwsiurl bindings', 'binding_object': 'appfwprofile_xmlwsiurl_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) # xmlxss bindings append_bindings(json_file=os.path.join(json_dir, 'appfwprofile_xmlxss_binding.json'), binding_dict={ 'binding_key': 'xmlxss_bindings', 'description': 'xmlxss bindings', 'binding_object': 'appfwprofile_xmlxss_binding', 'get_all_id': 'name', 'link_to_main': { 'main_key': 'name', 'bind_key': 'name', }, }) print(json.dumps(attributes_config_list, indent=4)) print('Bindings\n%s' % json.dumps(bindings, indent=4)) # Populate the template populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='appfwprofile', main_object_put_id='name', attributes_config_list=attributes_config_list, bindings=bindings, )
def main(): with open(os.path.join(HERE, 'generator_options.yaml'), 'r') as fh: options = yaml.load(fh) # Find template dir template_dir = os.path.join(HERE, '..', 'templates', 'basic') if not os.path.exists(template_dir): raise Exception('Cannot find template dir') # Find nscli json data dir json_dir = os.path.join(HERE, options['nitro_api_defines']) if not os.path.exists(json_dir): raise Exception('Cannot find json dir') main_json_file = os.path.join(json_dir, 'servicegroup.json') with open(main_json_file, 'r') as fh: main_object_attributes = json.load(fh) main_object_doc_list = calculate_doc_list(main_object_attributes, skip_attributes=['newname', 'state']) # Revert clttimeout and srvtimeout to int for doc_item in main_object_doc_list: if doc_item['option_name'] in ('clttimeout', 'svrtimeout'): doc_item['type'] = 'int' attributes_config_list = [] attributes_config_list.append( calculate_attributes_config_dict('servicegroup', main_object_attributes, skip_attributes=['newname', 'state']) ) attributes_config_list[-1]['non_updateable_attributes'] = calculate_non_updateable_attributes(main_object_attributes) #print(attributes_config_list[0]['non_updateable_attributes']) # Add the bindings objects bindings = [] def append_bindings(json_file, binding_dict): with open(json_file, 'r') as fh: attributes = json.load(fh) key = binding_dict['binding_key'] binding_dict.update({ 'attributes_config_list': calculate_attributes_config_dict(key, attributes), }) doc_list = copy.deepcopy(binding_dict['attributes_config_list']['attributes']) doc_list.remove(binding_dict['link_to_main']['bind_key']) binding_dict['doc_list'] = calculate_doc_list(attributes) binding_dict bindings.append(binding_dict) attributes_config_list.append(binding_dict['attributes_config_list']) # Process servicemembers json_file=os.path.join(json_dir, 'servicegroup_servicegroupmember_binding.json') with open(json_file, 'r') as fh: attributes = json.load(fh) servicemembers = {} servicemembers['doc_list'] = calculate_doc_list(attributes, skip_attributes=['servicegroupname']) servicemembers['attributes_config'] = calculate_attributes_config_dict('servicemembers', attributes, skip_attributes=['servicegroupname']) #print(json.dumps(servicemembers, indent=4)) if 'weight' in servicemembers['attributes_config']['transforms']: raise Exception('Cannot override transform for weight in servicemembers') servicemembers['attributes_config']['transforms']['weight'] = 'lambda v: str(v)' # Process monitor bindings json_file=os.path.join(json_dir, 'servicegroup_lbmonitor_binding.json') with open(json_file, 'r') as fh: attributes = json.load(fh) monitor_bindings = {} monitor_bindings['doc_list'] = calculate_doc_list(attributes, skip_attributes=['servicegroupname']) monitor_bindings['attributes_config'] = calculate_attributes_config_dict('monitor_bindings', attributes, skip_attributes=['servicegroupname']) print(json.dumps(monitor_bindings, indent=4)) if 'weight' in monitor_bindings['attributes_config']['transforms']: raise Exception('Cannot override transform for weight in monitor_bindings') monitor_bindings['attributes_config']['transforms']['weight'] = 'lambda v: str(v)' populate_template( template_dir, main_object_doc_list=main_object_doc_list, main_nitro_class='servicegroup', main_object_put_id='servicegroupname', attributes_config_list=attributes_config_list, servicemembers=servicemembers, monitor_bindings=monitor_bindings, )