mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	* NSX integration - skeletal code * Fix module not loading on startup * add upgrade path and daos \n add nsx controller command * add support for adding and listing nsx provider to a zone * add license * add default VPC offering and update upgrade path * add global setting to enable nsx plugin * add delete nsx controller operation * add nsxresource * add NSX resource , api client, create tier1 gw * update db * update response and add license * Add support to create and delete nsx tier-1 gateway * add license * cleanup and add skeletal code for network creation * add create/delete segment and UI integration * add license * address code smells - part 1 * fix test / build failure * NSX integration - skeletal code * Fix module not loading on startup * add upgrade path and daos \n add nsx controller command * add support for adding and listing nsx provider to a zone * add license * add default VPC offering and update upgrade path * add global setting to enable nsx plugin * add delete nsx controller operation * add nsxresource * add NSX resource , api client, create tier1 gw * update db * update response and add license * Add support to create and delete nsx tier-1 gateway * add license * cleanup and add skeletal code for network creation * add create/delete segment and UI integration * add license * address code smells - part 1 * fix test / build failure * add ui changes + update nsx_provider table transport zones + use NSX broadcast domain for add nics to router * ui: fix password field, and backend changes * add route advertisement * update offering * update offering * add sleep before deletion of vpc / tier g/w for ports to be removed * move creation of segments to design phase * change provider to VPC router for Dhcp & dns service in an nsx offering * Add public nic for NSX * reserve first IP (after g/w) of subnet for router nic - NSX * revert reserving 1st IP in vpc segments * [NSX] Create a DHCP relay and add it to a VPC tier segment (#107) * Create DHCP relay command and execute request * In progress integrate with networking * Create DHCP relay config on the network VR allocation * Revert domain router dao changes * Create DHCP relay con VR nic plug to NSX network * Link DHCP relay config to segment after creation * [NSX] Cleanup DHCP Relay config on segment deletion (#108) * Cleanup DHCP Relay config on segment deletion * update segment & relay name generators and call delete dhcprelay after deletion of segment * address comment * [NSX] Fix DHCP relay config deletion was missing zone name (#8068) * [NSX] Refactor API wrapper operations (#8059) * [NSX] Refactor API wrapper operations * Big refactor * Address review comment * change network cidr to cidr to prevent NPE * add domain and zone names to the various networks - vpc & tier --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * Nsx unit tests (#8090) * Add tests * add test for NsxGuestNetworkGuru * add unit tests for NsxResource * add unti tests for NsxElement * cleanup * [NSX] Refactor API wrapper operations * update tests * update tests - add nsxProviderServiceImpl test * add unit test - NsxServiceImpl * add license * Big refactor * Address review comment * change network cidr to cidr to prevent NPE * add domain and zone names to the various networks - vpc & tier * fix tests --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * modify NSX resource naming convention (#8095) * modify NSX resource naming convention * remove unused imports * add a setup phase between desgin and implementation of a network for intermediary steps * add method to all classes * NSX: Refactor Network & VPC offering (#8110) * [NSX] Refactor API wrapper operations * Network offering changes for NSX * fix services and provider combination * address comments: rename param * update nsx_mode parameter --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix test * [NSX] Allow NSX isolated networks (#8132) * Add network offerings for NSX on isolated networks * Fix offerings creation * In progress NSX isolated network * Fixes * Fix NIC allocation to router * NSX: Add Step for Adding Public traffic network for NSX During zone creation (#8126) * NSX: Add Step for Adding Public traffic network for NSX * address comments and cleanup * address comment * remove indent * NSX: Create and Delete static NAT & Port forward rules (#8131) * NSX: Create and delete NSX Static Nat rules * fix issues with static nat * add static nat * Support to add and delete Port forward rules * add license * fix adding multiple pf rules * cleanup * fix lint check * fix smoke tests * fix smoke tests * Nsx add lb rule (#8161) * NSX: Create and delete NSX Static Nat rules * fix issues with static nat * add static nat * Support to add and delete Port forward rules * add license * fix adding multiple pf rules * cleanup * NSX: Add support to create and delete Load balancer rules * fix deletion of lb rules * add header file and update protocol detail * build failure fix * [NSX] Add SNAT support (#8100) * In progress add source NAT * Fix after merge * Fix tests * Fix NPE on isolated network deletion * Reserve source NAT IP when its not passed for NSX VPC * Create source NAT rule on VR NIC allocation * Fix update VPC and remove VPC to update and remove SNAT rule * Fix packaging * Address review comment * Fix build * fix build - unused import * Add defensive checks * Add missing design to NSX public guru --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * NSX: Fix VR public NIC allocation (#8166) * NSX: fix LB member addition and deletion and add defensive checks (#8167) * Fix public NIC NPE on broadcast URI * NSX: Router Public nic to get IP from systemVM Ip range (#8172) * NSX: Router Public nic to get IP from systemVM Ip range * Fix VR IP address and setSourceNatIp command * NSX: hide systemVM reserved IP range SourceNAT * fix test --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix test failure * test failure fix * [NSX] Fix update source NAT IP (#8176) * [NSX] Fix update source NAT IP * Fix startup * Fix API result * NSX - add LB route Advertizement (#8192) * [NSX] Add ACL types support (#8224) * NSX: Create segment group on segment creation * Add unit tests * Remove group for segment before removing segment * Create Distributed Firewall rules * Remove distributed firewall policy on segment deletion * Fix policy rule ID and add more unit tests * Fix DROP action rules and transform tests * Add new ACL rules * Fixes * associate security policies with groups and not to DFW and add deletion of rules * Fix name convention --------- Co-authored-by: Pearl Dsilva <pearl1594@gmail.com> * NSX: Fix creation of VPCs (#8320) * Fix ACL rules creation (#8323) * [NSX] Fix database views (#8325) * NSX: Add CKS Support & Firewall rules for Isolated Networks (#8189) * NSX: Add ALL LB IP to the list of route advertisements in tier1 * NSX: Support Source NAT on NSX Isolated networks * NSX: Cks Support * NSX: Create segment group on segment creation * Add unit tests * Remove group for segment before removing segment * Create Distributed Firewall rules * Remove distributed firewall policy on segment deletion * Fix policy rule ID and add more unit tests * Add support for routed NSX Isolated networks \n and non RFC 1918 compliant IPs * Add support for routed NSX Isolated networks \n and non RFC 1918 compliant IPs * Add Firewall rules * build failure - fix unit test * fix npes * Add support to delete firewall rules * update nsx cks offering * add license * update order of ports in PF & FW rules * fix filter for getting transport zones * CKS support changed - MTU updated, etc * add LB for CKS on VPC * address comments * adapt upstream cks logic for vpc * rever mtu hack * update UI changes as per upstream fix * change display test for CKS n/w offerings for isolated and VPC tiers * add extra line for linter * address comment * revert list change --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * fix ui build failure * [NSX] Address SonarCloud Bugs (#8341) * [NSX] Address SonarCloud Bugs * Fix NSX API connection issues * NSX: Add unit tests to increase coverage (#8355) * NSX: Add unit tests * cleanup unused imports * add more unit tests * add tests for publicnsxnetworkguru * add license * fix build failures * address sonar comment * fix security hotspots * NSX: Add more unit tests (#8381) * NSX : Unit tests * remove unused imports * remove unused import causing build failure * fix build failures due to unused imports * fix build failure * fix test assertion * remove unused imports * remove unused import * Nsx UI zone bug (#8398) * NSX: Attempt to fix NSX Zone creation bug for public networks * fix zone wizard public traffic issue * add proper filtering of offerings based on VPC nsx mode * clean up console logs * NSX: Fix code smells and reported bugs (#8409) * NSX: Fix code smells and reported bugs * fox override issue * remove unused imports * fix test * refactor code to reduce complexity * add lisence * cleanup * fix build failure * fix build failure * address comments * test - add config to ignore certain files from test coverage * test exclusion of classes from test cov * rever pom changes * [NSX] Add more unit tests (#8431) * [NSX] Add more unit tests * More tests * Fix build errors * NSX: Prevent creation of L2 and Shared networks for NSX (#8463) * NSX: Prevent creation of L2 and Shared networks for NSX * add checks to backend to prevent creation of l2 and shared networks in nsx zones and filter only nsx offerings when creating isolated networks * cleanup * NSX: Fix code smells (#8436) * NSX: Fix code smells * Add changes to service creation logic * CKS: Add action to during firewall rule creation (#8498) * NSX,UI: Deduplicate network list when creating kubernetes clusters (#8513) * NSX: Make LB service selectable in network offering (#8512) * NSX: Make LB service selectable in network offering * fix label * address comments * address comments * NSX: Add appropriate error message when icmp type is set to -1 for NSX (#8504) * NSX: Add appropriate error message when icmp type is set to -1 for NSX * address comments * update text * fix test * fix test - build failure * fix test - build failure * NSX: Cleanup NSX resources during k8s cluster cleanup (#8528) * fix test failure * NSX: Improve segment deletion process (#8538) * NSX: Add passive monitor for NSX LB to test whether a server is available (#8533) * NSX: Add passive monitor for NSX LB to test whether a server is available * Add active monitors too * fix build failure * NSX: Add check for ICMP code / type for NSX zones (#8542) * NSX: Fix Routed Mode for Isolated and VPC networks (#8534) * NSX: Fix Routed Mode for Isolated and VPC networks * NSX: Fix Routed mode - add checks for ports added for FW rules * clean up code * fix build failure * NSX: Add retry logic with sleep to delete segments (#8554) * NSX: Add retry logic with sleep to delete segments * add logs * NSX: Fix custom ACL check (#2) * NSX: Fix custom ACL check * NSX: Fix custom ACL check * Nsx vpc routed mode (#5) * NSX: Fix VPC routed mode * NSX: VPC route mode * remove unnecessary changes * Nsx: Support internal LB (#4) * NSX: Support internal LB service in NSX * add lb removal logic * Fix UI issue hiding internal LB tab * Refactor method name --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * NSX: Improve NSX resource cleanup process (#3) * Fix unit test * NSX: Add SourceNAT service to the default Routed offering for VPC (#13) * Fix VPC restart with cleanup (#12) * NSX: Fix ACL rule removal on replacement and fix rule order (#11) * NSX: fix smoke test failure for ACLs (#9) * Fix unit tests * Fix NSX plugin pom XML * NSX: Add support to re-order ACL rules (NSX FW rules) (#14) * [WIP] NSX: Add support to re-order ACL rules (NSX FW rules) * fix reordering of acl rules on all networks that it is associated to * clean up and attempt test fix * Fix tests * Remove unused import * tweak reorder logic --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com> * Fix zone creation issue for internal load balancer * Fix * Fix unit test * fix logger * fix logger * fix logger * NSX: Fix VPC form to ignore source NAT IP when creating VPCs and fix label * Move SQL changes to the newest schema file * NSX: Last Fixes * Fix build --------- Co-authored-by: nvazquez <nicovazquez90@gmail.com>
		
			
				
	
	
		
			418 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			418 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/cygdrive/c/Python27
 | |
| # Licensed to the Apache Software Foundation (ASF) under one
 | |
| # or more contributor license agreements.  See the NOTICE file
 | |
| # distributed with this work for additional information
 | |
| # regarding copyright ownership.  The ASF licenses this file
 | |
| # to you under the Apache License, Version 2.0 (the
 | |
| # "License"); you may not use this file except in compliance
 | |
| # with the License.  You may obtain a copy of the License at
 | |
| #
 | |
| #   http://www.apache.org/licenses/LICENSE-2.0
 | |
| #
 | |
| # Unless required by applicable law or agreed to in writing,
 | |
| # software distributed under the License is distributed on an
 | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 | |
| # KIND, either express or implied.  See the License for the
 | |
| # specific language governing permissions and limitations
 | |
| # under the License.
 | |
| 
 | |
| import os
 | |
| import os.path
 | |
| import sys
 | |
| from xml.dom import minidom
 | |
| from xml.parsers.expat import ExpatError
 | |
| 
 | |
| 
 | |
| ROOT_ADMIN = 'r'
 | |
| 
 | |
| user_to_func = {
 | |
|     ROOT_ADMIN: 'populateForApi',
 | |
|     }
 | |
| 
 | |
| 
 | |
| user_to_cns = {
 | |
|     ROOT_ADMIN: 'allCommandNames',
 | |
|     }
 | |
| 
 | |
| 
 | |
| dirname_to_user = {
 | |
|     'apis': ROOT_ADMIN,
 | |
|     }
 | |
| 
 | |
| 
 | |
| dirname_to_dirname = {
 | |
|     'apis': 'apis',
 | |
|     }
 | |
| 
 | |
| 
 | |
| known_categories = {
 | |
|     'Cisco' : 'External Device',
 | |
|     'SystemVm': 'System VM',
 | |
|     'VirtualMachine': 'Virtual Machine',
 | |
|     'VM': 'Virtual Machine',
 | |
|     'Vnf': 'Virtual Network Functions',
 | |
|     'Domain': 'Domain',
 | |
|     'Template': 'Template',
 | |
|     'Iso': 'ISO',
 | |
|     'Volume': 'Volume',
 | |
|     'Vlan': 'VLAN',
 | |
|     'IpAddress': 'Address',
 | |
|     'PortForwarding': 'Firewall',
 | |
|     'Firewall': 'Firewall',
 | |
|     'StaticNat': 'NAT',
 | |
|     'IpForwarding': 'NAT',
 | |
|     'Host': 'Host',
 | |
|     'OutOfBand': 'Out-of-band Management',
 | |
|     'Cluster': 'Cluster',
 | |
|     'Account': 'Account',
 | |
|     'Role': 'Role',
 | |
|     'Snapshot': 'Snapshot',
 | |
|     'User': 'User',
 | |
|     'Os': 'Guest OS',
 | |
|     'ServiceOffering': 'Service Offering',
 | |
|     'DiskOffering': 'Disk Offering',
 | |
|     'LoadBalancer': 'Load Balancer',
 | |
|     'SslCert': 'Load Balancer',
 | |
|     'Router': 'Router',
 | |
|     'SystemVm': 'System VM',
 | |
|     'Configuration': 'Configuration',
 | |
|     'Capabilities': 'Configuration',
 | |
|     'Pod': 'Pod',
 | |
|     'PublicIpRange': 'Network',
 | |
|     'Zone': 'Zone',
 | |
|     'Vmware' : 'Zone',
 | |
|     'NetworkOffering': 'Network Offering',
 | |
|     'NetworkACL': 'Network ACL',
 | |
|     'Network': 'Network',
 | |
|     'CiscoNexus': 'Network',
 | |
|     'OpenDaylight': 'Network',
 | |
|     'createServiceInstance': 'Network',
 | |
|     'addGloboDnsHost': 'Network',
 | |
|     'createTungstenFabricProvider': 'Tungsten',
 | |
|     'listTungstenFabricProviders': 'Tungsten',
 | |
|     'configTungstenFabricService': 'Tungsten',
 | |
|     'createTungstenFabricPublicNetwork': 'Tungsten',
 | |
|     'synchronizeTungstenFabricData': 'Tungsten',
 | |
|     'addTungstenFabricPolicyRule': 'Tungsten',
 | |
|     'createTungstenFabricPolicy': 'Tungsten',
 | |
|     'deleteTungstenFabricPolicy': 'Tungsten',
 | |
|     'removeTungstenFabricPolicyRule': 'Tungsten',
 | |
|     'listTungstenFabricTag': 'Tungsten',
 | |
|     'listTungstenFabricTagType': 'Tungsten',
 | |
|     'listTungstenFabricPolicy': 'Tungsten',
 | |
|     'listTungstenFabricPolicyRule': 'Tungsten',
 | |
|     'listTungstenFabricNetwork': 'Tungsten',
 | |
|     'listTungstenFabricVm': 'Tungsten',
 | |
|     'listTungstenFabricNic': 'Tungsten',
 | |
|     'createTungstenFabricTag': 'Tungsten',
 | |
|     'createTungstenFabricTagType': 'Tungsten',
 | |
|     'deleteTungstenFabricTag': 'Tungsten',
 | |
|     'deleteTungstenFabricTagType': 'Tungsten',
 | |
|     'applyTungstenFabricPolicy': 'Tungsten',
 | |
|     'applyTungstenFabricTag': 'Tungsten',
 | |
|     'removeTungstenFabricTag': 'Tungsten',
 | |
|     'removeTungstenFabricPolicy': 'Tungsten',
 | |
|     'createTungstenFabricApplicationPolicySet': 'Tungsten',
 | |
|     'createTungstenFabricFirewallPolicy': 'Tungsten',
 | |
|     'createTungstenFabricFirewallRule': 'Tungsten',
 | |
|     'createTungstenFabricServiceGroup': 'Tungsten',
 | |
|     'createTungstenFabricAddressGroup': 'Tungsten',
 | |
|     'createTungstenFabricLogicalRouter': 'Tungsten',
 | |
|     'addTungstenFabricNetworkGatewayToLogicalRouter': 'Tungsten',
 | |
|     'listTungstenFabricApplicationPolicySet': 'Tungsten',
 | |
|     'listTungstenFabricFirewallPolicy': 'Tungsten',
 | |
|     'listTungstenFabricFirewallRule': 'Tungsten',
 | |
|     'listTungstenFabricServiceGroup': 'Tungsten',
 | |
|     'listTungstenFabricAddressGroup': 'Tungsten',
 | |
|     'listTungstenFabricLogicalRouter': 'Tungsten',
 | |
|     'deleteTungstenFabricApplicationPolicySet': 'Tungsten',
 | |
|     'deleteTungstenFabricFirewallPolicy': 'Tungsten',
 | |
|     'deleteTungstenFabricFirewallRule': 'Tungsten',
 | |
|     'deleteTungstenFabricAddressGroup': 'Tungsten',
 | |
|     'deleteTungstenFabricServiceGroup': 'Tungsten',
 | |
|     'deleteTungstenFabricLogicalRouter': 'Tungsten',
 | |
|     'removeTungstenFabricNetworkGatewayFromLogicalRouter': 'Tungsten',
 | |
|     'updateTungstenFabricLBHealthMonitor': 'Tungsten',
 | |
|     'listTungstenFabricLBHealthMonitor': 'Tungsten',
 | |
|     'listNsxControllers': 'NSX',
 | |
|     'addNsxController': 'NSX',
 | |
|     'deleteNsxController': 'NSX',
 | |
|     'Vpn': 'VPN',
 | |
|     'Limit': 'Limit',
 | |
|     'ResourceCount': 'Limit',
 | |
|     'CloudIdentifier': 'Cloud Identifier',
 | |
|     'InstanceGroup': 'VM Group',
 | |
|     'StorageMaintenance': 'Storage Pool',
 | |
|     'StoragePool': 'Storage Pool',
 | |
|     'StorageProvider': 'Storage Pool',
 | |
|     'updateStorageCapabilities' : 'Storage Pool',
 | |
|     'SecurityGroup': 'Security Group',
 | |
|     'SSH': 'SSH',
 | |
|     'register': 'Registration',
 | |
|     'AsyncJob': 'Async job',
 | |
|     'Certificate': 'Certificate',
 | |
|     'Hypervisor': 'Hypervisor',
 | |
|     'Alert': 'Alert',
 | |
|     'Event': 'Event',
 | |
|     'login': 'Authentication',
 | |
|     'logout': 'Authentication',
 | |
|     'saml': 'Authentication',
 | |
|     'getSPMetadata': 'Authentication',
 | |
|     'listIdps': 'Authentication',
 | |
|     'authorizeSamlSso': 'Authentication',
 | |
|     'listSamlAuthorization': 'Authentication',
 | |
|     'oauthlogin': 'Authentication',
 | |
|     'deleteOauthProvider': 'Oauth',
 | |
|     'listOauthProvider': 'Oauth',
 | |
|     'registerOauthProvider': 'Oauth',
 | |
|     'updateOauthProvider': 'Oauth',
 | |
|     'quota': 'Quota',
 | |
|     'emailTemplate': 'Quota',
 | |
|     'Capacity': 'System Capacity',
 | |
|     'NetworkDevice': 'Network Device',
 | |
|     'ExternalLoadBalancer': 'Ext Load Balancer',
 | |
|     'ExternalFirewall': 'Ext Firewall',
 | |
|     'Usage': 'Usage',
 | |
|     'TrafficMonitor': 'Usage',
 | |
|     'TrafficType': 'Usage',
 | |
|     'Product': 'Product',
 | |
|     'LB': 'Load Balancer',
 | |
|     'ldap': 'LDAP',
 | |
|     'Ldap': 'LDAP',
 | |
|     'Swift': 'Swift',
 | |
|     'S3' : 'S3',
 | |
|     'SecondaryStorage': 'Host',
 | |
|     'Project': 'Project',
 | |
|     'Lun': 'Storage',
 | |
|     'Pool': 'Pool',
 | |
|     'VPC': 'VPC',
 | |
|     'PrivateGateway': 'VPC',
 | |
|     'migrateVpc': 'VPC',
 | |
|     'Simulator': 'simulator',
 | |
|     'StaticRoute': 'VPC',
 | |
|     'Tags': 'Resource tags',
 | |
|     'Icon': 'Resource Icon',
 | |
|     'NiciraNvpDevice': 'Nicira NVP',
 | |
|     'BrocadeVcsDevice': 'Brocade VCS',
 | |
|     'BigSwitchBcfDevice': 'BigSwitch BCF',
 | |
|     'AutoScale': 'AutoScale',
 | |
|     'Counter': 'AutoScale',
 | |
|     'Condition': 'AutoScale',
 | |
|     'Api': 'API Discovery',
 | |
|     'Region': 'Region',
 | |
|     'Detail': 'Resource metadata',
 | |
|     'addIpToNic': 'Nic',
 | |
|     'removeIpFromNic': 'Nic',
 | |
|     'updateVmNicIp': 'Nic',
 | |
|     'listNics':'Nic',
 | |
| 	'AffinityGroup': 'Affinity Group',
 | |
|     'addImageStore': 'Image Store',
 | |
|     'listImageStore': 'Image Store',
 | |
|     'deleteImageStore': 'Image Store',
 | |
|     'createSecondaryStagingStore': 'Image Store',
 | |
|     'deleteSecondaryStagingStore': 'Image Store',
 | |
|     'listSecondaryStagingStores': 'Image Store',
 | |
|     'updateImageStore': 'Image Store',
 | |
|     'downloadImageStoreObject': 'Image Store',
 | |
|     'InternalLoadBalancer': 'Internal LB',
 | |
| 	'DeploymentPlanners': 'Configuration',
 | |
| 	'ObjectStore': 'Image Store',
 | |
|     'PortableIp': 'Portable IP',
 | |
|     'dedicateHost': 'Dedicate Resources',
 | |
|     'releaseDedicatedHost': 'Dedicate Resources',
 | |
|     'Baremetal' : 'Baremetal',
 | |
|     'UCS' : 'UCS',
 | |
|     'Ucs' : 'UCS',
 | |
|     'CacheStores' : 'Cache Stores',
 | |
|     'CacheStore' : 'Cache Store',
 | |
|     'OvsElement' : 'Ovs Element',
 | |
|     'StratosphereSsp' : ' Stratosphere SSP',
 | |
|     'Metrics' : 'Metrics',
 | |
|     'Infrastructure' : 'Metrics',
 | |
|     'listNetscalerControlCenter' : 'Load Balancer',
 | |
|     'listRegisteredServicePackages': 'Load Balancer',
 | |
|     'listNsVpx' : 'Load Balancer',
 | |
|     'destroyNsVPx': 'Load Balancer',
 | |
|     'deployNetscalerVpx' : 'Load Balancer',
 | |
|     'deleteNetscalerControlCenter' : 'Load Balancer',
 | |
|     'stopNetScalerVpx' : 'Load Balancer',
 | |
|     'deleteServicePackageOffering' : 'Load Balancer',
 | |
|     'destroyNsVpx' : 'Load Balancer',
 | |
|     'startNsVpx' : 'Load Balancer',
 | |
|     'listAnnotations' : 'Annotations',
 | |
|     'addAnnotation' : 'Annotations',
 | |
|     'removeAnnotation' : 'Annotations',
 | |
|     'updateAnnotationVisibility' : 'Annotations',
 | |
|     'CA': 'Certificate',
 | |
|     'listElastistorInterface': 'Misc',
 | |
|     'cloudian': 'Cloudian',
 | |
|     'Sioc' : 'Sioc',
 | |
|     'Diagnostics': 'Diagnostics',
 | |
|     'Management': 'Management',
 | |
|     'Backup' : 'Backup and Recovery',
 | |
|     'Restore' : 'Backup and Recovery',
 | |
|     'UnmanagedInstance': 'Virtual Machine',
 | |
|     'KubernetesSupportedVersion': 'Kubernetes Service',
 | |
|     'KubernetesCluster': 'Kubernetes Service',
 | |
|     'UnmanagedInstance': 'Virtual Machine',
 | |
|     'Rolling': 'Rolling Maintenance',
 | |
|     'importVsphereStoragePolicies' : 'vSphere storage policies',
 | |
|     'listVsphereStoragePolicies' : 'vSphere storage policies',
 | |
|     'ConsoleEndpoint': 'Console Endpoint',
 | |
|     'Shutdown': 'Shutdown',
 | |
|     'importVm': 'Virtual Machine',
 | |
|     'listQuarantinedIp': 'IP Quarantine',
 | |
|     'updateQuarantinedIp': 'IP Quarantine',
 | |
|     'removeQuarantinedIp': 'IP Quarantine',
 | |
|     'Shutdown': 'Shutdown',
 | |
|     'addObjectStoragePool': 'Object Store',
 | |
|     'listObjectStoragePools': 'Object Store',
 | |
|     'deleteObjectStoragePool': 'Object Store',
 | |
|     'updateObjectStoragePool': 'Object Store',
 | |
|     'createBucket': 'Object Store',
 | |
|     'updateBucket': 'Object Store',
 | |
|     'deleteBucket': 'Object Store',
 | |
|     'listBuckets': 'Object Store',
 | |
|     'listVmsForImport': 'Virtual Machine',
 | |
|     'importVm': 'Virtual Machine'
 | |
| }
 | |
| 
 | |
| 
 | |
| categories = {}
 | |
| 
 | |
| 
 | |
| def choose_category(fn):
 | |
|     for k, v in known_categories.items():
 | |
|         if k in fn:
 | |
|             return v
 | |
|     raise Exception('Need to add a category for %s to %s:known_categories' %
 | |
|                     (fn, __file__))
 | |
|     sys.exit(1)
 | |
| 
 | |
| 
 | |
| for f in sys.argv:
 | |
|     dirname, fn = os.path.split(f)
 | |
|     if not fn.endswith('.xml'):
 | |
|         continue
 | |
|     if fn.endswith('Summary.xml') and fn != 'quotaSummary.xml':
 | |
|         continue
 | |
|     if fn.endswith('SummarySorted.xml'):
 | |
|         continue
 | |
|     if fn == 'alert_types.xml':
 | |
|         continue
 | |
|     if dirname.startswith('./'):
 | |
|         dirname = dirname[2:]
 | |
|     try:
 | |
|         with open(f) as data:
 | |
|             dom = minidom.parse(data)
 | |
|         name = dom.getElementsByTagName('name')[0].firstChild.data
 | |
|         isAsync = dom.getElementsByTagName('isAsync')[0].firstChild.data
 | |
|         isDeprecated = dom.getElementsByTagName('isDeprecated')[0].firstChild.data
 | |
|         category = choose_category(fn)
 | |
|         if category not in categories:
 | |
|             categories[category] = []
 | |
|         categories[category].append({
 | |
|             'name': name,
 | |
|             'dirname': dirname_to_dirname[dirname],
 | |
|             'async': isAsync == 'true',
 | |
|             'deprecated': isDeprecated == 'true',
 | |
|             'user': dirname_to_user[dirname],
 | |
|             })
 | |
|     except ExpatError as e:
 | |
|         pass
 | |
|     except IndexError as e:
 | |
|         print(fn)
 | |
| 
 | |
| 
 | |
| def xml_for(command):
 | |
|     name = command['name']
 | |
|     isAsync = command['async'] and ' (A)' or ''
 | |
|     isDeprecated = command['deprecated'] and ' (D)' or ''
 | |
|     dirname = command['dirname']
 | |
|     return '''<xsl:if test="name=\'%(name)s\'">
 | |
| <li><a href="%(dirname)s/%(name)s.html"><xsl:value-of select="name"/>%(isAsync)s %(isDeprecated)s</a></li>
 | |
| </xsl:if>
 | |
| ''' % locals()
 | |
| 
 | |
| 
 | |
| def write_xml(out, user):
 | |
|     with open(out, 'w') as f:
 | |
|         cat_strings = []
 | |
| 
 | |
|         for category in categories.keys():
 | |
|             strings = []
 | |
|             for command in categories[category]:
 | |
|                 if command['user'] == user:
 | |
|                     strings.append(xml_for(command))
 | |
|             if strings:
 | |
|                 all_strings = ''.join(strings)
 | |
|                 cat_strings.append((len(strings), category, all_strings))
 | |
| 
 | |
|         cat_strings.sort(reverse=True)
 | |
| 
 | |
|         i = 0
 | |
|         for _1, category, all_strings in cat_strings:
 | |
|             if i == 0:
 | |
|                 f.write('<div class="apismallsections">\n')
 | |
|             f.write('''<div class="apismallbullet_box">
 | |
| <h5>%(category)s</h5>
 | |
| <ul>
 | |
| <xsl:for-each select="commands/command">
 | |
| %(all_strings)s
 | |
| </xsl:for-each>
 | |
| </ul>
 | |
| </div>
 | |
| 
 | |
| ''' % locals())
 | |
|             if i == 3:
 | |
|                 f.write('</div>\n')
 | |
|                 i = 0
 | |
|             else:
 | |
|                 i += 1
 | |
|         if i != 0:
 | |
|             f.write('</div>\n')
 | |
| 
 | |
| 
 | |
| def java_for(command, user):
 | |
|     name = command['name']
 | |
|     cns = user_to_cns[user]
 | |
|     return '''%(cns)s.add("%(name)s");
 | |
| ''' % locals()
 | |
| 
 | |
| 
 | |
| def java_for_user(user):
 | |
|     strings = []
 | |
|     for category in categories.keys():
 | |
|         for command in categories[category]:
 | |
|             if command['user'] == user:
 | |
|                 strings.append(java_for(command, user))
 | |
|     func = user_to_func[user]
 | |
|     all_strings = ''.join(strings)
 | |
|     return '''
 | |
|     public void %(func)s() {
 | |
|         %(all_strings)s
 | |
|     }
 | |
| ''' % locals()
 | |
| 
 | |
| 
 | |
| def write_java(out):
 | |
|     with open(out, 'w') as f:
 | |
|         f.write('''/* Generated using gen_toc.py.  Do not edit. */
 | |
| 
 | |
| import java.util.HashSet;
 | |
| import java.util.Set;
 | |
| 
 | |
| public class XmlToHtmlConverterData {
 | |
|     Set<String> allCommandNames = new HashSet<String>();
 | |
| ''')
 | |
|         f.write(java_for_user(ROOT_ADMIN) + "\n")
 | |
| 
 | |
|         f.write('''
 | |
| }
 | |
| 
 | |
| ''')
 | |
| 
 | |
| 
 | |
| write_xml('generatetoc_include.xsl', ROOT_ADMIN)
 | |
| write_java('XmlToHtmlConverterData.java')
 |