Skip to main content

Code Structure

Backend Code Structure

  • build: Compilation and build related directories, each component has a corresponding directory under this directory
  • cmd: Directory where entry functions (main functions) of each component are located
    • climc: Command-line tool climc code
      • shell: Command-line tool code corresponding to each service
  • docs: API swagger documentation, currently unused
  • locales: Localization code directory, mainly responsible for localizing information in responses
  • pkg: Main code
    • ansibleserver: ansibleserver code, service that executes ansible
    • apigateway: API gateway code
      • app: web service toolkit
      • clientman: Code related to clients accessing other services
      • constants: Constants
      • handler: web service handler
      • options: Service parameters
      • policy: keystone permission client code
      • service: Main service code
    • apihelper: web service toolkit
    • apis: API data structures, generally each directory corresponds to a component
      • compute: region's API data structures
        • zz_generated.model.go: Automatically generated corresponding data structures based on region's models
    • appctx: context toolkit
    • appsrv: web framework
      • dispatcher: web routing related code
    • baremetal: baremetal-agent service code
    • cloudcommon: Common toolkit
      • agent: Common package for agent services, currently used by baremetal-agent and esxi-agent
      • app: web service toolkit
      • cmdline: Command-line toolkit
      • cronman: cronjob toolkit
      • db: Common code for service models
        • lockman: Lock toolkit
        • proxy: Proxy settings, mainly used by pkg/compute/models/cloudaccounts.go
        • quotas: Quota related code
        • taskman: Asynchronous task code
      • elect: etcd related code
      • etcd: etcd related code
      • informer: Subscription notification related code, if you want to monitor changes in certain models, you can subscribe
      • notifyclient: Client code corresponding to notify service
      • options: Common options
      • pending_delete: pending_delete related option
      • policy: Common code for model default permissions, mainly used to set default keystone permissions for models of each service
      • service: Common service code
      • syncman: Code related to informer usage
        • watcher: Monitor service models
      • validators: Common code for validating web request parameters
      • workmanager: worker code
    • cloudevent: cloudevent service, public cloud logs
    • cloudid: cloudid service, public cloud passwordless login
    • cloudmon: cloudmon service, public cloud monitoring
      • collectors: Monitoring data collection for various public clouds
    • cloudprovider: Common data structures for multi-cloud
    • cloudproxy: Proxy service, can access virtual machines inside vpc through proxy
    • compute: region service code
      • baremetal: baremetal related code
      • capabilities: capabilities interface code
      • guestdrivers: Virtual machine related operation code in multi-cloud scenarios, different clouds implement drivers
      • hostdrivers: Host related operation code in multi-cloud scenarios, different clouds implement drivers
      • misc: Physical machines with existing operating systems, interface code
      • models: Service resource model code, generally one model corresponds to one table in the database
      • options: Service options
      • policy: Resource model default permissions
      • regiondrivers: Region-level cloud resource operation code in multi-cloud scenarios, different clouds implement drivers
      • service: Service startup code
      • specs: Code for obtaining physical machine and GPU specifications, used to create bare metal and GPU virtual machines
      • sshkeys: Code for obtaining sshkey, including global sshkey and project sshkey, can be used to access virtual machines
      • storagedrivers: Storage related operation code in multi-cloud scenarios, different clouds implement drivers
      • tasks: Service related asynchronous task code, for example creating virtual machines will eventually be executed as asynchronous tasks
      • usages: Interface for obtaining cloud resource usage statistics
    • controller: Controller code
      • autoscaling: Auto-scaling controller, mainly used to implement virtual machine auto-scaling functionality
    • devtool: Operations tool service, for example installing monitoring agents
    • esxi: esxi-agent service, mainly used to operate vmware clusters or esxi hosts
    • hostimage: Service deployed on each host, related to images
    • hostman: host service related code
      • diskutils: Disk operation toolkit
        • fsutils: File system operation toolkit
        • libguestfs: Toolkit for calling libguestfs
        • nbd: Toolkit for calling nbd module
      • downloader: Download code, including image, snapshot downloads, etc.
      • guestfs: Mainly used to mount virtual machine disks, detect disk fs, and perform some initialization operations
      • guestman: Virtual machine related interfaces in host service
      • host_health: Host health check related interfaces
      • hostdeployer: host-deployer service code, host-deployer is mainly used to initialize virtual machines
      • hosthandler: Host related interfaces in host service
      • storageman: Storage related interfaces in host service
    • httperrors: web service errors toolkit
    • i18n: Localization toolkit
    • image: glance service code
      • drivers: Storage driver
    • keystone: keystone service code, mainly authentication and user management
    • lbagent: Load balancer agent code
    • logger: Log service
    • mcclient: Common client code for backend services
      • auth: Authentication related
      • informer: model subscription notifications
      • modules: Each resource corresponds to one module
      • options: Request structs, currently mainly called by climc
    • monitor: Monitoring service
    • multicloud: Multi-cloud management, code for managing various clouds, implementing resource interfaces defined by cloudpods
      • aliyun: Aliyun management
        • shell: Each cloud will implement a command-line tool for easy debugging, corresponding to cmd/aliyuncli
    • notify: Notification service
      • rpc: rpc module of notification service, used to call notify-plugins component
    • proxy: Proxy code called by web framework
    • s3gateway: s3 gateway service
    • scheduler: Scheduler service
      • algorithm: Two major steps of scheduling
        • predicates: Filter hosts
        • priorities: Score hosts
      • algorithmprovider: Enable those predicates and priorities
      • api: API data structures
      • cache: Host cache, host information will be cached to improve scheduling efficiency
      • core: Core code, mainly scheduling implementation
      • test: Scheduler test code
        • mock: mock tests
    • util: Toolkit
      • alipayclient: Alipay client
      • ansible: ansible toolkit
      • ansiblev2: ansible toolkit v2
      • atexit: web framework code
      • billing: Billing tools
      • bitmap: Bitmap
      • cephutils: cepu storage
      • cgrouputils: Ccroup
      • choices: Option parameters in command-line tools
      • fileutils2: File operation toolkit
      • fuseutils: fuse toolkit
      • gin: web framework gin
      • httputils: http toolkit, mainly used to construct clients
      • imagetools: Image tools
      • influxdb: influxdb
      • logclient: Log client, service resource operations can record logs through this
      • qemuimg: Toolkit for calling qemu-img
      • qemutils: qemu toolkit
      • rbacutils: rbac authentication toolkit
      • regutils2: Regular expression toolkit
      • s3auth: s3 authentication
      • vmdkutils: vmware vmdk toolkit
    • vpcagent: vpc agent service, implements vpc functionality for private clouds
    • webconsole: webconsole service, for example vnc interface
    • yunionconf: Configuration service
  • scripts: Various scripts used in development
    • gencopyright.sh: Generate copyright
    • cherry_pick_pull.sh: Most commonly used, cherry pick PR to other branches

Frontend Code Structure

  • containers: Functional modules (corresponding to first-level menus)
    • Dashboard: Control panel
      • components: Components within the module
      • extends: Directory of different types of tiles for the control panel
      • locales: Internationalization (control panel part)
      • router: Routing
      • sections: Business components used when configuring tiles
      • styles: Style files
      • utils: Utility methods
      • views: Page display files
    • Cloudenv: Multi-cloud management
      • contants: Constants within the module
      • locales: Internationalization (current module part)
      • router: Routing (current module part)
      • sections: Business components
      • utils: Utility methods
      • views: Module pages (corresponding to second-level menus)
        • cloudaccount: Module name
          • components: Component directory, where List.vue is the list page of the current second-level menu module
          • create: Create related pages
          • dialogs: Dialog components
          • mixins: Provide mixins used by current module list, details, create, dialogs, etc. Common ones are singleAction.js (list single-row action buttons) and columns.js (define list table headers)
          • sidepage: Sidebar components including but not limited to detail pages
          • utils: Utility methods
          • index.vue: Entry file of the current module
    • Compute: Host
      • Code structure of the following modules is the same as multi-cloud management
    • DB: Database
    • Helm: Operations tools
    • IAM: Authentication and security
    • K8S: Container
    • Middleware: Middleware
    • Monitor: Monitoring
    • Network: Network
    • Storage: Storage
  • mock: API management (for testing)
  • public:
  • scope: Authorization related
    • assets: Store global custom icons
    • router: Routing (login authorization part)
    • store: State management (login authorization part)
  • scripts: Executable scripts
  • src: Source code directory
    • assets: Static resources
    • components: Global common components (can be used directly without importing)
    • config: Configuration, including plugins, themes, languages, channels, etc.
    • constants: Global constants, including multi-cloud types, global search, color configuration, monitoring, etc.
    • layouts: Page layout related components
    • locales: Internationalization (global)
    • mixins: Global mixin
    • plugins: Plugin directory
    • router: Global routing (including routes in scope and containers)
    • sections: Global business components
    • store: Global state management
    • styles: Styles
    • tools: Includes internationalization plugins
    • utils: Global utility methods (http, form validation, lists, echart, storage, authorization, error, etc.)
    • views: Pages (user information, ticket information, global search, email verification, etc.)
  • tests: Test file directory
  • upload: Build and release process configuration
  • .env.development: Development environment variables
  • .env.production: Production environment variables
  • .gitignore: Git ignore file
  • package.json: npm package configuration file
  • package-lock.json: npm package version lock file
  • yarn.lock: npm package version lock file
  • vue.config.js: Vue configuration file
  • README.md: Project introduction
  • .eslintrc.js: ESlint configuration file
  • .travirs.yml: Travis CI configuration file
  • babel.config.js: Babel configuration file
  • Dockerfile: Build image file
  • jest.config.js: Unit test configuration file