├── etc └── .keep ├── .dockerignore ├── .perltidyrc ├── .perlcriticrc ├── docs ├── .gitignore ├── validation │ ├── BaseValidation.md │ └── TestingValidations.md ├── images │ ├── devices.png │ ├── joyent.png │ ├── roles.png │ ├── full-schema.png │ ├── validations.png │ └── device-locations.png ├── versions │ ├── v2 │ │ ├── joyent.png │ │ ├── modules │ │ │ ├── Conch::Validation::CpuCount.md │ │ │ ├── Conch::Validation::DimmMap.md │ │ │ ├── Conch::Validation::HddSize.md │ │ │ ├── Conch::Validation::LinksUp.md │ │ │ ├── Conch::Validation::NicsNum.md │ │ │ ├── Conch::Validation::RamTotal.md │ │ │ ├── Conch::Validation::SlogSlot.md │ │ │ ├── Conch::Validation::DimmCount.md │ │ │ ├── Conch::Validation::NvmeSsdNum.md │ │ │ ├── Conch::Validation::RaidLunNum.md │ │ │ ├── Conch::Validation::SasHddNum.md │ │ │ ├── Conch::Validation::SasSsdNum.md │ │ │ ├── Conch::Validation::SataHddNum.md │ │ │ ├── Conch::Validation::SataSsdNum.md │ │ │ ├── Conch::Validation::SwitchPeers.md │ │ │ ├── Conch::Validation::UsbHddNum.md │ │ │ ├── Conch::Validation::CpuTemperature.md │ │ │ ├── Conch::Validation::DeviceProductName.md │ │ │ ├── Conch::Validation::DiskSmartStatus.md │ │ │ ├── Conch::Validation::DiskTemperature.md │ │ │ ├── Conch::Validation::FirmwareCurrent.md │ │ │ ├── Conch::Validation::BiosFirmwareVersion.md │ │ │ ├── Conch::DB.md │ │ │ ├── Conch::Command::workspaces.md │ │ │ ├── Conch::Command::thin_device_reports.md │ │ │ ├── Conch::DB::Result.md │ │ │ ├── Conch::DB::ResultSet.md │ │ │ ├── Conch::Plugin::Logging.md │ │ │ ├── Conch::Plugin::Features.md │ │ │ ├── Conch::Plugin::GitVersion.md │ │ │ ├── Conch::Command::update_validation_states.md │ │ │ ├── Conch::Command::check_layouts.md │ │ │ ├── Conch::Command::check_validation_plans.md │ │ │ ├── Conch::Command::add_hdd_size_validation.md │ │ │ ├── Conch::Command::insert_validation_states.md │ │ │ ├── Conch::Controller::ValidationState.md │ │ │ ├── Conch::Command::merge_validation_results.md │ │ │ ├── Conch::Command::clean_permissions.md │ │ │ ├── Conch::DB::ToJSON.md │ │ │ ├── Conch::Controller::Relay.md │ │ │ ├── Conch::Controller::DeviceLocation.md │ │ │ ├── Conch::Command::update_validation_plans.md │ │ │ ├── Conch::Route::DeviceReport.md │ │ │ ├── Conch.md │ │ │ ├── Conch::Controller::HardwareVendor.md │ │ │ ├── Conch::Plugin::Rollbar.md │ │ │ ├── Conch::Command::create_user.md │ │ │ ├── Conch::ValidationError.md │ │ │ ├── Conch::Plugin::FindHelpers.md │ │ │ ├── Conch::Controller::RackRole.md │ │ │ ├── Conch::DB::ResultSet::UserWorkspaceRole.md │ │ │ ├── Conch::Controller::Validation.md │ │ │ ├── Conch::DB::ResultSet::DeviceReport.md │ │ │ ├── Conch::Route::Relay.md │ │ │ ├── Conch::DB::Deactivatable.md │ │ │ ├── Conch::DB::Result::Migration.md │ │ │ ├── Conch::DB::InflateColumn::Time.md │ │ │ ├── Conch::DB::ResultSet::ValidationState.md │ │ │ ├── Conch::Plugin::Mail.md │ │ │ ├── Conch::Controller::DatacenterRoom.md │ │ │ ├── Conch::Controller::DeviceInterface.md │ │ │ ├── Conch::Controller::Datacenter.md │ │ │ ├── Conch::Route::HardwareVendor.md │ │ │ ├── Conch::Controller::RackLayout.md │ │ │ ├── Conch::Controller::WorkspaceRelay.md │ │ │ ├── Conch::DB::ResultSet::DeviceLocation.md │ │ │ ├── Conch::DB::ResultSet::Rack.md │ │ │ ├── Conch::Controller::Schema.md │ │ │ ├── Conch::Controller::DeviceSettings.md │ │ │ ├── Conch::DB::ResultSet::DeviceNic.md │ │ │ ├── Conch::DB::AsEpoch.md │ │ │ ├── Conch::Controller::HardwareProduct.md │ │ │ ├── Conch::DB::Result::WorkspaceRack.md │ │ │ ├── Conch::Route::Validation.md │ │ │ ├── Conch::DB::Result::ValidationPlanMember.md │ │ │ ├── Conch::Controller::WorkspaceUser.md │ │ │ ├── Conch::Route::HardwareProduct.md │ │ │ ├── Conch::Controller::ValidationPlan.md │ │ │ ├── Conch::DB::ResultsExist.md │ │ │ ├── Conch::Plugin::AuthHelpers.md │ │ │ ├── Conch::DB::Result::ValidationStateMember.md │ │ │ └── Conch::Controller::DeviceValidation.md │ │ ├── scripts │ │ │ ├── conch.md │ │ │ ├── index.md │ │ │ └── conch-db.md │ │ └── json-schema │ │ │ └── index.md │ └── index.md ├── _config.yml ├── modules │ ├── README │ ├── Conch::Validation::DimmMap.md │ ├── Conch::Validation::HddSize.md │ ├── Conch::Validation::LinksUp.md │ ├── Conch::Validation::NicsNum.md │ ├── Conch::Validation::CpuCount.md │ ├── Conch::Validation::DimmCount.md │ ├── Conch::Validation::NvmeSsdNum.md │ ├── Conch::Validation::RaidLunNum.md │ ├── Conch::Validation::RamTotal.md │ ├── Conch::Validation::SasHddNum.md │ ├── Conch::Validation::SasSsdNum.md │ ├── Conch::Validation::SataHddNum.md │ ├── Conch::Validation::SataSsdNum.md │ ├── Conch::Validation::SlogSlot.md │ ├── Conch::Validation::SwitchPeers.md │ ├── Conch::Validation::UsbHddNum.md │ ├── Conch::Validation::CpuTemperature.md │ ├── Conch::Validation::DeviceProductName.md │ ├── Conch::Validation::DiskSmartStatus.md │ ├── Conch::Validation::DiskTemperature.md │ ├── Conch::Validation::FirmwareCurrent.md │ ├── Conch::Validation::BiosFirmwareVersion.md │ ├── Conch::DB.md │ ├── Conch::Command::check_layouts.md │ ├── Conch::Command::check_validation_plans.md │ ├── Conch::Command::fix_usernames.md │ ├── Conch::Command::create_token.md │ ├── Conch::DB::ResultSet::Organization.md │ ├── Conch::Controller::ValidationState.md │ ├── Conch::Command::update_validation_plans.md │ ├── Conch::Command::passwd.md │ ├── Conch::Command::thin_device_reports.md │ ├── Conch::Command::force_password_change.md │ ├── Conch::DB::InflateColumn::Time.md │ ├── Conch::Plugin::ClientVerification.md │ ├── Conch::Plugin::Features.md │ ├── Conch::DB::Result.md │ ├── Conch::DB::ResultSet::RackLayout.md │ ├── Conch::DB::Helper::Row::ToJSON.md │ ├── Conch::Plugin::DeprecatedAction.md │ ├── Conch::DB::Result::Migration.md │ ├── Conch::ValidationError.md │ ├── Conch::Command::create_user.md │ ├── Conch::Route::ValidationState.md │ ├── Conch::DB::Helper::ResultSet::WithRole.md │ ├── Conch::DB::ResultSet::DeviceReport.md │ ├── Conch::DB::ResultSet::UserAccount.md │ ├── Conch::Plugin::GitVersion.md │ ├── Conch::Controller::HardwareVendor.md │ ├── Conch::DB::ResultSet::ValidationState.md │ ├── Conch::DB::Helper::ResultSet::Deactivatable.md │ ├── Conch::Controller::RackRole.md │ ├── Conch::Command::create_test_validation_results.md │ ├── Conch::Controller::DeviceLocation.md │ ├── Conch::DB::Helper::Row::WithRole.md │ ├── Conch::Plugin::AuthHelpers.md │ ├── Conch::DB::ResultSet::DeviceNic.md │ ├── Conch::Controller::DeviceSettings.md │ └── Conch::DB::Helper::Row::WithPhase.md ├── scripts │ ├── README │ └── index.md ├── Makefile ├── json-schema │ ├── README │ └── index.md ├── Gemfile ├── README └── _resources │ ├── devices.er │ └── roles.er ├── t ├── lib │ └── Conch │ │ └── Validation │ │ ├── Broken.pm │ │ ├── Empty.pm │ │ ├── WrongParentage.pm │ │ ├── WrongName.pm │ │ ├── WrongVersion.pm │ │ ├── MissingCategory.pm │ │ ├── WrongDescription.pm │ │ ├── LocalException.pm │ │ ├── ExternalException.pm │ │ ├── MutateDevice.pm │ │ └── MultipleResults.pm ├── pod-syntax.t ├── git-version.t ├── git-docs.t ├── integration │ └── removed-endpoints.t ├── validations │ ├── cpu_count_v1.t │ ├── firmware_current_v1.t │ └── bios_firmware_version_v1.t ├── pod-coverage.t └── pod-spelling.t ├── sql ├── migrations │ ├── 0115-device_environment.sql │ ├── 0111-device-state.sql │ ├── 0116-device_disk-temp.sql │ ├── 0117-device_nic-speed.sql │ ├── 0143-drop-organization_workspace_role.sql │ ├── 0170-device_nic-iface_driver.sql │ ├── 0145-user_session_token-ipaddr.sql │ ├── 0122-user_account-last_seen.sql │ ├── 0104-validation_result-component.sql │ ├── 0178-remove-workspaces.sql │ ├── 0118-device_neighbor-want_switch_port.sql │ ├── 0124-datacenter-uniqueness.sql │ ├── 0113-device-deactivated.sql │ ├── 0137-user_account-unique-name.sql │ ├── 0146-drop-validation_state-completed.sql │ ├── 0136-user_account-email-ci.sql │ ├── 0100-assert-safe-for-v3.sql │ ├── 0112-device-graduated.sql │ ├── 0186-hardware_product-unused-columns.sql │ ├── 0101-migration-table.sql │ ├── 0138-rack-unique-name-in-room.sql │ ├── 0148-device-links-remove.sql │ ├── 0150-validation_state_member-all-columns-unique.sql │ ├── 0107-user_workspace_role_unique.sql │ ├── 0114-device_report-drop-invalid.sql │ ├── 0125-user_workspace_role-is_admin.sql │ ├── 0132-hardware_product-sku.sql │ ├── 0179-hardware_product-specification-not-null.sql │ ├── 0127-user-and-device_setting.sql │ ├── 0142-datacenter_room-vendor_name.sql │ ├── 0177-remove-validation_state-validation_plan_id.sql │ ├── 0172-build-rack-links.sql │ ├── 0121-user_account-password.sql │ ├── 0130-validation_result-cascade-delete.sql │ ├── 0119-device-links.sql │ ├── 0134-build-constraints.sql │ ├── 0120-user_session_token-id-is-uuid.sql │ ├── 0176-build-completed_status.sql │ ├── 0123-better-indexes.sql │ ├── 0185-hardware_product-json_schema.sql │ ├── 0175-missing-indexes.sql │ ├── 0141-user_relay_connection.sql │ ├── 0149-validation_state_member-result_order-resequence.sql │ ├── 0110-device-triton.sql │ ├── 0180-json_schema.sql │ ├── 0105-hardware_product-rack_size.sql │ ├── 0174-truncate-workspaces.sql │ ├── 0106-integer-constraints.sql │ ├── 0144-validation_result-unique-constraint.sql │ ├── 0126-relay-last_seen.sql │ ├── 0128-organizations.sql │ └── 0131-builds.sql └── run_migrations.sh ├── dev ├── sql │ ├── make-dev-user.sh │ ├── 01-dev-user.sql │ └── reset-database.sh ├── Makefile └── README.md ├── templates └── email │ ├── build_user_remove_user.txt.ep │ ├── build_user_add_user.txt.ep │ ├── build_user_update_user.txt.ep │ ├── organization_user_remove_user.txt.ep │ ├── organization_user_add_user.txt.ep │ ├── organization_user_update_user.txt.ep │ ├── build_organization_remove_members.txt.ep │ ├── build_organization_add_members.txt.ep │ ├── build_organization_remove_admins.txt.ep │ ├── build_user_remove_admins.txt.ep │ ├── build_organization_update_members.txt.ep │ ├── build_organization_add_admins.txt.ep │ ├── build_user_add_admins.txt.ep │ ├── organization_user_remove_admins.txt.ep │ ├── build_organization_update_admins.txt.ep │ ├── updated_user_account.txt.ep │ ├── organization_user_add_admins.txt.ep │ ├── revoked_user_tokens.txt.ep │ ├── build_user_update_admins.txt.ep │ ├── organization_user_update_admins.txt.ep │ ├── changed_user_password.txt.ep │ └── new_user_account.txt.ep ├── docker ├── dev_test.bash ├── builder.sh ├── buildbot-release.bash ├── buildbot-prerelease.bash └── compose.yml.dist ├── .gitignore ├── CODEOWNERS ├── misc └── update-schema-diagrams ├── report └── bin │ ├── upload_dir_to_manta.sh │ └── start_manta_job.sh ├── .mailmap ├── .gitattributes ├── lib └── Conch │ ├── Validation │ ├── CpuCount.pm │ ├── BiosFirmwareVersion.pm │ ├── NicsNum.pm │ ├── DimmCount.pm │ ├── UsbHddNum.pm │ ├── RamTotal.pm │ ├── FirmwareCurrent.pm │ ├── SasHddNum.pm │ ├── NvmeSsdNum.pm │ ├── RaidLunNum.pm │ ├── SataHddNum.pm │ ├── LinksUp.pm │ └── SasSsdNum.pm │ ├── DB │ ├── Helper │ │ └── Row │ │ │ └── ToJSON.pm │ └── Result.pm │ ├── ValidationError.pm │ ├── Plugin │ └── Features.pm │ └── Route │ └── ValidationState.pm ├── schema-loader.yaml ├── Dockerfile.dev ├── Dockerfile └── docker-compose.yml /etc/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | local 2 | postgres 3 | -------------------------------------------------------------------------------- /.perltidyrc: -------------------------------------------------------------------------------- 1 | -b 2 | -i=2 3 | -et=2 4 | -------------------------------------------------------------------------------- /.perlcriticrc: -------------------------------------------------------------------------------- 1 | [-Subroutines::ProhibitSubroutinePrototypes] 2 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | .bundle 2 | vendor 3 | Gemfile.lock 4 | _site 5 | -------------------------------------------------------------------------------- /docs/validation/BaseValidation.md: -------------------------------------------------------------------------------- 1 | ../modules/Conch::Validation.md -------------------------------------------------------------------------------- /docs/validation/TestingValidations.md: -------------------------------------------------------------------------------- 1 | ../modules/Test::Conch::Validation.md -------------------------------------------------------------------------------- /docs/images/devices.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/devices.png -------------------------------------------------------------------------------- /docs/images/joyent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/joyent.png -------------------------------------------------------------------------------- /docs/images/roles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/roles.png -------------------------------------------------------------------------------- /docs/images/full-schema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/full-schema.png -------------------------------------------------------------------------------- /docs/images/validations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/validations.png -------------------------------------------------------------------------------- /docs/versions/v2/joyent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/versions/v2/joyent.png -------------------------------------------------------------------------------- /t/lib/Conch/Validation/Broken.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::Broken; 2 | sub foo { # oops, file is corrupted! 3 | -------------------------------------------------------------------------------- /docs/images/device-locations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joyent/conch-api/HEAD/docs/images/device-locations.png -------------------------------------------------------------------------------- /t/lib/Conch/Validation/Empty.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::Empty; 2 | use Mojo::Base -base, 'Conch::Validation'; 3 | 1; 4 | -------------------------------------------------------------------------------- /sql/migrations/0115-device_environment.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(115, $$ 2 | 3 | drop table device_environment; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0111-device-state.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(111, $$ 2 | 3 | alter table device drop column state; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0116-device_disk-temp.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(116, $$ 2 | 3 | alter table device_disk drop column temp; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0117-device_nic-speed.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(117, $$ 2 | 3 | alter table device_nic drop column speed; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/WrongParentage.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::WrongParentage; 2 | # I'm just a poor boy from a poor family 3 | 1; 4 | -------------------------------------------------------------------------------- /sql/migrations/0143-drop-organization_workspace_role.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(143, $$ 2 | 3 | drop table organization_workspace_role; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0170-device_nic-iface_driver.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(170, $$ 2 | 3 | alter table device_nic drop column iface_driver; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /dev/sql/make-dev-user.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | PSQL="psql -A -U conch -d conch" 4 | BASEDIR=$(cd `dirname $0` && pwd) 5 | 6 | $PSQL < $BASEDIR/01-dev-user.sql 7 | -------------------------------------------------------------------------------- /sql/migrations/0145-user_session_token-ipaddr.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(145, $$ 2 | 3 | alter table user_session_token add column last_ipaddr inet; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0122-user_account-last_seen.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(122, $$ 2 | 3 | alter table user_account add column last_seen timestamp with time zone; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /sql/migrations/0104-validation_result-component.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(104, $$ 2 | 3 | alter table validation_result rename column component_id to component; 4 | 5 | $$); 6 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | title: Conch API 2 | logo: images/joyent.png 3 | show_downloads: true 4 | 5 | exclude: 6 | - vendor 7 | - .git 8 | 9 | theme: jekyll-theme-minimal 10 | -------------------------------------------------------------------------------- /docs/modules/README: -------------------------------------------------------------------------------- 1 | This directory and its contents are automatically generated by misc/pod2githubpages. 2 | DO NOT manually edit these files, but rather the sources they were generated from. 3 | -------------------------------------------------------------------------------- /docs/scripts/README: -------------------------------------------------------------------------------- 1 | This directory and its contents are automatically generated by misc/pod2githubpages. 2 | DO NOT manually edit these files, but rather the sources they were generated from. 3 | -------------------------------------------------------------------------------- /sql/migrations/0178-remove-workspaces.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(178, $$ 2 | 3 | drop table workspace_rack; 4 | drop table user_workspace_role; 5 | drop table workspace; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | default: vendor serve 2 | 3 | build: 4 | bundle exec jekyll build 5 | 6 | serve: 7 | bundle exec jekyll serve 8 | 9 | vendor: 10 | bundle install --path vendor/bundle 11 | -------------------------------------------------------------------------------- /docs/json-schema/README: -------------------------------------------------------------------------------- 1 | This directory and its contents are automatically generated by misc/pod2githubpages. 2 | DO NOT manually edit these files, but rather the sources they were generated from. 3 | -------------------------------------------------------------------------------- /templates/email/build_user_remove_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | You have been removed from the "<%= $build %>" build at Joyent Conch (https://<%= host %>). 4 | 5 | Thank you, 6 | Joyent Build Ops Team 7 | -------------------------------------------------------------------------------- /dev/sql/01-dev-user.sql: -------------------------------------------------------------------------------- 1 | begin; 2 | insert into user_account(name, email, password) values('conch','conch@conch.joyent.us','$2a$04$h963P26i4rTMaVogvA2U7ePcZTYm2o0gfSHyxaUCZSuthkpg47Zbi'); 3 | 4 | commit; 5 | -------------------------------------------------------------------------------- /dev/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: database all 2 | 3 | all: deps database 4 | 5 | ../local: 6 | cd .. && make local 7 | 8 | deps: ../local 9 | 10 | database: 11 | sql/reset-database.sh 12 | sql/make-dev-user.sh 13 | -------------------------------------------------------------------------------- /sql/migrations/0118-device_neighbor-want_switch_port.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(118, $$ 2 | 3 | alter table device_neighbor 4 | drop column want_switch, 5 | drop column want_port; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gem 'bundler', '>=1.17.3' 3 | gem 'ffi', '1.10.0' # avoid 1.11.1 - https://github.com/ffi/ffi/issues/702 4 | gem "jekyll" 5 | gem "github-pages", group: :jekyll_plugins 6 | -------------------------------------------------------------------------------- /sql/migrations/0124-datacenter-uniqueness.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(124, $$ 2 | 3 | alter table datacenter add constraint datacenter_vendor_region_location_key 4 | unique (vendor, region, location); 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /templates/email/build_user_add_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | You have been added to the "<%= $build %>" build at Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 4 | 5 | Thank you, 6 | Joyent Build Ops Team 7 | -------------------------------------------------------------------------------- /templates/email/build_user_update_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your access to the "<%= $build %>" build at Joyent Conch (https://<%= host %>) has been adjusted to "<%= $role %>". 4 | 5 | Thank you, 6 | Joyent Build Ops Team 7 | -------------------------------------------------------------------------------- /templates/email/organization_user_remove_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | You have been removed from the "<%= $organization %>" organization 4 | at Joyent Conch (https://<%= host %>). 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0113-device-deactivated.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(113, $$ 2 | 3 | update device set phase = 'decommissioned' where deactivated is not null; 4 | 5 | alter table device drop column deactivated; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/WrongName.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::WrongName; 2 | use Mojo::Base 'Conch::Validation'; 3 | sub version { 1 } 4 | sub name { 'WRONG NAME' } 5 | sub description { 'validation with wrong name' } 6 | 1; 7 | -------------------------------------------------------------------------------- /t/pod-syntax.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Pod 1.41; 6 | 7 | subtest all_pod_files_ok => sub { 8 | all_pod_files_ok(); 9 | }; 10 | 11 | done_testing; 12 | -------------------------------------------------------------------------------- /sql/migrations/0137-user_account-unique-name.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(137, $$ 2 | 3 | drop index user_account_name_key; 4 | create unique index user_account_name_key on user_account (name) where deactivated is null; 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/WrongVersion.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::WrongVersion; 2 | use Mojo::Base 'Conch::Validation'; 3 | sub version { 2 } 4 | sub name { 'wrong version' } 5 | sub description { 'validation with wrong version' } 6 | 1; 7 | -------------------------------------------------------------------------------- /sql/migrations/0146-drop-validation_state-completed.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(146, $$ 2 | 3 | update validation_state set created = greatest(created, completed); 4 | 5 | alter table validation_state drop column completed; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/MissingCategory.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::MissingCategory; 2 | use Mojo::Base 'Conch::Validation'; 3 | sub version { 1 } 4 | sub name { 'missing category' } 5 | sub description { 'validation with missing category' } 6 | 1; 7 | -------------------------------------------------------------------------------- /templates/email/organization_user_add_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | You have been added to the "<%= $organization %>" organization at 4 | Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /templates/email/organization_user_update_user.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your access to the "<%= $organization %>" organization at 4 | Joyent Conch (https://<%= host %>) has been adjusted to "<%= $role %>". 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /templates/email/build_organization_remove_members.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your "<%= $organization %>" organization has been removed from the 4 | "<%= $build %>" build at Joyent Conch (https://<%= host %>). 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0136-user_account-email-ci.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(136, $$ 2 | 3 | drop index user_account_email_key; 4 | create unique index user_account_email_key 5 | on user_account (lower(email)) where deactivated is null; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /sql/migrations/0100-assert-safe-for-v3.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(100, $$ 2 | 3 | do $inner$ begin 4 | assert (select max(id) from migration) = 95, 'not all v2 migrations have been run; cannot proceed with v3 upgrade'; 5 | end; $inner$; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /sql/migrations/0112-device-graduated.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(112, $$ 2 | 3 | update device set phase = 'production', updated = now() 4 | where graduated is not null and phase < 'production'; 5 | 6 | alter table device drop column graduated; 7 | 8 | $$); 9 | -------------------------------------------------------------------------------- /sql/migrations/0186-hardware_product-unused-columns.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(186, $$ 2 | 3 | alter table hardware_product alter column cpu_type drop not null; 4 | update hardware_product set cpu_type = null where cpu_type = '' or cpu_type = 'unknown'; 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/WrongDescription.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::WrongDescription; 2 | use Mojo::Base 'Conch::Validation'; 3 | sub version { 1 } 4 | sub name { 'wrong description' } 5 | sub description { 'this does not match \'description\' in the database' } 6 | 1; 7 | -------------------------------------------------------------------------------- /templates/email/build_organization_add_members.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your "<%= $organization %>" organization has been added to the 4 | "<%= $build %>" build at Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0101-migration-table.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(101, $$ 2 | 3 | -- migration numbers are always manually selected; this sequence serves no purpose. 4 | alter table migration alter column id drop default; 5 | drop sequence migration_id_seq; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /templates/email/build_organization_remove_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) removed the "<%= $organization %>" 4 | organization from the "<%= $build %>" build at Joyent Conch (https://<%= host %>). 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | Yeah, there's ruby stuff in here. You can ignore every bit of it unless you'd 2 | like to preview changes locally. 3 | 4 | If you do, install ruby's bundler via your OS's packages and run 'make vendor' 5 | and then 'make serve'. hit up http://localhost:4000 and preview away 6 | -------------------------------------------------------------------------------- /sql/migrations/0138-rack-unique-name-in-room.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(138, $$ 2 | 3 | alter table rack drop constraint if exists rack_datacenter_room_id_name_key; 4 | alter table rack add constraint rack_datacenter_room_id_name_key unique (datacenter_room_id, name); 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /sql/migrations/0148-device-links-remove.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(148, $$ 2 | 3 | create function array_subtract(anyarray, anyarray) returns anyarray as $f$ 4 | select array(select unnest($1) except select unnest($2) order by 1); 5 | $f$ language sql immutable; 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /templates/email/build_user_remove_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) removed <%= $target_user->name %> (<%= $target_user->email %>) from the 4 | "<%= $build %>" build at Joyent Conch (https://<%= host %>). 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0150-validation_state_member-all-columns-unique.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(150, $$ 2 | 3 | alter table validation_state_member 4 | add constraint validation_state_member_validation_state_id_result_order_key unique (validation_state_id, result_order); 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /templates/email/build_organization_update_members.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your access to the "<%= $build %>" build at Joyent Conch (https://<%= host %>) 4 | via the "<%= $organization %>" organization has been adjusted to the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0107-user_workspace_role_unique.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(107, $$ 2 | 3 | -- this constraint serves no purpose. the primary key already covers this. 4 | alter table user_workspace_role drop constraint if exists user_workspace_role_user_id_workspace_id_role_key; 5 | 6 | $$); 7 | -------------------------------------------------------------------------------- /sql/migrations/0114-device_report-drop-invalid.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(114, $$ 2 | 3 | delete from device_report where invalid_report is not null; 4 | 5 | alter table device_report 6 | drop column invalid_report, 7 | alter column report set not null; 8 | 9 | $$); 10 | -------------------------------------------------------------------------------- /templates/email/build_organization_add_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) added the "<%= $organization %>" organization to the 4 | "<%= $build %>" build at Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /templates/email/build_user_add_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) added <%= $target_user->name %> (<%= $target_user->email %>) to the 4 | "<%= $build %>" build at Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /templates/email/organization_user_remove_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) removed <%= $target_user->name %> (<%= $target_user->email %>) from the 4 | "<%= $organization %>" organization at Joyent Conch (https://<%= host %>). 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0125-user_workspace_role-is_admin.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(125, $$ 2 | 3 | delete from user_workspace_role 4 | using user_account 5 | where 6 | user_account.id = user_workspace_role.user_id 7 | and user_account.is_admin is true; 8 | 9 | $$); 10 | -------------------------------------------------------------------------------- /templates/email/build_organization_update_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) modified the "<%= $organization %>" organization's 4 | access to the "<%= $build %>" build at Joyent Conch (https://<%= host %>) to the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /sql/migrations/0132-hardware_product-sku.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(132, $$ 2 | 3 | update hardware_product 4 | set sku = 'placeholder-missing-sku-' || legacy_product_name 5 | where sku is null or sku = ''; 6 | 7 | alter table hardware_product alter column sku set not null; 8 | 9 | $$); 10 | -------------------------------------------------------------------------------- /sql/migrations/0179-hardware_product-specification-not-null.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(179, $$ 2 | 3 | update hardware_product set specification = '{}' where specification is null; 4 | 5 | alter table hardware_product alter column specification set default '{}', 6 | alter column specification set not null; 7 | 8 | $$); 9 | -------------------------------------------------------------------------------- /templates/email/updated_user_account.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your account at Joyent Conch (https://<%= host %>) has been updated: 4 | 5 | <%== 6 | sprintf("%12s: %s -> %s\n", $_, $orig_data->{$_}, $new_data->{$_}) 7 | foreach sort keys $new_data->%* 8 | %>\ 9 | 10 | Thank you, 11 | Joyent Build Ops Team 12 | -------------------------------------------------------------------------------- /templates/email/organization_user_add_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) added <%= $target_user->name %> (<%= $target_user->email %>) to the 4 | "<%= $organization %>" organization at Joyent Conch (https://<%= host %>) with the "<%= $role %>" role. 5 | 6 | Thank you, 7 | Joyent Build Ops Team 8 | -------------------------------------------------------------------------------- /templates/email/revoked_user_tokens.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | The following tokens at Joyent Conch (https://<%= host %>) have been reset: 4 | 5 | <%= join("\n", map ' '.$_, $token_names->@*) %> 6 | 7 | You should now log into https://<%= host %> using your login credentials. 8 | 9 | Thank you, 10 | Joyent Build Ops Team 11 | -------------------------------------------------------------------------------- /docker/dev_test.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | : ${PREFIX:=$USER} 3 | 4 | docker volume create ${PREFIX}-api-test-carton 5 | PREFIX=${PREFIX} docker/builder.sh --file Dockerfile.dev . 6 | 7 | docker run \ 8 | --mount type=volume,src=${PREFIX}-api-test-carton,dst=/app/conch/local \ 9 | --rm \ 10 | ${PREFIX}/conch-api 11 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::CpuCount.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::DimmMap.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::HddSize.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::LinksUp.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::NicsNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::RamTotal.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SlogSlot.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::DimmCount.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::NvmeSsdNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::RaidLunNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SasHddNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SasSsdNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SataHddNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SataSsdNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::SwitchPeers.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::UsbHddNum.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /templates/email/build_user_update_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) modified a user's access to your build 4 | "<%= $build %>" at Joyent Conch (https://<%= host %>). 5 | <%= $target_user->name %> (<%= $target_user->email %>) now has the "<%= $role %>" role. 6 | 7 | Thank you, 8 | Joyent Build Ops Team 9 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::DimmMap.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::HddSize.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::LinksUp.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::NicsNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::CpuTemperature.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::DeviceProductName.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::DiskSmartStatus.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::DiskTemperature.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::FirmwareCurrent.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::CpuCount.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::DimmCount.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::NvmeSsdNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::RaidLunNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::RamTotal.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SasHddNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SasSsdNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SataHddNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SataSsdNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SlogSlot.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::SwitchPeers.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::UsbHddNum.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Validation::BiosFirmwareVersion.md: -------------------------------------------------------------------------------- 1 | # LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /sql/migrations/0127-user-and-device_setting.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(127, $$ 2 | 3 | alter table device_setting 4 | alter column value type text, 5 | alter column value set not null; 6 | 7 | alter table user_setting 8 | alter column value type text, 9 | alter column value set not null; 10 | 11 | $$); 12 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::CpuTemperature.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::DeviceProductName.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::DiskSmartStatus.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::DiskTemperature.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::FirmwareCurrent.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Temporary, backup, dependency, and object files 2 | *.swp 3 | *.tmp 4 | *.bak 5 | tags 6 | .lvimrc 7 | .agignore 8 | .DS_Store 9 | .ackrc 10 | .vimlocal 11 | 12 | # Conch 13 | /conch.conf 14 | /log 15 | /bin/hypnotoad.pid 16 | /nytprof 17 | /nytprof.log 18 | /local/ 19 | /local* 20 | 21 | # used by the docker-compose file 22 | /postgres 23 | -------------------------------------------------------------------------------- /docs/modules/Conch::Validation::BiosFirmwareVersion.md: -------------------------------------------------------------------------------- 1 | ## LICENSING 2 | 3 | Copyright Joyent, Inc. 4 | 5 | This Source Code Form is subject to the terms of the Mozilla Public License, 6 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 7 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 8 | -------------------------------------------------------------------------------- /templates/email/organization_user_update_admins.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | <%= $user->name %> (<%= $user->email %>) modified a user's access to your organization 4 | "<%= $organization %>" at Joyent Conch (https://<%= host %>). 5 | <%= $target_user->name %> (<%= $target_user->email %>) now has the "<%= $role %>" role. 6 | 7 | Thank you, 8 | Joyent Build Ops Team 9 | -------------------------------------------------------------------------------- /sql/migrations/0142-datacenter_room-vendor_name.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(142, $$ 2 | 3 | alter table datacenter_room drop constraint if exists datacenter_room_vendor_name_key; 4 | alter table datacenter_room alter column vendor_name set not null; 5 | alter table datacenter_room add constraint datacenter_room_vendor_name_key unique (vendor_name); 6 | 7 | $$); 8 | -------------------------------------------------------------------------------- /sql/migrations/0177-remove-validation_state-validation_plan_id.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(177, $$ 2 | 3 | -- this is redundant information that serves no real purpose. 4 | -- individual validation results (and their validation_ids) are already 5 | -- associated with a validation_state. 6 | alter table validation_state drop column validation_plan_id; 7 | 8 | $$); 9 | -------------------------------------------------------------------------------- /sql/migrations/0172-build-rack-links.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(172, $$ 2 | 3 | alter table build add column links text[] not null default '{}'; 4 | create index build_links_idx on build using gin (links); 5 | 6 | alter table rack add column links text[] not null default '{}'; 7 | create index rack_links_idx on rack using gin (links); 8 | 9 | $$); 10 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # docs: https://help.github.com/en/articles/about-code-owners 2 | # 3 | # An important note is that precedence matters. For instance, @karenetheridge 4 | # is marked to own everything. If a later line only contains '@billybob', then 5 | # only billybob will get an automated review request and only billybob will be 6 | # required to sign off. 7 | 8 | * @karenetheridge 9 | -------------------------------------------------------------------------------- /sql/migrations/0121-user_account-password.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(121, $$ 2 | 3 | -- remove all the legacy leading '{CRYPT}' from password_hash. 4 | update user_account 5 | set password_hash = substr(password_hash, 8) 6 | where password_hash like '{CRYPT}%'; 7 | 8 | alter table user_account rename column password_hash to password; 9 | 10 | $$); 11 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/LocalException.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::LocalException; 2 | 3 | use Mojo::Base 'Conch::Validation', -signatures; 4 | 5 | sub version { 1 } 6 | sub name { 'local_exception' } 7 | sub description { 'my description' } 8 | sub category { 'exception' } 9 | 10 | sub validate ($self, $data) { 11 | die 'I did something dumb'; 12 | } 13 | 14 | 1; 15 | -------------------------------------------------------------------------------- /docker/builder.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | : ${PREFIX:="joyent"} 4 | : ${LABEL:="latest"} 5 | 6 | TAG=`git describe` 7 | HASH=`git rev-parse HEAD` 8 | 9 | LABEL=$(echo "${LABEL}" | sed 's/\//_/g') 10 | 11 | docker build \ 12 | --force-rm \ 13 | -t ${PREFIX}/conch-api:${LABEL} \ 14 | --build-arg VERSION=${TAG} \ 15 | --build-arg VCS_REF=${HASH} \ 16 | $@ 17 | -------------------------------------------------------------------------------- /sql/migrations/0130-validation_result-cascade-delete.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(130, $$ 2 | 3 | alter table validation_state_member 4 | drop constraint validation_state_member_validation_result_id_fkey, 5 | add constraint validation_state_member_validation_result_id_fkey 6 | foreign key (validation_result_id) references validation_result (id) on delete cascade; 7 | 8 | $$); 9 | -------------------------------------------------------------------------------- /misc/update-schema-diagrams: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | use strict; 3 | use warnings; 4 | use Path::Tiny; 5 | 6 | foreach my $file (glob('docs/_resources/*.er')) { 7 | # erd -f png -i docs/_resources/full-schema.er > docs/images/full-schema.png 8 | my $command = 'erd -f png -i '.$file.' > docs/images/'.(path($file)->basename =~ s/er$/png/r); 9 | print $command, "\n"; 10 | system($command); 11 | } 12 | -------------------------------------------------------------------------------- /report/bin/upload_dir_to_manta.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | test $1 || (echo 'Must specify local directory to upload' && exit 1) 4 | 5 | dir=$1; 6 | name=$(basename $dir); 7 | test -d $dir || (echo "Directory '$dir' does not exist" && exit 1); 8 | 9 | tar -czf - $dir | mput "~~/stor/$name.tar.gz" 10 | 11 | echo "~~/stor/$name.tar.gz" | mjob create -o -m gzcat -m 'muntar -f $MANTA_INPUT_FILE ~~/stor/' 12 | -------------------------------------------------------------------------------- /sql/run_migrations.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | IFS=$'\n\t' 4 | 5 | BASEDIR=$(cd `dirname "$0"` && pwd) 6 | DATABASE="${1:-conch}" 7 | 8 | date "+%Y-%m-%d %T" 9 | for migration in $(ls $BASEDIR/migrations | sort); do 10 | echo $BASEDIR/migrations/$migration 11 | psql -U conch $DATABASE -v ON_ERROR_STOP=1 -f $BASEDIR/migrations/$migration; 12 | date "+%Y-%m-%d %T" 13 | done 14 | -------------------------------------------------------------------------------- /docs/versions/index.md: -------------------------------------------------------------------------------- 1 | # Documentation for Conch API by version 2 | 3 | * [Version 2.x](v2/) 4 | * [Version 3.0](../) 5 | 6 | 7 | # Copyright / License 8 | 9 | Copyright Joyent, Inc. 10 | 11 | This Source Code Form is subject to the terms of the Mozilla Public License, 12 | v.2.0. If a copy of the MPL was not distributed with this file, you can 13 | obtain one at . 14 | -------------------------------------------------------------------------------- /t/git-version.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Conch; 6 | 7 | my $t = Test::Conch->new(pg => undef); 8 | 9 | like($t->app->version_tag, qr/^v\d+\.\d+(?:\.\d+(.*))?-\d+-g[[:xdigit:]]+$/, 'got the version tag'); 10 | 11 | like($t->app->version_hash, qr/^[[:xdigit:]]+$/, 'got the version hash'); 12 | 13 | done_testing; 14 | # vim: set sts=2 sw=2 et : 15 | -------------------------------------------------------------------------------- /docs/versions/v2/scripts/conch.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | conch 4 | 5 | # DESCRIPTION 6 | 7 | Start script for conch Mojo app 8 | 9 | # LICENSING 10 | 11 | Copyright Joyent, Inc. 12 | 13 | This Source Code Form is subject to the terms of the Mozilla Public License, 14 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 15 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 16 | -------------------------------------------------------------------------------- /docker/buildbot-release.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | : ${PREFIX:="joyentbuildops"} 4 | : ${LABEL:="latest"} 5 | : ${BUILDNUMBER:=0} 6 | 7 | LABEL=$(echo "${LABEL}" | sed 's/\//_/g') 8 | PREFIX=${PREFIX} LABEL=${LABEL} docker/builder.sh --no-cache --file Dockerfile . 9 | 10 | docker run \ 11 | --name ${PREFIX}_${BUILDNUMBER} \ 12 | --rm \ 13 | --entrypoint=make \ 14 | ${PREFIX}/conch-api:${LABEL} \ 15 | test 16 | -------------------------------------------------------------------------------- /sql/migrations/0119-device-links.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(119, $$ 2 | 3 | alter table device add column links text[] not null default '{}'; 4 | 5 | create index device_links_idx on device using gin (links); 6 | 7 | create function array_cat_distinct(anyarray, anyarray) returns anyarray as $f$ 8 | select array(select distinct unnest(array_cat($1, $2)) order by 1); 9 | $f$ language sql immutable; 10 | 11 | $$); 12 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html#_mapping_authors 2 | Lane Seppala 3 | sungo 4 | Bryan Horstmann-Allen 5 | Karen Etheridge 6 | Jared Morrow 7 | Dale Ghent 8 | -------------------------------------------------------------------------------- /docs/scripts/index.md: -------------------------------------------------------------------------------- 1 | # Executable documentation (in `bin/`) 2 | 3 | * [conch-db](../scripts/conch-db) 4 | * [conch](../scripts/conch) 5 | 6 | [Back to main index](../) 7 | 8 | # Copyright / License 9 | 10 | Copyright Joyent, Inc. 11 | 12 | This Source Code Form is subject to the terms of the Mozilla Public License, 13 | v.2.0. If a copy of the MPL was not distributed with this file, you can 14 | obtain one at . 15 | -------------------------------------------------------------------------------- /docs/versions/v2/scripts/index.md: -------------------------------------------------------------------------------- 1 | # Executable documentation (in `bin/`) 2 | 3 | * [conch-db](../scripts/conch-db) 4 | * [conch](../scripts/conch) 5 | 6 | [Back to main index](../) 7 | 8 | # Copyright / License 9 | 10 | Copyright Joyent, Inc. 11 | 12 | This Source Code Form is subject to the terms of the Mozilla Public License, 13 | v.2.0. If a copy of the MPL was not distributed with this file, you can 14 | obtain one at . 15 | -------------------------------------------------------------------------------- /sql/migrations/0134-build-constraints.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(134, $$ 2 | 3 | alter table build 4 | add constraint build_completed_iff_started_check check 5 | (completed is null or started is not null); 6 | 7 | alter table build 8 | add constraint build_completed_xnor_completed_user_id_check check 9 | ((completed is null and completed_user_id is null) or (completed is not null and completed_user_id is not null)); 10 | 11 | $$); 12 | -------------------------------------------------------------------------------- /t/git-docs.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::More; 5 | use Test::Warnings; 6 | plan skip_all => 'no .git: cannot check dirty files' if not -d '.git'; 7 | 8 | system(qw(make ghdocs)); 9 | 10 | chomp(my $dirty = `git status --untracked --porcelain docs`); 11 | my @errors = grep /^.[^ ]/, split("\n", $dirty); 12 | 13 | is(@errors, 0, 'no files changed after running "make ghdocs"') 14 | or diag 'files need updating:',"\n",join("\n",@errors); 15 | 16 | done_testing; 17 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB 4 | 5 | # DESCRIPTION 6 | 7 | Base schema class for the Conch application. See [DBIx::Class::Schema](https://metacpan.org/pod/DBIx::Class::Schema). 8 | 9 | # LICENSING 10 | 11 | Copyright Joyent, Inc. 12 | 13 | This Source Code Form is subject to the terms of the Mozilla Public License, 14 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 15 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 16 | -------------------------------------------------------------------------------- /templates/email/changed_user_password.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | Your password at Joyent Conch (https://<%= host %>) has been reset. You should now log 4 | into https://<%= host %> using the credentials below. 5 | 6 | WARNING!!! You will only be able to use this password once, and 7 | must select a new password within 10 minutes after logging in. 8 | 9 | Username: <%= $target_user->name %> 10 | Email: <%= $target_user->email %> 11 | Password: <%= $password %> 12 | 13 | Thank you, 14 | Joyent Build Ops Team 15 | -------------------------------------------------------------------------------- /templates/email/new_user_account.txt.ep: -------------------------------------------------------------------------------- 1 | Hello, 2 | 3 | An account has been created for you in Joyent Conch (https://<%= host %>). 4 | Please log into https://<%= host %> using the temporary password below: 5 | 6 | Username: <%= $target_user->name %> 7 | Email: <%= $target_user->email %> 8 | Password: <%= $password %> 9 | 10 | WARNING!!! You will only be able to use this password once, and 11 | must select a new password within 10 minutes after logging in. 12 | 13 | Thank you, 14 | Joyent Build Ops Team 15 | -------------------------------------------------------------------------------- /sql/migrations/0120-user_session_token-id-is-uuid.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(120, $$ 2 | 3 | -- all existing tokens are invalid since their payload contains 4 | -- discontinued fields, and all application secrets are being rotated out. 5 | delete from user_session_token; 6 | 7 | alter table user_session_token 8 | add column id uuid default gen_random_uuid() not null, 9 | drop constraint user_session_token_pkey, 10 | drop column token_hash, 11 | add primary key (id); 12 | 13 | $$); 14 | -------------------------------------------------------------------------------- /dev/README.md: -------------------------------------------------------------------------------- 1 | Contains tools and scripts and what not to stand up a dev environment. DO NOT 2 | USE THIS IN PROD! 3 | 4 | No really, never use this in prod. 5 | 6 | If you run `make`, the following "great for dev but HORRIBLE for prod things 7 | will happen". (Seriously don't run this in prod.) 8 | 9 | * If the perl dependencies have not been installed, they will be 10 | * The database *will be silently blown away and recreated* 11 | * A dummy admin user named `conch` will be created with the *ultra-secure* 12 | password of 'conch' 13 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::workspaces.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | workspaces - view the workspace hierarchy 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch workspaces [long options...] 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /sql/migrations/0176-build-completed_status.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(176, $$ 2 | 3 | create type completed_status_enum as enum ('failure', 'success'); 4 | alter table build add column completed_status completed_status_enum; 5 | 6 | update build set completed_status = 'success' where completed is not null; 7 | 8 | alter table build 9 | add constraint build_completed_xnor_completed_status_check check 10 | ((completed is null and completed_status is null) or (completed is not null and completed_status is not null)); 11 | 12 | $$); 13 | -------------------------------------------------------------------------------- /sql/migrations/0123-better-indexes.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(123, $$ 2 | 3 | alter table device drop constraint device_serial_number_key; 4 | alter table device add constraint device_serial_number_key 5 | unique (serial_number) deferrable initially immediate; 6 | 7 | alter table device_location drop constraint device_location_rack_id_rack_unit_start_key; 8 | alter table device_location add constraint device_location_rack_id_rack_unit_start_key 9 | unique (rack_id, rack_unit_start) deferrable initially immediate; 10 | 11 | $$); 12 | -------------------------------------------------------------------------------- /sql/migrations/0185-hardware_product-json_schema.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(185, $$ 2 | 3 | create table hardware_product_json_schema ( 4 | hardware_product_id uuid not null references hardware_product (id), 5 | json_schema_id uuid not null references json_schema (id), 6 | added timestamp with time zone default now() not null, 7 | added_user_id uuid not null references user_account (id), 8 | primary key (hardware_product_id, json_schema_id) 9 | ); 10 | 11 | grant select on all tables in schema public to conch_read_only; 12 | 13 | $$); 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pl linguist-language=Perl whitespace=trailing-space,space-before-tab,tab-in-indent 2 | *.pm linguist-language=Perl whitespace=trailing-space,space-before-tab,tab-in-indent 3 | *.t linguist-language=Perl whitespace=trailing-space,space-before-tab,tab-in-indent 4 | Makefile whitespace=trailing-space,space-before-tab,-tab-in-indent 5 | /docker whitespace=trailing-space,space-before-tab,-tab-in-indent 6 | /Dockerfile* whitespace=trailing-space,space-before-tab,-tab-in-indent 7 | sql/schema.sql whitespace=-blank-at-eol,-blank-at-eof,space-before-tab,tab-in-indent 8 | -------------------------------------------------------------------------------- /docker/buildbot-prerelease.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | : ${PREFIX:=$USER} 4 | : ${LABEL:="latest"} 5 | : ${BUILDNUMBER:=0} 6 | 7 | LABEL=$(echo "${LABEL}" | sed 's/\//_/g') 8 | 9 | docker volume create ${PREFIX}-conch-api-carton 10 | 11 | set -euo pipefail 12 | IFS=$'\n\t' 13 | 14 | PREFIX=${PREFIX} LABEL=${LABEL} docker/builder.sh --file Dockerfile.dev . 15 | 16 | docker run \ 17 | --mount type=volume,src=${PREFIX}-conch-api-carton,dst=/app/conch/local \ 18 | --rm \ 19 | --name ${PREFIX}_${BUILDNUMBER} \ 20 | ${PREFIX}/conch-api:${LABEL} 21 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::thin_device_reports.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | thin\_device\_reports - remove unwanted device reports 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch thin_device_reports [long options...] 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Result.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Result 4 | 5 | # DESCRIPTION 6 | 7 | Base class for our result classes, to allow us to add on additional functionality from what is 8 | available in core [DBIx::Class](https://metacpan.org/pod/DBIx::Class). 9 | 10 | # LICENSING 11 | 12 | Copyright Joyent, Inc. 13 | 14 | This Source Code Form is subject to the terms of the Mozilla Public License, 15 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 16 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 17 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet 4 | 5 | # DESCRIPTION 6 | 7 | Base class for our resultsets, to allow us to add on additional functionality from what is 8 | available in core [DBIx::Class](https://metacpan.org/pod/DBIx::Class). 9 | 10 | # LICENSING 11 | 12 | Copyright Joyent, Inc. 13 | 14 | This Source Code Form is subject to the terms of the Mozilla Public License, 15 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 16 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 17 | -------------------------------------------------------------------------------- /dev/sql/reset-database.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(cd `dirname $0` && pwd) 4 | 5 | sudo -u postgres psql -d postgres -c 'DROP DATABASE conch' 6 | sudo -u postgres psql -d postgres -c 'DROP USER conch' 7 | sudo -u postgres psql -d postgres -c 'CREATE ROLE conch LOGIN' 8 | sudo -u postgres psql -d postgres -c 'CREATE DATABASE conch OWNER conch' 9 | sudo -u postgres psql -U postgres -d conch -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";' 10 | sudo -u postgres psql -U postgres -d conch -c 'CREATE EXTENSION IF NOT EXISTS "pgcrypto";' 11 | 12 | $BASEDIR/../../sql/run_migrations.sh 13 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::Logging.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::Logging - Sets up logging for the application 4 | 5 | # METHODS 6 | 7 | ## register 8 | 9 | Initializes the logger object, and sets up hooks in various places to log request data and 10 | process exceptions. 11 | 12 | # LICENSING 13 | 14 | Copyright Joyent, Inc. 15 | 16 | This Source Code Form is subject to the terms of the Mozilla Public License, 17 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 18 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 19 | -------------------------------------------------------------------------------- /docs/versions/v2/scripts/conch-db.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | conch-db - commands to administrate a database 4 | 5 | # SYNOPSIS 6 | 7 | bin/conch-db [long options...] [arguments] 8 | 9 | # DESCRIPTION 10 | 11 | Work with the Conch database. Run `bin/conch-db --help` for a list of options. 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::Features.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::Features - Sets up a helper to access configured features 4 | 5 | ## DESCRIPTION 6 | 7 | Provides the helper sub 'feature' to the app and controllers: 8 | 9 | ``` 10 | if ($c->feature('rollbar') { ... } 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::GitVersion.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::GitVersion 4 | 5 | # DESCRIPTION 6 | 7 | Mojo plugin registering the git version tag and hash for the repository 8 | 9 | # METHODS 10 | 11 | ## register 12 | 13 | Register `version_tag` and `version_hash`. 14 | 15 | # LICENSING 16 | 17 | Copyright Joyent, Inc. 18 | 19 | This Source Code Form is subject to the terms of the Mozilla Public License, 20 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 21 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 22 | -------------------------------------------------------------------------------- /t/integration/removed-endpoints.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | 4 | use Test::Conch; 5 | use Test::More; 6 | use Test::Warnings; 7 | 8 | my $t = Test::Conch->new(pg => undef); 9 | 10 | $t->get_ok('/foo') 11 | ->status_is(404) 12 | ->json_is({ error => 'Route Not Found' }); 13 | 14 | $t->get_ok($_) 15 | ->status_is(404) 16 | ->stash_cmp_deeply('/top_level_path_match', 1) 17 | ->json_is({ error => 'Route Not Found' }) 18 | foreach 19 | '/rack', 20 | '/validation', 21 | '/workspace'; 22 | 23 | done_testing; 24 | # vim: set sts=2 sw=2 et : 25 | -------------------------------------------------------------------------------- /docs/versions/v2/json-schema/index.md: -------------------------------------------------------------------------------- 1 | # JSON Schema documentation (in `json-schema/`) 2 | 3 | * [common](../json-schema/common.json) 4 | * [device_report](../json-schema/device_report.json) 5 | * [input](../json-schema/input.json) 6 | * [response](../json-schema/response.json) 7 | 8 | [Back to main index](../) 9 | 10 | # Copyright / License 11 | 12 | Copyright Joyent, Inc. 13 | 14 | This Source Code Form is subject to the terms of the Mozilla Public License, 15 | v.2.0. If a copy of the MPL was not distributed with this file, you can 16 | obtain one at . 17 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::update_validation_states.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | update\_validation\_states - set validation\_state.device\_report\_id 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch update_validation_states [long options...] 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /sql/migrations/0175-missing-indexes.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(175, $$ 2 | 3 | -- this index was created in migration 109, 4 | -- then removed in migration 135 because it was redundant with 5 | -- validation_state_device_id_validation_plan_id_completed_idx, 6 | -- but then that index was removed in migration 146 and so we also lost the first-column index 7 | -- on device_id as a side effect. 8 | create index validation_state_device_id_idx on validation_state (device_id); 9 | 10 | -- a quick audit of all tables shows no other inadvertent losses of indexes. 11 | 12 | $$); 13 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::check_layouts.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | check\_layouts - check for rack layout conflicts 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch check_layouts [long options...] 9 | 10 | --ws --workspace workspace name 11 | --help print usage message and exit 12 | ``` 13 | 14 | # LICENSING 15 | 16 | Copyright Joyent, Inc. 17 | 18 | This Source Code Form is subject to the terms of the Mozilla Public License, 19 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 20 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 21 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/ExternalException.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::ExternalException; 2 | 3 | use Mojo::Base 'Conch::Validation', -signatures; 4 | use JSON::PP 'decode_json'; 5 | 6 | sub version { 1 } 7 | sub name { 'external exception' } 8 | sub description { 'my description' } 9 | sub category { 'exception' } 10 | 11 | sub validate ($self, $data) { 12 | my $got = decode_json('{"foo'); 13 | $self->register_result( 14 | got => $got, 15 | expected => 'hi', 16 | component => 'x', 17 | hint => 'we should have died before getting here', 18 | ); 19 | } 20 | 21 | 1; 22 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::check_validation_plans.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | check\_validation\_plans - Utility to check all validations and plans are up to date 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch check_validation_plans [long options...] 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docker/compose.yml.dist: -------------------------------------------------------------------------------- 1 | # vim: se syn=yaml shiftwidth=2 et ts=2: 2 | # 3 | # Purely as an example. One will need to edit the config name at the very 4 | # least, and almost certainly the image version 5 | --- 6 | version: '3.7' 7 | configs: 8 | "conch-api-prod": 9 | external: true 10 | networks: 11 | default: 12 | name: overlay 13 | services: 14 | api: 15 | image: joyentbuildops/conch-api:v2.19.6 16 | ports: 17 | - "5000:5000" 18 | configs: 19 | - source: "conch-api-prod" 20 | target: /app/conch/etc/conch.conf 21 | mode: 0440 22 | deploy: 23 | mode: global 24 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::add_hdd_size_validation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | add\_hdd\_size\_validation - Add the 'hdd\_size' validation to the Server validation plan 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch add_hdd_size_validation [long options...] 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::insert_validation_states.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | insert\_validation\_states - insert new validation\_state records from old device\_validate data 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch insert_validation_states [long options...] inputfile.csv 9 | 10 | --help print usage message and exit 11 | ``` 12 | 13 | # LICENSING 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 19 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::ValidationState.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::ValidationState 4 | 5 | # DESCRIPTION 6 | 7 | Controller for managing Validation states and results. 8 | 9 | # METHODS 10 | 11 | ## get 12 | 13 | Get the validation\_state record specified by uuid. 14 | 15 | Response uses the ValidationStateWithResults json schema. 16 | 17 | # LICENSING 18 | 19 | Copyright Joyent, Inc. 20 | 21 | This Source Code Form is subject to the terms of the Mozilla Public License, 22 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 23 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 24 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB.md: -------------------------------------------------------------------------------- 1 | # Conch::DB 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Base schema class for the Conch application. See [DBIx::Class::Schema](https://metacpan.org/pod/DBIx%3A%3AClass%3A%3ASchema). 10 | 11 | ## LICENSING 12 | 13 | Copyright Joyent, Inc. 14 | 15 | This Source Code Form is subject to the terms of the Mozilla Public License, 16 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 17 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 18 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::merge_validation_results.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | merge\_validation\_results - collapse duplicate validation\_result rows together 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch merge_validation_results [long options...] 9 | 10 | -n --dry-run dry-run (no changes are made) 11 | --help print usage message and exit 12 | ``` 13 | 14 | # LICENSING 15 | 16 | Copyright Joyent, Inc. 17 | 18 | This Source Code Form is subject to the terms of the Mozilla Public License, 19 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 20 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 21 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::clean_permissions.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | clean\_permissions - clean up unnecessary user\_workspace\_role entries 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | bin/conch clean_permissions [-nv] [long options...] 9 | -n --dry-run dry-run (no changes are made) 10 | -v --verbose verbose 11 | 12 | --help print usage message and exit 13 | ``` 14 | 15 | # LICENSING 16 | 17 | Copyright Joyent, Inc. 18 | 19 | This Source Code Form is subject to the terms of the Mozilla Public License, 20 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 21 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 22 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ToJSON.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ToJSON 4 | 5 | # DESCRIPTION 6 | 7 | A component for Conch::DB::Result classes to provide serialization functionality via `TO_JSON`. 8 | Sub-classes [DBIx::Class::Helper::Row::ToJSON](https://metacpan.org/pod/DBIx::Class::Helper::Row::ToJSON) to also serialize 'text' data. 9 | 10 | # USAGE 11 | 12 | ``` 13 | __PACKAGE__->load_components('+Conch::DB::ToJSON'); 14 | ``` 15 | 16 | # LICENSING 17 | 18 | Copyright Joyent, Inc. 19 | 20 | This Source Code Form is subject to the terms of the Mozilla Public License, 21 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 22 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 23 | -------------------------------------------------------------------------------- /sql/migrations/0141-user_relay_connection.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(141, $$ 2 | 3 | alter table relay add column user_id uuid references user_account (id); 4 | 5 | update relay 6 | set user_id = user_relay_connection.user_id, 7 | last_seen = greatest(relay.last_seen, user_relay_connection.last_seen) 8 | from user_relay_connection 9 | where user_relay_connection.relay_id = relay.id; 10 | 11 | -- these relays were never used and don't need to be preserved. 12 | delete from relay where user_id is null; 13 | 14 | create index relay_user_id on relay (user_id); 15 | 16 | alter table relay alter column user_id set not null; 17 | drop table user_relay_connection; 18 | 19 | $$); 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::Relay.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Relay 4 | 5 | # METHODS 6 | 7 | ## register 8 | 9 | Registers a relay and connects it with the current user. The relay is created 10 | it if the relay does not already exists 11 | 12 | ## list 13 | 14 | If the user is a system admin, retrieve a list of all active relays in the database 15 | 16 | Response uses the Relays json schema. 17 | 18 | ## delete 19 | 20 | # LICENSING 21 | 22 | Copyright Joyent, Inc. 23 | 24 | This Source Code Form is subject to the terms of the Mozilla Public License, 25 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 26 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 27 | -------------------------------------------------------------------------------- /docs/json-schema/index.md: -------------------------------------------------------------------------------- 1 | # JSON Schema documentation (in `json-schema/`) 2 | 3 | * [common](../json-schema/common.json) 4 | * [device_report](../json-schema/device_report.json) 5 | * [draft-2019-09-strict](../json-schema/draft-2019-09-strict.json) 6 | * [other](../json-schema/other.json) 7 | * [query_params](../json-schema/query_params.json) 8 | * [request](../json-schema/request.json) 9 | * [response](../json-schema/response.json) 10 | 11 | [Back to main index](../) 12 | 13 | # Copyright / License 14 | 15 | Copyright Joyent, Inc. 16 | 17 | This Source Code Form is subject to the terms of the Mozilla Public License, 18 | v.2.0. If a copy of the MPL was not distributed with this file, you can 19 | obtain one at . 20 | -------------------------------------------------------------------------------- /report/bin/start_manta_job.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | test $MANTA_USER || (echo '$MANTA_USER must be defined' && exit 1); 4 | test $1 || (echo 'First argument must be local directory for manta job' && exit 1); 5 | test $2 || (echo 'Second argument must be Manta path for job inputs' && exit 1); 6 | 7 | manta_job_dir=$1 8 | job_name=$(basename $manta_job_dir) 9 | 10 | test -f $manta_job_dir/job.json || (echo "$manta_job_dir must have job.json file" && exit 1) 11 | 12 | manta_input_dir=$2 13 | 14 | echo 'Uploading job files...' 15 | muntar -f <(tar -cf - $manta_job_dir) ~~/stor/job 16 | echo 'Done.' 17 | 18 | echo 'Starting Manta job' 19 | mfind $manta_input_dir | mjob create -f <(perl -pe 's/\$([_A-Z]+)/$ENV{$1}/g' $manta_job_dir/job.json) -n "$job_name" 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::DeviceLocation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::DeviceLocation 4 | 5 | # METHODS 6 | 7 | ## get 8 | 9 | Retrieves location data for the current device. 10 | 11 | Response uses the DeviceLocation json schema. 12 | 13 | ## set 14 | 15 | Sets the location for a device, given a valid rack id and rack unit 16 | 17 | ## delete 18 | 19 | Deletes the location data for a device, provided it has been assigned to a location 20 | 21 | # LICENSING 22 | 23 | Copyright Joyent, Inc. 24 | 25 | This Source Code Form is subject to the terms of the Mozilla Public License, 26 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 27 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 28 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/MutateDevice.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::MutateDevice; 2 | 3 | use strict; 4 | use warnings; 5 | use warnings FATAL => 'utf8'; 6 | use utf8; 7 | use Mojo::Base 'Conch::Validation', -signatures; 8 | 9 | sub version { 1 } 10 | sub name { 'mutate_device' } 11 | sub description { 'my description' } 12 | sub category { 'exception' } 13 | 14 | sub validate ($self, $data) { 15 | # this validator is very naughty and tries to write to the database! 16 | $self->device->asset_tag('King Zøg'); 17 | $self->device->update; 18 | 19 | $self->register_result( 20 | got => 'hi', 21 | expected => 'hi', 22 | component => 'x', 23 | hint => 'we should have died before getting here', 24 | ); 25 | } 26 | 27 | 1; 28 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::update_validation_plans.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | update\_validation\_plans - Utility to bring validations and validation\_plans up to date 4 | 5 | # SYNOPSIS 6 | 7 | ```perl 8 | bin/conch update_validation_plans [long options...] 9 | 10 | --help print usage message and exit 11 | --use_latest deactivate old versions of validation , 12 | update all plans to use the new version of this validation 13 | ``` 14 | 15 | # LICENSING 16 | 17 | Copyright Joyent, Inc. 18 | 19 | This Source Code Form is subject to the terms of the Mozilla Public License, 20 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 21 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 22 | -------------------------------------------------------------------------------- /sql/migrations/0149-validation_state_member-result_order-resequence.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(149, $$ 2 | 3 | update validation_state_member set result_order = result_seq - 1 4 | from ( 5 | select 6 | validation_state_id, 7 | validation_result_id, 8 | row_number() over ( 9 | partition by validation_state_id order by validation_result_id, result_order asc 10 | ) as result_seq 11 | from validation_state_member 12 | left join validation_result on validation_result.id = validation_state_member.validation_result_id 13 | ) _tmp 14 | where validation_state_member.validation_state_id = _tmp.validation_state_id 15 | and validation_state_member.validation_result_id = _tmp.validation_result_id; 16 | 17 | $$); 18 | -------------------------------------------------------------------------------- /t/lib/Conch/Validation/MultipleResults.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::MultipleResults; 2 | 3 | use Mojo::Base 'Conch::Validation', -signatures; 4 | 5 | sub version { 1 } 6 | sub name { 'multiple_results' } 7 | sub description { 'my description' } 8 | sub category { 'multi' } 9 | 10 | sub validate ($self, $data) { 11 | 12 | $self->register_result( 13 | got => 'hi', 14 | expected => 'hi', 15 | component => 'x', 16 | hint => 'this is ignored', 17 | ); 18 | $self->register_result( 19 | got => 'yay', 20 | expected => 'nay', 21 | name => 'new name', 22 | message => 'new message', 23 | category => 'new category', 24 | component => 'y', 25 | hint => 'stfu', 26 | ); 27 | } 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Route::DeviceReport.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Route::DeviceReport 4 | 5 | # METHODS 6 | 7 | ## routes 8 | 9 | Sets up the routes for /device\_report: 10 | 11 | Unless otherwise noted, all routes require authentication. 12 | 13 | ### `POST /device_report` 14 | 15 | - Request: device\_report.yaml 16 | - Response: response.yaml#/ReportValidationResults 17 | 18 | ### `GET /device_report/:device_report_id` 19 | 20 | - Response: response.yaml#/DeviceReportRow 21 | 22 | # LICENSING 23 | 24 | Copyright Joyent, Inc. 25 | 26 | This Source Code Form is subject to the terms of the Mozilla Public License, 27 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 28 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 29 | -------------------------------------------------------------------------------- /sql/migrations/0110-device-triton.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(110, $$ 2 | 3 | insert into device_setting (name, device_id, value) 4 | select 'latest_triton_reboot', id, latest_triton_reboot::text 5 | from device where latest_triton_reboot is not null; 6 | 7 | insert into device_setting (name, device_id, value) 8 | select 'triton_uuid', id, triton_uuid::text 9 | from device where triton_uuid is not null; 10 | 11 | insert into device_setting (name, device_id, value) 12 | select 'triton_setup', id, triton_setup::text 13 | from device where triton_setup is not null; 14 | 15 | alter table device 16 | drop column latest_triton_reboot, 17 | drop column triton_uuid, 18 | drop column triton_setup; 19 | 20 | $$); 21 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch - Setup and helpers for Conch Mojo app 4 | 5 | # SYNOPSIS 6 | 7 | ``` 8 | Mojolicious::Commands->start_app('Conch'); 9 | ``` 10 | 11 | # METHODS 12 | 13 | ## startup 14 | 15 | Used by Mojo in the startup process. Loads the config file and sets up the 16 | helpers, routes and everything else. 17 | 18 | ## startup\_time 19 | 20 | Stores a [Conch::Time](/modules/Conch::Time) instance representing the time the server started accepting requests. 21 | 22 | # LICENSING 23 | 24 | Copyright Joyent, Inc. 25 | 26 | This Source Code Form is subject to the terms of the Mozilla Public License, 27 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 28 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 29 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::HardwareVendor.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::User 4 | 5 | # METHODS 6 | 7 | ## find\_hardware\_vendor 8 | 9 | Handles looking up the object by id or name. 10 | 11 | ## get\_all 12 | 13 | Retrieves all active hardware vendors. 14 | 15 | Response uses the HardwareVendors json schema. 16 | 17 | ## get\_one 18 | 19 | Gets one (active) hardware vendor. 20 | 21 | Response uses the HardwareVendor json schema. 22 | 23 | ## create 24 | 25 | ## delete 26 | 27 | # LICENSING 28 | 29 | Copyright Joyent, Inc. 30 | 31 | This Source Code Form is subject to the terms of the Mozilla Public License, 32 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 33 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 34 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::check_layouts.md: -------------------------------------------------------------------------------- 1 | # check\_layouts - check for rack layout conflicts 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/check_layouts.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/check_layouts.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch check_layouts [long options...] 11 | 12 | --ws --build build name 13 | 14 | --help print usage message and exit 15 | ``` 16 | 17 | ## LICENSING 18 | 19 | Copyright Joyent, Inc. 20 | 21 | This Source Code Form is subject to the terms of the Mozilla Public License, 22 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 23 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 24 | -------------------------------------------------------------------------------- /sql/migrations/0180-json_schema.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(180, $$ 2 | 3 | create table json_schema ( 4 | id uuid default gen_random_uuid() not null primary key, 5 | type text not null, 6 | name text not null, 7 | version integer not null check (version > 0), 8 | body jsonb not null, 9 | created timestamp with time zone default now() not null, 10 | created_user_id uuid not null references user_account (id), 11 | deactivated timestamp with time zone, 12 | 13 | unique (type, name, version) 14 | ); 15 | create index json_schema_type_idx on json_schema (type) where deactivated is null; 16 | create index json_schema_type_name_idx on json_schema (type, name) where deactivated is null; 17 | 18 | grant select on all tables in schema public to conch_read_only; 19 | 20 | $$); 21 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::check_validation_plans.md: -------------------------------------------------------------------------------- 1 | # check\_validation\_plans - Utility to check all validations and plans are up to date 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/check_validation_plans.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/check_validation_plans.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch check_validation_plans [long options...] 11 | 12 | --help print usage message and exit 13 | ``` 14 | 15 | ## LICENSING 16 | 17 | Copyright Joyent, Inc. 18 | 19 | This Source Code Form is subject to the terms of the Mozilla Public License, 20 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 21 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 22 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::Rollbar.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::Rollbar 4 | 5 | # DESCRIPTION 6 | 7 | Mojo plugin to send exceptions to [Rollbar](https://rollbar.com) 8 | 9 | # METHODS 10 | 11 | ## register 12 | 13 | Adds \`send\_exception\_to\_rollbar\` to Mojolicious app 14 | 15 | ## send\_exception\_to\_rollbar 16 | 17 | Asynchronously send exception details to Rollbar if 'rollbar\_access\_token' is 18 | configured. Returns a unique uuid suitable for logging, to correlate with the 19 | Rollbar entry thus created. 20 | 21 | # LICENSING 22 | 23 | Copyright Joyent, Inc. 24 | 25 | This Source Code Form is subject to the terms of the Mozilla Public License, 26 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 27 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 28 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::fix_usernames.md: -------------------------------------------------------------------------------- 1 | # fix\_usernames - fixes old usernames in the database (one-off for v3 launch) 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/fix_usernames.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/fix_usernames.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch fix_usernames [long options...] 11 | 12 | -n --dry-run dry-run (no changes are made) 13 | 14 | --help print usage message and exit 15 | ``` 16 | 17 | ## LICENSING 18 | 19 | Copyright Joyent, Inc. 20 | 21 | This Source Code Form is subject to the terms of the Mozilla Public License, 22 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 23 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 24 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Command::create_user.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | create\_user - create a new user, optionally sending an email 4 | 5 | # SYNOPSIS 6 | 7 | ```perl 8 | bin/conch create_user --email --name [--password ] [--send-mail] 9 | 10 | --email The user's email address. Required. 11 | --name The user's name. Required. 12 | --password The user's temporary password. If not provided, one will be randomly generated. 13 | --send-mail Send a welcome email to the user (defaults to true) 14 | ``` 15 | 16 | # LICENSING 17 | 18 | Copyright Joyent, Inc. 19 | 20 | This Source Code Form is subject to the terms of the Mozilla Public License, 21 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 22 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 23 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::ValidationError.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::ValidationError - Internal error representation for Conch::Validation 4 | 5 | # DESCRIPTION 6 | 7 | Extends [Mojo::Exception](https://metacpan.org/pod/Mojo::Exception) to store a `hint` attribute. Intended for use in 8 | [Conch::Validation](/modules/Conch::Validation). 9 | 10 | # METHODS 11 | 12 | ## error\_loc 13 | 14 | Return a description of where the error occurred. Provides the module name and 15 | line number, but not the filepath, so it doesn't expose where the file lives. 16 | 17 | # LICENSING 18 | 19 | Copyright Joyent, Inc. 20 | 21 | This Source Code Form is subject to the terms of the Mozilla Public License, 22 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 23 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 24 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::FindHelpers.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::FindHelpers 4 | 5 | # DESCRIPTION 6 | 7 | Common methods for looking up various data in the database and saving it to the stash, or 8 | generating error responses as appropriate. 9 | 10 | These are suitable to be used in `under` calls in various routes, or directly by a controller 11 | method. 12 | 13 | # HELPERS 14 | 15 | ## find\_user 16 | 17 | Validates the provided user\_id or email address (prefaced with 'email='), and stashes the 18 | corresponding user row in `target_user`. 19 | 20 | # LICENSING 21 | 22 | Copyright Joyent, Inc. 23 | 24 | This Source Code Form is subject to the terms of the Mozilla Public License, 25 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 26 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 27 | -------------------------------------------------------------------------------- /sql/migrations/0105-hardware_product-rack_size.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(105, $$ 2 | 3 | alter table hardware_product 4 | add column rack_unit_size integer check (rack_unit_size > 0); 5 | 6 | update hardware_product 7 | set rack_unit_size = hardware_product_profile.rack_unit 8 | from hardware_product_profile 9 | where hardware_product_profile.hardware_product_id = hardware_product.id; 10 | 11 | -- for the remaining rows, use a obviously-placeholder value, to be fixed later (the large 12 | -- rack unit size will prevent any layouts from using this hardware without fixing) 13 | update hardware_product set rack_unit_size = 999 where rack_unit_size is null; 14 | 15 | alter table hardware_product alter rack_unit_size set not null; 16 | alter table hardware_product_profile drop column rack_unit; 17 | 18 | $$); 19 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::RackRole.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::RackRole 4 | 5 | # METHODS 6 | 7 | ## find\_rack\_role 8 | 9 | Supports rack role lookups by uuid and name. 10 | 11 | ## create 12 | 13 | Create a new rack role. 14 | 15 | ## get 16 | 17 | Get a single rack role. 18 | 19 | Response uses the RackRole json schema. 20 | 21 | ## get\_all 22 | 23 | Get all rack roles. 24 | 25 | Response uses the RackRoles json schema. 26 | 27 | ## update 28 | 29 | Modify an existing rack role. 30 | 31 | ## delete 32 | 33 | Delete a rack role. 34 | 35 | # LICENSING 36 | 37 | Copyright Joyent, Inc. 38 | 39 | This Source Code Form is subject to the terms of the Mozilla Public License, 40 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 41 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 42 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::UserWorkspaceRole.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::UserWorkspaceRole 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving user/workspace permissions. 8 | 9 | # METHODS 10 | 11 | ## with\_permission 12 | 13 | Constrains the resultset to those user\_workspace\_role rows that grant (at least) the specified 14 | permission level. 15 | 16 | ## user\_has\_permission 17 | 18 | Returns a boolean indicating whether there exists a user\_workspace\_role row that grant (at 19 | least) the specified permission level. 20 | 21 | # LICENSING 22 | 23 | Copyright Joyent, Inc. 24 | 25 | This Source Code Form is subject to the terms of the Mozilla Public License, 26 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 27 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 28 | -------------------------------------------------------------------------------- /sql/migrations/0174-truncate-workspaces.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(174, $$ 2 | 3 | drop trigger all_racks_in_global_workspace on rack; 4 | drop function add_rack_to_global_workspace; 5 | 6 | create table legacy_workspace_rack ( like workspace_rack including all ); 7 | create table legacy_user_workspace_role ( like user_workspace_role including all ); 8 | create table legacy_workspace ( like workspace including all ); 9 | 10 | insert into legacy_workspace_rack (select * from workspace_rack ); 11 | insert into legacy_user_workspace_role (select * from user_workspace_role ); 12 | insert into legacy_workspace (select * from workspace ); 13 | 14 | truncate workspace_rack; 15 | truncate user_workspace_role; 16 | -- avoid "cannot truncate a table referenced in a foreign key constraint" 17 | delete from workspace; 18 | 19 | $$); 20 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::create_token.md: -------------------------------------------------------------------------------- 1 | # create\_token - create a new api token 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_token.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_token.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch create_token [long options...] 11 | 12 | --name required; the name to give the token 13 | --email required; the user account for which to create the token 14 | 15 | --help print usage message and exit 16 | ``` 17 | 18 | ## LICENSING 19 | 20 | Copyright Joyent, Inc. 21 | 22 | This Source Code Form is subject to the terms of the Mozilla Public License, 23 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 24 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 25 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::Organization.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::Organization 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/Organization.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/Organization.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries involving organizations. 10 | 11 | ## METHODS 12 | 13 | ### admins 14 | 15 | All the 'admin' users for the provided organization(s). Pass a true argument to also include all 16 | system admin users in the result. 17 | 18 | ## LICENSING 19 | 20 | Copyright Joyent, Inc. 21 | 22 | This Source Code Form is subject to the terms of the Mozilla Public License, 23 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 24 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 25 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::Validation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Validation 4 | 5 | Controller for managing Validations, **NOT** executing them. 6 | 7 | # METHODS 8 | 9 | ## list 10 | 11 | List all Validations. 12 | 13 | Response uses the Validations json schema (including deactivated ones). 14 | 15 | ## find\_validation 16 | 17 | Find the Validation specified by uuid or name, and stashes the query to get to it in 18 | `validation_rs`. 19 | 20 | ## get 21 | 22 | Get the Validation specified by uuid or name. 23 | 24 | Response uses the Validation json schema. 25 | 26 | # LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::DeviceReport.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::DeviceReport 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving device reports. 8 | 9 | # METHODS 10 | 11 | ## with\_report\_status 12 | 13 | Given a resultset indicating one or more report(s), adds a column to the result indicating 14 | the cumulative status of all the validation state record(s) associated with it (that is, if all 15 | pass, then return 'pass', otherwise consider if any were 'error' or 'fail'). 16 | 17 | Reports with no validation results are considered to be a 'pass'. 18 | 19 | # LICENSING 20 | 21 | Copyright Joyent, Inc. 22 | 23 | This Source Code Form is subject to the terms of the Mozilla Public License, 24 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 25 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 26 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Route::Relay.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Route::Relay 4 | 5 | # METHODS 6 | 7 | ## routes 8 | 9 | Sets up the routes for /relay: 10 | 11 | Unless otherwise noted, all routes require authentication. 12 | 13 | ### `POST /relay/:relay_id/register` 14 | 15 | - Request: input.yaml#/RegisterRelay 16 | - Response: `204 NO CONTENT` 17 | 18 | ### `GET /relay` 19 | 20 | - Requires System Admin Authentication 21 | - Response: response.yaml#/Relays 22 | 23 | ## `DELETE /relay/:relay_serial_number` 24 | 25 | - Requires system admin authorization 26 | - Response: `204 NO CONTENT` 27 | 28 | # LICENSING 29 | 30 | Copyright Joyent, Inc. 31 | 32 | This Source Code Form is subject to the terms of the Mozilla Public License, 33 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 34 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 35 | -------------------------------------------------------------------------------- /docs/modules/Conch::Controller::ValidationState.md: -------------------------------------------------------------------------------- 1 | # Conch::Controller::ValidationState 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/ValidationState.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/ValidationState.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Controller for managing Validation states and results. 10 | 11 | ## METHODS 12 | 13 | ### get 14 | 15 | Get the validation\_state record specified by uuid, along with all its associated results. 16 | 17 | Response uses the ValidationStateWithResults json schema. 18 | 19 | ## LICENSING 20 | 21 | Copyright Joyent, Inc. 22 | 23 | This Source Code Form is subject to the terms of the Mozilla Public License, 24 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 25 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 26 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Deactivatable.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Deactivatable 4 | 5 | # DESCRIPTION 6 | 7 | A component for [Conch::DB::ResultSet](/modules/Conch::DB::ResultSet) classes for database tables with a `deactivated` 8 | column, to provide common query functionality. 9 | 10 | # USAGE 11 | 12 | ``` 13 | __PACKAGE__->load_components('+Conch::DB::Deactivatable'); 14 | ``` 15 | 16 | # METHODS 17 | 18 | ## active 19 | 20 | Chainable resultset to limit results to those that aren't deactivated. 21 | 22 | ## deactivate 23 | 24 | Update all matching rows by setting deactivated = now(). 25 | 26 | # LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Result::Migration.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Result::Migration 4 | 5 | # BASE CLASS: [Conch::DB::Result](/modules/Conch::DB::Result) 6 | 7 | # TABLE: `migration` 8 | 9 | # ACCESSORS 10 | 11 | ## id 12 | 13 | ``` 14 | data_type: 'integer' 15 | is_auto_increment: 1 16 | is_nullable: 0 17 | sequence: 'migration_id_seq' 18 | ``` 19 | 20 | ## created 21 | 22 | ```perl 23 | data_type: 'timestamp with time zone' 24 | default_value: current_timestamp 25 | is_nullable: 1 26 | original: {default_value => \"now()"} 27 | ``` 28 | 29 | # PRIMARY KEY 30 | 31 | - ["id"](#id) 32 | 33 | # LICENSING 34 | 35 | Copyright Joyent, Inc. 36 | 37 | This Source Code Form is subject to the terms of the Mozilla Public License, 38 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 39 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 40 | -------------------------------------------------------------------------------- /sql/migrations/0106-integer-constraints.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(106, $$ 2 | 3 | alter table migration 4 | add constraint migration_id_check check (id >= 0); 5 | 6 | alter table device_location 7 | add constraint device_location_rack_unit_start_check check (rack_unit_start > 0); 8 | 9 | alter table rack_layout 10 | add constraint rack_layout_rack_unit_start_check check (rack_unit_start > 0); 11 | 12 | alter table rack_role 13 | add constraint rack_role_rack_size_check check (rack_size > 0); 14 | 15 | alter table relay 16 | add constraint relay_ssh_port_check check (ssh_port >= 0); 17 | 18 | alter table validation 19 | add constraint validation_version_check check (version > 0); 20 | 21 | alter table validation_result 22 | add constraint validation_result_result_order_check check (result_order >= 0); 23 | 24 | $$); 25 | -------------------------------------------------------------------------------- /t/validations/cpu_count_v1.t: -------------------------------------------------------------------------------- 1 | use v5.20; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Conch::Validation 'test_validation'; 6 | 7 | test_validation( 8 | 'Conch::Validation::CpuCount', 9 | device => { 10 | hardware_product => { 11 | cpu_num => 2, 12 | }, 13 | }, 14 | cases => [ 15 | { 16 | description => 'Missing cpus', 17 | data => {}, 18 | }, 19 | { 20 | description => 'Incorrect processor count', 21 | data => { cpus => [ { core_id => '0' } ] }, 22 | failure_num => 1, 23 | }, 24 | { 25 | description => 'Correct processor count', 26 | data => { cpus => [ { core_id => '0' }, { core_id => '1' } ] }, 27 | success_num => 1, 28 | }, 29 | ] 30 | ); 31 | 32 | done_testing; 33 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::update_validation_plans.md: -------------------------------------------------------------------------------- 1 | # update\_validation\_plans - Utility to bring validations and validation\_plans up to date 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/update_validation_plans.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/update_validation_plans.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch update_validation_plans [long options...] 11 | 12 | --update_all update all plans to use the new version of this validation 13 | 14 | --help print usage message and exit 15 | ``` 16 | 17 | ## LICENSING 18 | 19 | Copyright Joyent, Inc. 20 | 21 | This Source Code Form is subject to the terms of the Mozilla Public License, 22 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 23 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 24 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::passwd.md: -------------------------------------------------------------------------------- 1 | # passwd - change a user's password 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/passwd.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/passwd.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch passwd [--id ] [--email ] [--password ] 11 | 12 | --id The user's id. 13 | --email The user's email address. required, if id is not provided. 14 | --password The user's new password. If not provided, one will be randomly generated and echoed. 15 | 16 | --help print usage message and exit 17 | ``` 18 | 19 | ## LICENSING 20 | 21 | Copyright Joyent, Inc. 22 | 23 | This Source Code Form is subject to the terms of the Mozilla Public License, 24 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 25 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 26 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::thin_device_reports.md: -------------------------------------------------------------------------------- 1 | # thin\_device\_reports - remove unwanted device reports 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/thin_device_reports.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/thin_device_reports.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch thin_device_reports [long options...] 11 | 12 | -n --dry-run dry-run (no changes are made) 13 | --updated-since= only consider devices updated since 14 | 15 | --help print usage message and exit 16 | ``` 17 | 18 | ## LICENSING 19 | 20 | Copyright Joyent, Inc. 21 | 22 | This Source Code Form is subject to the terms of the Mozilla Public License, 23 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 24 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 25 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::InflateColumn::Time.md: -------------------------------------------------------------------------------- 1 | # DESCRIPTION 2 | 3 | Automatically inflates/deflates timestamps in the database to [Conch::Time](/modules/Conch::Time) objects (which is 4 | a subclass of [Time::Moment](https://metacpan.org/pod/Time::Moment)). 5 | 6 | No extra work needs to be done for deflation, because postgres is happy to accept our slight 7 | modifications to the format used in `to_string`. All we need to do is rebless the 8 | [Time::Moment](https://metacpan.org/pod/Time::Moment) object into [Conch::Time](/modules/Conch::Time), and work around the bug in 9 | [RT#125975](https://rt.cpan.org/Ticket/Display.html?id=125975). 10 | 11 | # LICENSING 12 | 13 | Copyright Joyent, Inc. 14 | 15 | This Source Code Form is subject to the terms of the Mozilla Public License, 16 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 17 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 18 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::force_password_change.md: -------------------------------------------------------------------------------- 1 | # force\_password\_change - force a user or users to change their password 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/force_password_change.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/force_password_change.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch force_password_change [long options...] 11 | 12 | -n --dry-run dry-run (no changes are made) 13 | --email modify this user, by email (can be used more than once) 14 | 15 | --help print usage message and exit 16 | ``` 17 | 18 | ## LICENSING 19 | 20 | Copyright Joyent, Inc. 21 | 22 | This Source Code Form is subject to the terms of the Mozilla Public License, 23 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 24 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 25 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::ValidationState.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::ValidationState 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving validation states. 8 | 9 | # METHODS 10 | 11 | ## latest\_completed\_state\_per\_plan 12 | 13 | Generates a resultset that returns the single most recent \*completed\* validation\_state entry 14 | per validation plan (using whatever other search criteria are already in the resultset). 15 | 16 | The query will be closed off as a subselect (that additional chaining will SELECT FROM), 17 | so it makes a difference whether you add things to the resultset before or after calling this 18 | method. 19 | 20 | # LICENSING 21 | 22 | Copyright Joyent, Inc. 23 | 24 | This Source Code Form is subject to the terms of the Mozilla Public License, 25 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 26 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 27 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::InflateColumn::Time.md: -------------------------------------------------------------------------------- 1 | ## DESCRIPTION 2 | 3 | Automatically inflates/deflates timestamps in the database to [Conch::Time](../modules/Conch%3A%3ATime) objects (which is 4 | a subclass of [Time::Moment](https://metacpan.org/pod/Time%3A%3AMoment)). 5 | 6 | No extra work needs to be done for deflation, because postgres is happy to accept our slight 7 | modifications to the format used in `to_string`. All we need to do is rebless the 8 | [Time::Moment](https://metacpan.org/pod/Time%3A%3AMoment) object into [Conch::Time](../modules/Conch%3A%3ATime), and work around the bug in 9 | [RT#125975](https://rt.cpan.org/Ticket/Display.html?id=125975). 10 | 11 | ## LICENSING 12 | 13 | Copyright Joyent, Inc. 14 | 15 | This Source Code Form is subject to the terms of the Mozilla Public License, 16 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 17 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 18 | -------------------------------------------------------------------------------- /docs/modules/Conch::Plugin::ClientVerification.md: -------------------------------------------------------------------------------- 1 | # Conch::Plugin::ClientVerification 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/ClientVerification.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/ClientVerification.pm) 6 | 7 | ## METHODS 8 | 9 | ### register 10 | 11 | Sets up the hooks. 12 | 13 | ## HOOKS 14 | 15 | ### before\_dispatch 16 | 17 | Checks the version of the client sending us a request, possibly rejecting it if it does not 18 | meet our criteria. 19 | 20 | For security reasons we do not specify the reason for the rejection in the error response, 21 | but we will log it. 22 | 23 | ## LICENSING 24 | 25 | Copyright Joyent, Inc. 26 | 27 | This Source Code Form is subject to the terms of the Mozilla Public License, 28 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 29 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 30 | -------------------------------------------------------------------------------- /docs/modules/Conch::Plugin::Features.md: -------------------------------------------------------------------------------- 1 | # Conch::Plugin::Features - Sets up a helper to access configured features 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/Features.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/Features.pm) 6 | 7 | ## METHODS 8 | 9 | ### register 10 | 11 | Sets up the helpers. 12 | 13 | ## HELPERS 14 | 15 | These methods are made available on the `$c` object (the invocant of all controller methods, 16 | and therefore other helpers). 17 | 18 | ### feature 19 | 20 | Checks if a given feature name is enabled. 21 | 22 | ``` 23 | if ($c->feature('rollbar') { ... } 24 | ``` 25 | 26 | ## LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Result.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Result 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Result.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Result.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Base class for our result classes, to allow us to add on additional functionality from what is 10 | available in core [DBIx::Class](https://metacpan.org/pod/DBIx%3A%3AClass). 11 | 12 | ## METHODS 13 | 14 | Methods added are: 15 | 16 | - [self\_rs](https://metacpan.org/pod/DBIx%3A%3AClass%3A%3AHelper%3A%3ARow%3A%3ASelfResultSet#self_rs) 17 | - [TO\_JSON](../modules/Conch%3A%3ADB%3A%3AHelper%3A%3ARow%3A%3AToJSON) 18 | 19 | ## LICENSING 20 | 21 | Copyright Joyent, Inc. 22 | 23 | This Source Code Form is subject to the terms of the Mozilla Public License, 24 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 25 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 26 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::Mail.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::Mail - Sets up a helper to send emails 4 | 5 | ## DESCRIPTION 6 | 7 | Provides the helper sub 'send\_mail' to the app and controllers: 8 | 9 | ```perl 10 | $c->send_mail( 11 | template_file => $filename, # file in templates/email, without extension 12 | OR 13 | template => $template_string, 14 | OR 15 | content => $raw_content, 16 | 17 | to => $to_email, defaults to stashed 'target_user' 18 | from => $from_email, defaults to stashed 'user' 19 | subject => $subject, 20 | 21 | ... all additional arguments are passed to the template renderer ... 22 | ); 23 | ``` 24 | 25 | # LICENSING 26 | 27 | Copyright Joyent, Inc. 28 | 29 | This Source Code Form is subject to the terms of the Mozilla Public License, 30 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 31 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 32 | -------------------------------------------------------------------------------- /lib/Conch/Validation/CpuCount.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::CpuCount; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'cpu_count'; 6 | use constant version => 2; 7 | use constant category => 'CPU'; 8 | use constant description => 'Validate the reported number of CPUs match the hardware product profile'; 9 | 10 | sub validate { 11 | my ($self, $data) = @_; 12 | 13 | unless ($data->{cpus}) { 14 | $self->die("Missing cpus property") 15 | } 16 | 17 | $self->register_result( 18 | expected => $self->hardware_product->cpu_num, 19 | got => scalar $data->{cpus}->@*, 20 | ); 21 | } 22 | 23 | 1; 24 | __END__ 25 | 26 | =pod 27 | 28 | =head1 LICENSING 29 | 30 | Copyright Joyent, Inc. 31 | 32 | This Source Code Form is subject to the terms of the Mozilla Public License, 33 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 34 | one at L. 35 | 36 | =cut 37 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::RackLayout.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::RackLayout 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/RackLayout.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/RackLayout.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries involving rack layouts. 10 | 11 | ## METHODS 12 | 13 | ### with\_rack\_unit\_size 14 | 15 | Chainable resultset that adds `rack_unit_size` to the results. 16 | 17 | ### with\_rack\_name 18 | 19 | Modifies the resultset to add the `rack_name` column (the full rack name). 20 | 21 | ### with\_sku 22 | 23 | Modifies the resultset to add the `sku` column. 24 | 25 | ## LICENSING 26 | 27 | Copyright Joyent, Inc. 28 | 29 | This Source Code Form is subject to the terms of the Mozilla Public License, 30 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 31 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 32 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::DatacenterRoom.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::DatacenterRoom 4 | 5 | # METHODS 6 | 7 | ## find\_datacenter\_room 8 | 9 | Handles looking up the object by id. 10 | 11 | ## get\_all 12 | 13 | Get all datacenter rooms. 14 | 15 | Response uses the DatacenterRoomsDetailed json schema. 16 | 17 | ## get\_one 18 | 19 | Get a single datacenter room. 20 | 21 | Response uses the DatacenterRoomDetailed json schema. 22 | 23 | ## create 24 | 25 | Create a new datacenter room. 26 | 27 | ## update 28 | 29 | Update an existing room. 30 | 31 | ## delete 32 | 33 | Permanently delete a datacenter room. 34 | 35 | ## racks 36 | 37 | Response uses the Racks json schema. 38 | 39 | # LICENSING 40 | 41 | Copyright Joyent, Inc. 42 | 43 | This Source Code Form is subject to the terms of the Mozilla Public License, 44 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 45 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 46 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::DeviceInterface.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Device 4 | 5 | # METHODS 6 | 7 | ## find\_device\_interface 8 | 9 | Chainable action that looks up the device interface by its id or name. 10 | 11 | ## get\_one\_field 12 | 13 | Retrieves the value of the specified device\_nic field for the specified device interface. 14 | 15 | Response uses the DeviceNicField json schema. 16 | 17 | ## get\_one 18 | 19 | Retrieves all device\_nic fields for the specified device interface. 20 | 21 | Response uses the DeviceNic json schema. 22 | 23 | ## get\_all 24 | 25 | Retrieves all device\_nic records for the specified device. 26 | 27 | Response uses the DeviceNics json schema. 28 | 29 | # LICENSING 30 | 31 | Copyright Joyent, Inc. 32 | 33 | This Source Code Form is subject to the terms of the Mozilla Public License, 34 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 35 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 36 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Helper::Row::ToJSON.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Helper::Row::ToJSON 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/ToJSON.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/ToJSON.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | A component for [Conch::DB::Result](../modules/Conch%3A%3ADB%3A%3AResult) classes to provide serialization functionality via `TO_JSON`. 10 | Sub-classes [DBIx::Class::Helper::Row::ToJSON](https://metacpan.org/pod/DBIx%3A%3AClass%3A%3AHelper%3A%3ARow%3A%3AToJSON) to also serialize 'text' data. 11 | 12 | ## USAGE 13 | 14 | ``` 15 | __PACKAGE__->load_components('+Conch::DB::Helper::Row::ToJSON'); 16 | ``` 17 | 18 | ## LICENSING 19 | 20 | Copyright Joyent, Inc. 21 | 22 | This Source Code Form is subject to the terms of the Mozilla Public License, 23 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 24 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 25 | -------------------------------------------------------------------------------- /docs/modules/Conch::Plugin::DeprecatedAction.md: -------------------------------------------------------------------------------- 1 | # Conch::Plugin::DeprecationAction 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/DeprecatedAction.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/DeprecatedAction.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Mojo plugin to detect and report the usage of deprecated controller actions. 10 | 11 | ## METHODS 12 | 13 | ### register 14 | 15 | Sets up the hooks. 16 | 17 | ## HOOKS 18 | 19 | ### after\_dispatch 20 | 21 | Sets the `X-Deprecated` header in the response. 22 | 23 | Also sends a message to Rollbar when a deprecated action is invoked, if the 24 | `report_deprecated_actions` feature is enabled. 25 | 26 | ## LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::Datacenter.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Datacenter 4 | 5 | # METHODS 6 | 7 | ## find\_datacenter 8 | 9 | Handles looking up the object by id. 10 | 11 | ## get\_all 12 | 13 | Get all datacenters. 14 | 15 | Response uses the Datacenters json schema. 16 | 17 | ## get\_one 18 | 19 | Get a single datacenter. 20 | 21 | Response uses the Datacenter json schema. 22 | 23 | ## get\_rooms 24 | 25 | Get all rooms for the given datacenter. 26 | 27 | Response uses the DatacenterRoomsDetailed json schema. 28 | 29 | ## create 30 | 31 | Create a new datacenter. 32 | 33 | ## update 34 | 35 | Update an existing datacenter. 36 | 37 | ## delete 38 | 39 | Permanently delete a datacenter. 40 | 41 | # LICENSING 42 | 43 | Copyright Joyent, Inc. 44 | 45 | This Source Code Form is subject to the terms of the Mozilla Public License, 46 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 47 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 48 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Route::HardwareVendor.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Route::HardwareVendor 4 | 5 | # METHODS 6 | 7 | ## routes 8 | 9 | Sets up the routes for /hardware\_vendor: 10 | 11 | Unless otherwise noted, all routes require authentication. 12 | 13 | ### `GET /hardware_vendor` 14 | 15 | - Response: response.yaml#/HardwareVendors 16 | 17 | ### `GET /hardware_vendor/:hardware_vendor_id_or_name` 18 | 19 | - Response: response.yaml#/HardwareVendor 20 | 21 | ### `DELETE /hardware_vendor/:hardware_vendor_id_or_name` 22 | 23 | - Response: `204 NO CONTENT` 24 | 25 | ### `POST /hardware_vendor/:hardware_vendor_name` 26 | 27 | - Requires System Admin Authentication 28 | - Response: Redirect to the created hardware vendor 29 | 30 | # LICENSING 31 | 32 | Copyright Joyent, Inc. 33 | 34 | This Source Code Form is subject to the terms of the Mozilla Public License, 35 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 36 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 37 | -------------------------------------------------------------------------------- /lib/Conch/Validation/BiosFirmwareVersion.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::BiosFirmwareVersion; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'bios_firmware_version'; 6 | use constant version => 2; 7 | use constant category => 'BIOS'; 8 | use constant description => 'Validate the reported BIOS firmware version matches the hardware product profile'; 9 | 10 | sub validate { 11 | my ($self, $data) = @_; 12 | 13 | $self->die("Missing 'bios_version'") unless $data->{bios_version}; 14 | 15 | $self->register_result( 16 | expected => $self->hardware_product->bios_firmware, 17 | got => $data->{bios_version} 18 | ); 19 | } 20 | 21 | 1; 22 | __END__ 23 | 24 | =pod 25 | 26 | =head1 LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at L. 33 | 34 | =cut 35 | -------------------------------------------------------------------------------- /sql/migrations/0144-validation_result-unique-constraint.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(144, $$ 2 | 3 | -- We know that new validation results re-use old validation_result rows whenever possible 4 | -- (see the end of Conch::ValidationSystem::run_validation_plan), and since release v3.0.0 5 | -- (where either: 1. merge_validation_results was run a final time, or 2. validation_result 6 | -- was truncated) there are no duplicates, so it is now safe to turn this index into a 7 | -- unique constraint. 8 | 9 | -- we copied hardware_product_id to validation_state in migration 0129. 10 | alter table validation_result drop column hardware_product_id; 11 | 12 | alter table validation_result 13 | add constraint validation_result_all_columns_key unique 14 | (device_id, validation_id, message, hint, status, category, component); 15 | 16 | drop index if exists validation_result_all_columns_idx; 17 | drop index validation_result_device_id_idx; -- redundant with unique constraint 18 | 19 | $$); 20 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::RackLayout.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::RackLayout 4 | 5 | # METHODS 6 | 7 | ## find\_rack\_layout 8 | 9 | Supports rack layout lookups by id 10 | 11 | ## create 12 | 13 | Creates a new rack\_layout entry according to the passed-in specification. 14 | 15 | ## get 16 | 17 | Gets one specific rack layout. 18 | 19 | Response uses the RackLayout json schema. 20 | 21 | ## get\_all 22 | 23 | Gets \*all\* rack layouts. 24 | 25 | Response uses the RackLayouts json schema. 26 | 27 | ## update 28 | 29 | Updates a rack layout to specify that a certain hardware product should reside at a certain 30 | rack starting position. 31 | 32 | ## delete 33 | 34 | Deletes the specified rack layout. 35 | 36 | # LICENSING 37 | 38 | Copyright Joyent, Inc. 39 | 40 | This Source Code Form is subject to the terms of the Mozilla Public License, 41 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 42 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 43 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Result::Migration.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Result::Migration 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Result/Migration.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Result/Migration.pm) 6 | 7 | ## BASE CLASS: [Conch::DB::Result](../modules/Conch%3A%3ADB%3A%3AResult) 8 | 9 | ## TABLE: `migration` 10 | 11 | ## ACCESSORS 12 | 13 | ### id 14 | 15 | ``` 16 | data_type: 'integer' 17 | is_nullable: 0 18 | ``` 19 | 20 | ### created 21 | 22 | ``` 23 | data_type: 'timestamp with time zone' 24 | default_value: current_timestamp 25 | is_nullable: 1 26 | original: {default_value => \"now()"} 27 | ``` 28 | 29 | ## PRIMARY KEY 30 | 31 | - ["id"](#id) 32 | 33 | ## LICENSING 34 | 35 | Copyright Joyent, Inc. 36 | 37 | This Source Code Form is subject to the terms of the Mozilla Public License, 38 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 39 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 40 | -------------------------------------------------------------------------------- /docs/modules/Conch::ValidationError.md: -------------------------------------------------------------------------------- 1 | # Conch::ValidationError - Internal error representation for Conch::Validation 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/ValidationError.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/ValidationError.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Extends [Mojo::Exception](https://metacpan.org/pod/Mojo%3A%3AException) to store a `hint` attribute. Intended for use in 10 | [Conch::Validation](../modules/Conch%3A%3AValidation). 11 | 12 | ## METHODS 13 | 14 | ### error\_loc 15 | 16 | Return a description of where the error occurred. Provides the module name and 17 | line number, but not the filepath, so it doesn't expose where the file lives. 18 | 19 | ## LICENSING 20 | 21 | Copyright Joyent, Inc. 22 | 23 | This Source Code Form is subject to the terms of the Mozilla Public License, 24 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 25 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 26 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::WorkspaceRelay.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::WorkspaceRelay 4 | 5 | # METHODS 6 | 7 | ## list 8 | 9 | List all relays located in the current workspace (as specified by :workspace\_id in the path) 10 | or sub-workspaces beneath it. 11 | 12 | Use `?active_within=X` to constrains results to those updated in the last X minutes. 13 | 14 | Response uses the WorkspaceRelays json schema. 15 | 16 | ## get\_relay\_devices 17 | 18 | Returns all the devices that have been reported by the provided relay that are located within 19 | this workspace. (It doesn't matter if the relay itself was later moved to another workspace - we 20 | just look at device locations.) 21 | 22 | Response uses the Devices json schema. 23 | 24 | # LICENSING 25 | 26 | Copyright Joyent, Inc. 27 | 28 | This Source Code Form is subject to the terms of the Mozilla Public License, 29 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 30 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 31 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::DeviceLocation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::DeviceLocation 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving device locations. 8 | 9 | # METHODS 10 | 11 | ## assign\_device\_location 12 | 13 | Atomically assign a device to the provided rack and rack unit start position. 14 | 15 | \- checks that the rack layout exists (dying otherwise) 16 | \- removes the current occupant of the location 17 | \- makes the location assignment, moving the device if it had a previous location 18 | 19 | ## target\_hardware\_product 20 | 21 | Returns a resultset that will produce the 'target\_hardware\_product' portion of the 22 | DeviceLocation json schema (one hashref per matching device\_location). 23 | 24 | # LICENSING 25 | 26 | Copyright Joyent, Inc. 27 | 28 | This Source Code Form is subject to the terms of the Mozilla Public License, 29 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 30 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 31 | -------------------------------------------------------------------------------- /schema-loader.yaml: -------------------------------------------------------------------------------- 1 | # vim: set sts=2 sw=2 et : 2 | 3 | schema_class: Conch::DB 4 | 5 | # connection string 6 | connect_info: 7 | dsn: dbi:Pg:dbname=conch 8 | user: conch 9 | 10 | # dbic loader options 11 | loader_options: 12 | dump_directory: ./lib 13 | 14 | default_resultset_class: +Conch::DB::ResultSet 15 | 16 | result_base_class: Conch::DB::Result 17 | 18 | allow_extra_m2m_cols: 1 19 | 20 | rel_name_map: 21 | user: user_account 22 | DeviceNeighbor: 23 | mac: device_nic 24 | UserAccount: 25 | builds_2s: completed_builds 26 | 27 | moniker_map: 28 | hardware_product_json_schema: HardwareProductJSONSchema 29 | json_schema: JSONSchema 30 | 31 | naming: v8 # the latest and greatest (v7 is still the default) 32 | 33 | # this is usually more useful than not, but take care that you don't blow away any changes 34 | # not yet in git! 35 | overwrite_modifications: 1 36 | 37 | omit_timestamp: 1 38 | 39 | # exclude these tables - they are kept as backups only 40 | exclude: !!perl/regexp ^legacy_.*workspace 41 | -------------------------------------------------------------------------------- /docs/_resources/devices.er: -------------------------------------------------------------------------------- 1 | title {label: "Conch database schema (as of v3.1.2, 2020-12-10): device data", size: "40"} 2 | 3 | entity {bgcolor: "#ececfc", size: "20"} 4 | 5 | [device] {bgcolor: "#fbfbdb"} 6 | *id 7 | serial_number 8 | system_uuid 9 | +hardware_product_id 10 | health {label: "error, fail, unknown, pass"} 11 | last_seen 12 | created 13 | updated 14 | uptime_since 15 | validated 16 | asset_tag 17 | hostname 18 | phase 19 | links 20 | +build_id 21 | 22 | [device_disk] 23 | *id 24 | +device_id 25 | serial_number 26 | slot 27 | size 28 | vendor 29 | model 30 | firmware 31 | transport 32 | health 33 | drive_type 34 | deactivated 35 | created 36 | updated 37 | enclosure 38 | hba 39 | 40 | [device_neighbor] 41 | *mac 42 | raw_text 43 | peer_switch 44 | peer_port 45 | created 46 | updated 47 | peer_mac 48 | 49 | [device_nic] 50 | *mac 51 | +device_id 52 | iface_name 53 | iface_type 54 | iface_vendor 55 | deactivated 56 | created 57 | updated 58 | state 59 | ipaddr 60 | mtu 61 | 62 | device_disk *--1 device 63 | device_neighbor *--1 device_nic 64 | device_nic *--1 device 65 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::create_user.md: -------------------------------------------------------------------------------- 1 | # create\_user - create a new user, optionally sending an email 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_user.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_user.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch create_user --email --name [--password ] [--send-email] 11 | 12 | --email The user's email address. Required. 13 | --name The user's name. Required. 14 | --password The user's temporary password. If not provided, one will be randomly generated. 15 | --send-email Send a welcome email to the user (defaults to true) 16 | 17 | --help print usage message and exit 18 | ``` 19 | 20 | ## LICENSING 21 | 22 | Copyright Joyent, Inc. 23 | 24 | This Source Code Form is subject to the terms of the Mozilla Public License, 25 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 26 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 27 | -------------------------------------------------------------------------------- /docs/modules/Conch::Route::ValidationState.md: -------------------------------------------------------------------------------- 1 | # Conch::Route::ValidationState 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Route/ValidationState.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Route/ValidationState.pm) 6 | 7 | ## METHODS 8 | 9 | ### routes 10 | 11 | Sets up the routes for /validation\_state. 12 | 13 | ## ROUTE ENDPOINTS 14 | 15 | All routes require authentication. 16 | 17 | ### `GET /validation_state/:validation_state_id` 18 | 19 | - Controller/Action: ["get" in Conch::Controller::ValidationState](../modules/Conch%3A%3AController%3A%3AValidationState#get) 20 | - Response: [response.json#/$defs/ValidationStateWithResults](../json-schema/response.json#/$defs/ValidationStateWithResults) 21 | 22 | ## LICENSING 23 | 24 | Copyright Joyent, Inc. 25 | 26 | This Source Code Form is subject to the terms of the Mozilla Public License, 27 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 28 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 29 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Helper::ResultSet::WithRole.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Helper::ResultSet::WithRole 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/ResultSet/WithRole.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/ResultSet/WithRole.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | A component for [Conch::DB::ResultSet](../modules/Conch%3A%3ADB%3A%3AResultSet) classes for database tables with a `role` 10 | column, to provide common query functionality. 11 | 12 | ## USAGE 13 | 14 | ``` 15 | __PACKAGE__->load_components('+Conch::DB::Helper::ResultSet::WithRole'); 16 | ``` 17 | 18 | ## METHODS 19 | 20 | ### with\_role 21 | 22 | Constrains the resultset to those rows that grants (at least) the specified role. 23 | 24 | ## LICENSING 25 | 26 | Copyright Joyent, Inc. 27 | 28 | This Source Code Form is subject to the terms of the Mozilla Public License, 29 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 30 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 31 | -------------------------------------------------------------------------------- /sql/migrations/0126-relay-last_seen.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(126, $$ 2 | 3 | alter table relay add column last_seen timestamp with time zone; 4 | 5 | with relay_updates as 6 | ( 7 | select 8 | relay_id, 9 | last_seen, 10 | (row_number() over (partition by relay_id order by last_seen desc)) as result_num 11 | from ( 12 | select relay_id, last_seen 13 | from 14 | ((select relay_id, last_seen from device_relay_connection) 15 | union 16 | (select relay_id, last_seen from user_relay_connection) 17 | ) as connections 18 | ) as rseen 19 | ) 20 | update relay 21 | set last_seen = relay_updates.last_seen 22 | from relay_updates 23 | where relay.id = relay_updates.relay_id and result_num = 1; 24 | 25 | update relay set last_seen = created where last_seen is null; 26 | 27 | alter table relay 28 | alter column last_seen set default now(), 29 | alter column last_seen set not null; 30 | 31 | $$); 32 | -------------------------------------------------------------------------------- /Dockerfile.dev: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN apt-get update && \ 6 | apt-get upgrade -y --no-install-recommends && \ 7 | apt-get install -y --no-install-recommends \ 8 | build-essential \ 9 | ca-certificates \ 10 | carton \ 11 | curl \ 12 | git \ 13 | libssl-dev \ 14 | libzip-dev \ 15 | perl-doc \ 16 | unzip \ 17 | postgresql \ 18 | libpq-dev \ 19 | && apt-get clean 20 | 21 | RUN mkdir -p /app/conch 22 | WORKDIR /app/conch 23 | 24 | COPY . /app/conch 25 | 26 | ARG VCS_REF="master" 27 | ARG VERSION="v0.0.0-dirty" 28 | 29 | ENV LANG C.UTF-8 30 | ENV EV_EXTRA_DEFS -DEV_NO_ATFORK 31 | ENV MOJO_CONFIG /app/conch/etc/conch.conf 32 | 33 | # The port hypnotoad listens on is defined in its config so the exposed port 34 | # may need to be changed at runtime to match that config. 35 | ENV MOJO_LISTEN http://0.0.0.0:5000 36 | EXPOSE 5000 37 | 38 | ENV HARNESS_OPTIONS j6:c 39 | ENTRYPOINT ["make"] 40 | CMD [ "forcebuild", "test"] 41 | 42 | # vim: se syn=dockerfile: 43 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::DeviceReport.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::DeviceReport 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/DeviceReport.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/DeviceReport.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries involving device reports. 10 | 11 | ## METHODS 12 | 13 | ### with\_report\_status 14 | 15 | Given a resultset indicating one or more report(s), adds a column to the result indicating 16 | the cumulative status of all the validation state record(s) associated with it (that is, if all 17 | pass, then return 'pass', otherwise consider if any were 'error' or 'fail'). 18 | 19 | Reports with no validation results are considered to be a 'pass'. 20 | 21 | ## LICENSING 22 | 23 | Copyright Joyent, Inc. 24 | 25 | This Source Code Form is subject to the terms of the Mozilla Public License, 26 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 27 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 28 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::UserAccount.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::UserAccount 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/UserAccount.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/UserAccount.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries against the `user_account` table. 10 | 11 | ## METHODS 12 | 13 | ### find\_by\_email 14 | 15 | Queries for user by (case-insensitive) email address. 16 | 17 | If more than one user is found, we return the one created most recently. 18 | 19 | If you want to search only for **active** users, apply the `->active` resultset to the 20 | caller first. 21 | 22 | ### search\_by\_email 23 | 24 | Just the resultset for ["find\_by\_email"](#find_by_email). 25 | 26 | ## LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::Rack.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::Rack 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving racks. 8 | 9 | # METHODS 10 | 11 | ## assigned\_rack\_units 12 | 13 | Returns a list of rack\_unit positions that are assigned to current layouts (including positions 14 | assigned to hardware that start at an earlier position) at the specified rack. (Will return 15 | merged results when passed a resultset referencing multiple racks, so don't do that.) 16 | 17 | This is used for identifying potential conflicts when adjusting layouts. 18 | 19 | ## user\_has\_permission 20 | 21 | Checks that the provided user\_id has (at least) the specified permission in at least one 22 | workspace associated with the specified rack(s), including parent workspaces. 23 | 24 | # LICENSING 25 | 26 | Copyright Joyent, Inc. 27 | 28 | This Source Code Form is subject to the terms of the Mozilla Public License, 29 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 30 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 31 | -------------------------------------------------------------------------------- /lib/Conch/Validation/NicsNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::NicsNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'nics_num'; 6 | use constant version => 1; 7 | use constant category => 'NET'; 8 | use constant description => 'Validate the reported number of NICs match the hardware product profile'; 9 | 10 | sub validate { 11 | my ($self, $data) = @_; 12 | 13 | $self->die("Input data must include 'interfaces' hash") 14 | unless $data->{interfaces} && ref($data->{interfaces}) eq 'HASH'; 15 | 16 | my $nics_count = scalar(keys $data->{interfaces}->%*); 17 | 18 | $self->register_result( 19 | expected => $self->hardware_product->nics_num, 20 | got => $nics_count, 21 | ); 22 | } 23 | 24 | 1; 25 | __END__ 26 | 27 | =pod 28 | 29 | =head1 LICENSING 30 | 31 | Copyright Joyent, Inc. 32 | 33 | This Source Code Form is subject to the terms of the Mozilla Public License, 34 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 35 | one at L. 36 | 37 | =cut 38 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:bionic 2 | 3 | ENV DEBIAN_FRONTEND=noninteractive 4 | 5 | RUN apt-get update && \ 6 | apt-get upgrade -y --no-install-recommends && \ 7 | apt-get install -y --no-install-recommends \ 8 | build-essential \ 9 | ca-certificates \ 10 | carton \ 11 | curl \ 12 | git \ 13 | libssl-dev \ 14 | libzip-dev \ 15 | perl-doc \ 16 | unzip \ 17 | postgresql \ 18 | libpq-dev \ 19 | && apt-get clean 20 | 21 | RUN mkdir -p /app/conch 22 | WORKDIR /app/conch 23 | 24 | COPY . /app/conch 25 | 26 | ARG VCS_REF="master" 27 | ARG VERSION="v0.0.0-dirty" 28 | 29 | ENV HARNESS_OPTIONS j6:c 30 | RUN make forcebuild && rm -r local/cache && rm -r ~/.cpanm 31 | 32 | ENV LANG C.UTF-8 33 | ENV EV_EXTRA_DEFS -DEV_NO_ATFORK 34 | ENV MOJO_CONFIG /app/conch/etc/conch.conf 35 | 36 | # The port hypnotoad listens on is defined in its config so the exposed port 37 | # may need to be changed at runtime to match that config. 38 | EXPOSE 5000 39 | 40 | ENTRYPOINT ["carton", "exec"] 41 | CMD ["hypnotoad", "-f", "bin/conch"] 42 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::Schema.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Schema 4 | 5 | # METHODS 6 | 7 | ## get 8 | 9 | Get the json-schema in JSON format. 10 | 11 | ## \_extract\_schema\_definition 12 | 13 | Given a [JSON::Validator](https://metacpan.org/pod/JSON::Validator) object containing a schema definition, extract the requested portion 14 | out of the "definitions" section, including any named references, and add some standard 15 | headers. 16 | 17 | TODO: this (plus addition of the header fields) could mostly be replaced with just: 18 | 19 | ```perl 20 | my $new_defs = $jv->bundle({ 21 | schema => $jv->get('/definitions/'.$title), 22 | ref_key => 'definitions', 23 | }); 24 | ``` 25 | 26 | ..except circular refs are not handled there, and the definition renaming leaks local path info. 27 | 28 | # LICENSING 29 | 30 | Copyright Joyent, Inc. 31 | 32 | This Source Code Form is subject to the terms of the Mozilla Public License, 33 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 34 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 35 | -------------------------------------------------------------------------------- /lib/Conch/DB/Helper/Row/ToJSON.pm: -------------------------------------------------------------------------------- 1 | package Conch::DB::Helper::Row::ToJSON; 2 | use v5.26; 3 | use warnings; 4 | 5 | use parent 'DBIx::Class::Helper::Row::ToJSON'; 6 | 7 | =head1 NAME 8 | 9 | Conch::DB::Helper::Row::ToJSON 10 | 11 | =head1 DESCRIPTION 12 | 13 | A component for L classes to provide serialization functionality via C. 14 | Sub-classes L to also serialize 'text' data. 15 | 16 | =head1 USAGE 17 | 18 | __PACKAGE__->load_components('+Conch::DB::Helper::Row::ToJSON'); 19 | 20 | =cut 21 | 22 | # same as parent, only 'text' is not unserializable. 23 | sub unserializable_data_types { 24 | return { 25 | blob => 1, 26 | ntext => 1, 27 | }; 28 | } 29 | 30 | 1; 31 | __END__ 32 | 33 | =pod 34 | 35 | =head1 LICENSING 36 | 37 | Copyright Joyent, Inc. 38 | 39 | This Source Code Form is subject to the terms of the Mozilla Public License, 40 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 41 | one at L. 42 | 43 | =cut 44 | # vim: set sts=2 sw=2 et : 45 | -------------------------------------------------------------------------------- /lib/Conch/Validation/DimmCount.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::DimmCount; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'dimm_count'; 6 | use constant version => 3; 7 | use constant category => 'RAM'; 8 | use constant description => 'Verify the number of DIMMs reported'; 9 | 10 | sub validate { 11 | my ($self, $data) = @_; 12 | 13 | unless($data->{dimms}) { 14 | $self->die("Missing 'dimms' property"); 15 | } 16 | 17 | my $dimms_num = scalar grep $_->{'memory-size'} || $_->{'memory-type'}, 18 | $data->{dimms}->@*; 19 | my $dimms_want = $self->hardware_product->dimms_num; 20 | 21 | $self->register_result( 22 | expected => $dimms_want, 23 | got => $dimms_num, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::DeviceSettings.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::DeviceSettings 4 | 5 | # METHODS 6 | 7 | ## set\_all 8 | 9 | Overrides all settings for a device with the given payload. 10 | Existing settings are deactivated even if they are not being replaced with new ones. 11 | 12 | ## set\_single 13 | 14 | Sets a single setting on a device. If the setting already exists, it is 15 | overwritten, unless the value is unchanged. 16 | 17 | ## get\_all 18 | 19 | Get all settings for a device as a hash 20 | 21 | Response uses the DeviceSettings json schema. 22 | 23 | ## get\_single 24 | 25 | Get a single setting from a device 26 | 27 | Response uses the DeviceSetting json schema. 28 | 29 | ## delete\_single 30 | 31 | Delete a single setting from a device, provide that setting was previously set 32 | 33 | # LICENSING 34 | 35 | Copyright Joyent, Inc. 36 | 37 | This Source Code Form is subject to the terms of the Mozilla Public License, 38 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 39 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 40 | -------------------------------------------------------------------------------- /lib/Conch/Validation/UsbHddNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::UsbHddNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'usb_hdd_num'; 7 | use constant version => 1; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of reported USB HDDs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my $usb_num = 18 | grep { fc($_->{transport}) eq fc('usb') } (values $data->{disks}->%*); 19 | 20 | $self->register_result( 21 | expected => $self->hardware_product->usb_num, 22 | got => $usb_num, 23 | ); 24 | } 25 | 26 | 1; 27 | __END__ 28 | 29 | =pod 30 | 31 | =head1 LICENSING 32 | 33 | Copyright Joyent, Inc. 34 | 35 | This Source Code Form is subject to the terms of the Mozilla Public License, 36 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 37 | one at L. 38 | 39 | =cut 40 | -------------------------------------------------------------------------------- /t/validations/firmware_current_v1.t: -------------------------------------------------------------------------------- 1 | use v5.20; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Conch::Validation 'test_validation'; 6 | 7 | test_validation( 8 | 'Conch::Validation::FirmwareCurrent', 9 | cases => [ 10 | { 11 | description => 'No device settings fails', 12 | failure_num => 1, 13 | }, 14 | ] 15 | ); 16 | 17 | test_validation( 18 | 'Conch::Validation::FirmwareCurrent', 19 | device => { 20 | device_settings => { 21 | firmware => 'updating' 22 | }, 23 | }, 24 | cases => [ 25 | { 26 | description => '"updating" firmware fails', 27 | failure_num => 1, 28 | }, 29 | ] 30 | ); 31 | 32 | test_validation( 33 | 'Conch::Validation::FirmwareCurrent', 34 | device => { 35 | device_settings => { 36 | firmware => 'current' 37 | }, 38 | }, 39 | cases => [ 40 | { 41 | description => '"current" firmware fails', 42 | success_num => 1, 43 | }, 44 | ] 45 | ); 46 | 47 | done_testing; 48 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultSet::DeviceNic.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultSet::DeviceNic 4 | 5 | # DESCRIPTION 6 | 7 | Interface to queries involving device network interfaces. 8 | 9 | # METHODS 10 | 11 | ## nic\_pxe 12 | 13 | Returns a resultset which provides the MAC address of the relevant PXE network interface(s) 14 | (the first-by-name interface whose state = 'up'). 15 | 16 | Suitable for embedding as a sub-query. 17 | 18 | ## nic\_ipmi 19 | 20 | Returns a resultset which provides the MAC address and IP address (as an arrayref) of the 21 | network interface(s) named "ipmi1". 22 | 23 | Suitable for embedding as a sub-query; post-processing will be required to extract the two 24 | columns into the desired format. 25 | 26 | ## fields 27 | 28 | The list of fields associated with each network interface entry. 29 | 30 | # LICENSING 31 | 32 | Copyright Joyent, Inc. 33 | 34 | This Source Code Form is subject to the terms of the Mozilla Public License, 35 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 36 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 37 | -------------------------------------------------------------------------------- /docs/modules/Conch::Plugin::GitVersion.md: -------------------------------------------------------------------------------- 1 | # Conch::Plugin::GitVersion 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/GitVersion.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/GitVersion.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Mojo plugin registering the git version tag and hash for the repository 10 | 11 | ## METHODS 12 | 13 | ### register 14 | 15 | Sets up the helpers. 16 | 17 | ## HELPERS 18 | 19 | These methods are made available on the `$c` object (the invocant of all controller methods, 20 | and therefore other helpers). 21 | 22 | ### version\_tag 23 | 24 | Provides a string that uniquely describes the version and commit of the currently-running code. 25 | 26 | ### version\_hash 27 | 28 | Provides the exact git SHA of the currently-running code. 29 | 30 | ## LICENSING 31 | 32 | Copyright Joyent, Inc. 33 | 34 | This Source Code Form is subject to the terms of the Mozilla Public License, 35 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 36 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 37 | -------------------------------------------------------------------------------- /lib/Conch/ValidationError.pm: -------------------------------------------------------------------------------- 1 | =pod 2 | 3 | =head1 NAME 4 | 5 | Conch::ValidationError - Internal error representation for Conch::Validation 6 | 7 | =head1 DESCRIPTION 8 | 9 | Extends L to store a C attribute. Intended for use in 10 | L. 11 | 12 | =head1 METHODS 13 | 14 | =cut 15 | 16 | package Conch::ValidationError; 17 | 18 | use Mojo::Base 'Mojo::Exception'; 19 | has 'hint'; 20 | 21 | =head2 error_loc 22 | 23 | Return a description of where the error occurred. Provides the module name and 24 | line number, but not the filepath, so it doesn't expose where the file lives. 25 | 26 | =cut 27 | 28 | sub error_loc { 29 | my $frame = shift->frames->[0]; 30 | 31 | my $error_loc = 'Exception raised in \''.$frame->[0].'\' at line '.$frame->[2]; 32 | } 33 | 34 | 1; 35 | __END__ 36 | 37 | =pod 38 | 39 | =head1 LICENSING 40 | 41 | Copyright Joyent, Inc. 42 | 43 | This Source Code Form is subject to the terms of the Mozilla Public License, 44 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 45 | one at L. 46 | 47 | =cut 48 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::AsEpoch.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::AsEpoch 4 | 5 | # DESCRIPTION 6 | 7 | A component for [Conch::DB::ResultSet](/modules/Conch::DB::ResultSet) classes that provides the `as_epoch` method. 8 | 9 | This code is postgres-specific. 10 | 11 | # USAGE 12 | 13 | ``` 14 | __PACKAGE__->load_components('+Conch::DB::AsEpoch'); 15 | ``` 16 | 17 | # METHODS 18 | 19 | ## as\_epoch 20 | 21 | Adds to a resultset a selection list for a timestamp column as a unix epoch time. 22 | If the column already existed in the selection list (presumably using the default time format), 23 | it is replaced. 24 | 25 | In this example, a `created` column will be included in the result, containing a value in unix 26 | epoch time format (number of seconds since 1970-01-01 00:00:00 UTC). 27 | 28 | ``` 29 | $rs = $rs->as_epoch('created'); 30 | ``` 31 | 32 | # LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 39 | -------------------------------------------------------------------------------- /lib/Conch/Validation/RamTotal.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::RamTotal; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use List::Util 'sum'; 5 | 6 | use constant name => 'ram_total'; 7 | use constant version => 2; 8 | use constant category => 'RAM'; 9 | use constant description => 'Validate the reported RAM match the hardware product profile'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | unless(exists $data->{dimms} && $data->{dimms}->@*) { 15 | $self->die("Missing 'dimms' property"); 16 | } 17 | 18 | my $ram_total = sum map $_->{'memory-size'} // 0, $data->{dimms}->@*; 19 | my $ram_want = $self->hardware_product->ram_total; 20 | 21 | $self->register_result( 22 | expected => $ram_want, 23 | got => $ram_total, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /t/validations/bios_firmware_version_v1.t: -------------------------------------------------------------------------------- 1 | use v5.20; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Conch::Validation 'test_validation'; 6 | 7 | test_validation( 8 | 'Conch::Validation::BiosFirmwareVersion', 9 | device => { 10 | hardware_product => { 11 | name => 'Test Product', 12 | bios_firmware => '1.2.3', 13 | }, 14 | }, 15 | cases => [ 16 | { 17 | description => 'No data yields no successes', 18 | data => {}, 19 | }, 20 | { 21 | description => 'bios_version should be string', 22 | data => { bios_version => ['foobar'] }, 23 | }, 24 | { 25 | description => "bios_version doesn't match hw product definition", 26 | data => { bios_version => '1.2' }, 27 | failure_num => 1 28 | }, 29 | { 30 | description => "bios_version matches hw product definition", 31 | data => { bios_version => '1.2.3' }, 32 | success_num => 1, 33 | }, 34 | ] 35 | ); 36 | 37 | done_testing; 38 | -------------------------------------------------------------------------------- /docs/modules/Conch::Controller::HardwareVendor.md: -------------------------------------------------------------------------------- 1 | # Conch::Controller::HardwareVendor 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/HardwareVendor.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/HardwareVendor.pm) 6 | 7 | ## METHODS 8 | 9 | ### find\_hardware\_vendor 10 | 11 | Chainable action that uses the `hardware_vendor_id_or_name` value provided in the stash 12 | (usually via the request URL) to look up a hardware vendor, and stashes the result in 13 | `hardware_vendor`. 14 | 15 | ### get\_all 16 | 17 | Retrieves all active hardware vendors. 18 | 19 | Response uses the HardwareVendors json schema. 20 | 21 | ### get\_one 22 | 23 | Gets one (active) hardware vendor. 24 | 25 | Response uses the HardwareVendor json schema. 26 | 27 | ### create 28 | 29 | ### delete 30 | 31 | ## LICENSING 32 | 33 | Copyright Joyent, Inc. 34 | 35 | This Source Code Form is subject to the terms of the Mozilla Public License, 36 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 37 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 38 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::HardwareProduct.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::HardwareProduct 4 | 5 | # METHODS 6 | 7 | ## list 8 | 9 | Get a list of all available hardware products. 10 | 11 | Response uses the HardwareProducts json schema. 12 | 13 | ## find\_hardware\_product 14 | 15 | Chainable action that looks up the object by id, sku, name or alias depending on the url 16 | pattern, stashing the query to get to it in `hardware_product_rs`. 17 | 18 | ## get 19 | 20 | Get the details of a single hardware product. 21 | 22 | Response uses the HardwareProduct json schema. 23 | 24 | ## create 25 | 26 | Creates a new hardware\_product, and possibly also a hardware\_product\_profile. 27 | 28 | ## update 29 | 30 | Updates an existing hardware\_product, possibly updating or creating a hardware\_product\_profile 31 | as needed. 32 | 33 | ## delete 34 | 35 | # LICENSING 36 | 37 | Copyright Joyent, Inc. 38 | 39 | This Source Code Form is subject to the terms of the Mozilla Public License, 40 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 41 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 42 | -------------------------------------------------------------------------------- /lib/Conch/Validation/FirmwareCurrent.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::FirmwareCurrent; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'firmware_current'; 6 | use constant version => 1; 7 | use constant category => 'BIOS'; 8 | use constant description => 'Validate that firmware is \'current\' in device settings'; 9 | 10 | sub validate { 11 | my ($self) = @_; 12 | 13 | my $firmware_value = $self->device_settings->{firmware}; 14 | 15 | if ($firmware_value) { 16 | $self->register_result( 17 | expected => 'current', 18 | got => $firmware_value 19 | ); 20 | } 21 | else { 22 | $self->fail("No 'firmware' setting in device settings", 23 | hint => 'Device may not have started initial setup yet'); 24 | } 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /lib/Conch/Validation/SasHddNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::SasHddNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'sas_hdd_num'; 7 | use constant version => 1; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of SAS HDDs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my $sas_hdd_count = 18 | grep { $_->{drive_type} && fc($_->{drive_type}) eq fc('SAS_HDD') } 19 | (values $data->{disks}->%*); 20 | 21 | $self->register_result( 22 | expected => $self->hardware_product->sas_hdd_num, 23 | got => $sas_hdd_count, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /t/pod-coverage.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | use Test::Pod::Coverage 1.00; 6 | use List::Util 'any'; 7 | 8 | # add regexes of module names here that should be skipped in their entirety. 9 | my @skip_modules = ( 10 | qr/^Conch::Validation::/, 11 | ); 12 | 13 | # regexps of sub names that are always trusted 14 | my @also_private = qw( 15 | BUILDARGS 16 | ); 17 | 18 | # module => [ regexps of sub names to be trusted ] 19 | my %trustme = ( 20 | ); 21 | 22 | for my $module (all_modules()) { 23 | next if any { $module =~ $_ } @skip_modules; 24 | 25 | my @trustme = @{$trustme{$module} // []}; 26 | push @trustme, 'run' if $module =~ /^Conch::Command::/; 27 | 28 | pod_coverage_ok( 29 | $module, 30 | { 31 | coverage_class => 'Pod::Coverage::CountParents', 32 | #coverage_class => 'Pod::Coverage::TrustPod', # includes Pod::Coverage::CountParents 33 | also_private => \@also_private, 34 | trustme => \@trustme, 35 | }, 36 | "pod coverage for $module" 37 | ); 38 | } 39 | 40 | done_testing; 41 | # vim: set sts=2 sw=2 et : 42 | -------------------------------------------------------------------------------- /lib/Conch/Validation/NvmeSsdNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::NvmeSsdNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'nvme_ssd_num'; 7 | use constant version => 1; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of NVMe SSDs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my $nvme_ssd_count = 18 | grep { $_->{drive_type} && fc($_->{drive_type}) eq fc('NVME_SSD') } 19 | (values $data->{disks}->%*); 20 | 21 | $self->register_result( 22 | expected => $self->hardware_product->nvme_ssd_num, 23 | got => $nvme_ssd_count, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /lib/Conch/Validation/RaidLunNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::RaidLunNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'raid_lun_num'; 7 | use constant version => 1; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of RAID LUNs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my $raid_lun_count = 18 | grep { $_->{drive_type} && fc($_->{drive_type}) eq fc('RAID_LUN') } 19 | (values $data->{disks}->%*); 20 | 21 | $self->register_result( 22 | expected => $self->hardware_product->raid_lun_num, 23 | got => $raid_lun_count, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /lib/Conch/Validation/SataHddNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::SataHddNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'sata_hdd_num'; 7 | use constant version => 1; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of SATA HDDs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my $sata_hdd_count = 18 | grep { $_->{drive_type} && fc($_->{drive_type}) eq fc('SATA_HDD') } 19 | (values $data->{disks}->%*); 20 | 21 | $self->register_result( 22 | expected => $self->hardware_product->sata_hdd_num, 23 | got => $sata_hdd_count, 24 | ); 25 | } 26 | 27 | 1; 28 | __END__ 29 | 30 | =pod 31 | 32 | =head1 LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at L. 39 | 40 | =cut 41 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::ValidationState.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::ValidationState 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/ValidationState.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/ValidationState.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries involving validation states. 10 | 11 | ## METHODS 12 | 13 | ### with\_legacy\_validation\_results 14 | 15 | Generates a resultset that adds the legacy\_validation\_results to the validation\_state(s) in the 16 | resultset (to be rendered as a flat list of results grouped by validation\_state). 17 | 18 | ### with\_validation\_results 19 | 20 | Generates a resultset that adds the validation\_results to the validation\_state(s) in the 21 | resultset (to be rendered as a list json\_schemas, each with a list of errors). 22 | 23 | ## LICENSING 24 | 25 | Copyright Joyent, Inc. 26 | 27 | This Source Code Form is subject to the terms of the Mozilla Public License, 28 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 29 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 30 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Result::WorkspaceRack.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Result::WorkspaceRack 4 | 5 | # BASE CLASS: [Conch::DB::Result](/modules/Conch::DB::Result) 6 | 7 | # TABLE: `workspace_rack` 8 | 9 | # ACCESSORS 10 | 11 | ## workspace\_id 12 | 13 | ``` 14 | data_type: 'uuid' 15 | is_foreign_key: 1 16 | is_nullable: 0 17 | size: 16 18 | ``` 19 | 20 | ## rack\_id 21 | 22 | ``` 23 | data_type: 'uuid' 24 | is_foreign_key: 1 25 | is_nullable: 0 26 | size: 16 27 | ``` 28 | 29 | # PRIMARY KEY 30 | 31 | - ["workspace\_id"](#workspace_id) 32 | - ["rack\_id"](#rack_id) 33 | 34 | # RELATIONS 35 | 36 | ## rack 37 | 38 | Type: belongs\_to 39 | 40 | Related object: [Conch::DB::Result::Rack](/modules/Conch::DB::Result::Rack) 41 | 42 | ## workspace 43 | 44 | Type: belongs\_to 45 | 46 | Related object: [Conch::DB::Result::Workspace](/modules/Conch::DB::Result::Workspace) 47 | 48 | # LICENSING 49 | 50 | Copyright Joyent, Inc. 51 | 52 | This Source Code Form is subject to the terms of the Mozilla Public License, 53 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 54 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 55 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Helper::ResultSet::Deactivatable.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Helper::ResultSet::Deactivatable 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/ResultSet/Deactivatable.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/ResultSet/Deactivatable.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | A component for [Conch::DB::ResultSet](../modules/Conch%3A%3ADB%3A%3AResultSet) classes for database tables with a `deactivated` 10 | column, to provide common query functionality. 11 | 12 | ## USAGE 13 | 14 | ``` 15 | __PACKAGE__->load_components('+Conch::DB::Helper::ResultSet::Deactivatable'); 16 | ``` 17 | 18 | ## METHODS 19 | 20 | ### active 21 | 22 | Chainable resultset to limit results to those that aren't deactivated. 23 | 24 | ### deactivate 25 | 26 | Update all matching rows by setting deactivated = now(). 27 | 28 | ## LICENSING 29 | 30 | Copyright Joyent, Inc. 31 | 32 | This Source Code Form is subject to the terms of the Mozilla Public License, 33 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 34 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 35 | -------------------------------------------------------------------------------- /docs/modules/Conch::Controller::RackRole.md: -------------------------------------------------------------------------------- 1 | # Conch::Controller::RackRole 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/RackRole.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/RackRole.pm) 6 | 7 | ## METHODS 8 | 9 | ### find\_rack\_role 10 | 11 | Chainable action that uses the `rack_role_id_or_name` value provided in the stash (usually via 12 | the request URL) to look up a rack role, and stashes the result in `rack_role`. 13 | 14 | ### create 15 | 16 | Create a new rack role. 17 | 18 | ### get 19 | 20 | Get a single rack role. 21 | 22 | Response uses the RackRole json schema. 23 | 24 | ### get\_all 25 | 26 | Get all rack roles. 27 | 28 | Response uses the RackRoles json schema. 29 | 30 | ### update 31 | 32 | Modify an existing rack role. 33 | 34 | ### delete 35 | 36 | Delete a rack role. 37 | 38 | ## LICENSING 39 | 40 | Copyright Joyent, Inc. 41 | 42 | This Source Code Form is subject to the terms of the Mozilla Public License, 43 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 44 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 45 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # vim: se syn=yaml shiftwidth=2 et ts=2: 2 | --- 3 | version: '3.3' 4 | services: 5 | postgres: 6 | image: postgres:9.6 7 | container_name: conch_postgres 8 | restart: always 9 | environment: 10 | POSTGRES_USER: conch 11 | POSTGRES_PASSWORD: conch 12 | POSTGRES_DB: conch 13 | volumes: 14 | - ./postgres:/var/lib/postgresql/data 15 | 16 | web: 17 | image: joyentbuildops/conch-api:latest 18 | container_name: conch_api 19 | restart: always 20 | read_only: true 21 | user: nobody 22 | 23 | entrypoint: ["carton", "exec"] 24 | command: ["hypnotoad", "-f", "bin/conch" ] 25 | 26 | environment: 27 | POSTGRES_USER: conch 28 | POSTGRES_PASSWORD: conch 29 | POSTGRES_DB: conch 30 | POSTGRES_HOST: postgres 31 | ports: 32 | - 5000:5000 33 | volumes: 34 | - type: tmpfs 35 | target: /tmp 36 | tmpfs: 37 | size: 1000 38 | - type: bind 39 | source: ./log 40 | target: /app/conch/log 41 | - type: bind 42 | source: ./conch.conf 43 | target: /app/conch/etc/conch.conf 44 | read_only: true 45 | depends_on: 46 | - postgres 47 | -------------------------------------------------------------------------------- /docs/modules/Conch::Command::create_test_validation_results.md: -------------------------------------------------------------------------------- 1 | # create\_test\_validation\_results - create new-style validation\_result entries for testing 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_test_validation_results.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Command/create_test_validation_results.pm) 6 | 7 | ## SYNOPSIS 8 | 9 | ``` 10 | bin/conch create_test_validation_results [-de] [long options...] 11 | 12 | -n --dry-run dry-run (no changes are made) 13 | --help print usage message and exit 14 | 15 | -d STR --device STR the device serial number to use for the results 16 | -e STR --email STR the creation user's email address 17 | --[no-]rvs --[no-]reuse-validation-state 18 | use an existing validation_state (otherwise, create a new one) 19 | ``` 20 | 21 | ## LICENSING 22 | 23 | Copyright Joyent, Inc. 24 | 25 | This Source Code Form is subject to the terms of the Mozilla Public License, 26 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 27 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 28 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Route::Validation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Route::Validation 4 | 5 | # METHODS 6 | 7 | ## routes 8 | 9 | Sets up the routes for /validation, /validation\_plan and /validation\_state: 10 | 11 | Unless otherwise noted, all routes require authentication. 12 | 13 | ### `GET /validation` 14 | 15 | - Response: response.yaml#/Validations 16 | 17 | ### `GET /validation/:validation_id_or_name` 18 | 19 | - Response: response.yaml#/Validation 20 | 21 | ### `GET /validation_plan` 22 | 23 | - Response: response.yaml#/ValidationPlans 24 | 25 | ### `GET /validation_plan/:validation_plan_id_or_name` 26 | 27 | - Response: response.yaml#/ValidationPlan 28 | 29 | ### `GET /validation_plan/:validation_plan_id_or_name/validation` 30 | 31 | - Response: response.yaml#/Validations 32 | 33 | ### `GET /validation_state/:validation_state_id` 34 | 35 | - Response: response.yaml#/ValidationStateWithResults 36 | 37 | # LICENSING 38 | 39 | Copyright Joyent, Inc. 40 | 41 | This Source Code Form is subject to the terms of the Mozilla Public License, 42 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 43 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 44 | -------------------------------------------------------------------------------- /t/pod-spelling.t: -------------------------------------------------------------------------------- 1 | use strict; 2 | use warnings; 3 | use Test::More; 4 | use Test::Warnings; 5 | 6 | # This test is based upon content generated by Dist::Zilla::Plugin::Test::PodSpelling 2.007005 7 | use Test::Spelling 0.12; 8 | use Pod::Wordlist; 9 | use YAML::XS; 10 | 11 | foreach my $file (glob('json-schema/*.yaml')) { 12 | my $data = YAML::XS::LoadFile($file); 13 | add_stopwords(keys $data->{'$defs'}->%*); 14 | } 15 | 16 | add_stopwords(); 17 | 18 | subtest all_pod_files_spelling_ok => sub { 19 | all_pod_files_spelling_ok(qw(lib t misc)); 20 | }; 21 | 22 | done_testing; 23 | 24 | __DATA__ 25 | ANDed 26 | api 27 | auth 28 | az 29 | bunyan 30 | chainable 31 | circ 32 | Circonus 33 | csv 34 | datacenter 35 | datacenters 36 | deduplication 37 | dsn 38 | filepath 39 | hba 40 | iff 41 | ipmi 42 | ISO 43 | iso8601 44 | Joyent 45 | jsonb 46 | JWT 47 | listref 48 | Mojo 49 | Mojolicious 50 | MPL 51 | mtu 52 | nullable 53 | ORed 54 | postgres 55 | PROXYED 56 | pxe 57 | rebless 58 | rels 59 | renderer 60 | resultset 61 | resultsets 62 | rfc 63 | ro 64 | Rollbar 65 | schema 66 | schemas 67 | sku 68 | subref 69 | subselect 70 | subtest 71 | timestamptz 72 | TODO 73 | unresolvable 74 | unstarted 75 | validator 76 | VLAN 77 | -------------------------------------------------------------------------------- /lib/Conch/DB/Result.pm: -------------------------------------------------------------------------------- 1 | package Conch::DB::Result; 2 | use v5.26; 3 | use warnings; 4 | use parent 'DBIx::Class::Core'; 5 | 6 | =head1 NAME 7 | 8 | Conch::DB::Result 9 | 10 | =head1 DESCRIPTION 11 | 12 | Base class for our result classes, to allow us to add on additional functionality from what is 13 | available in core L. 14 | 15 | =head1 METHODS 16 | 17 | Methods added are: 18 | 19 | =over 4 20 | 21 | =item * L 22 | 23 | =item * L 24 | 25 | =back 26 | 27 | =cut 28 | 29 | __PACKAGE__->load_components( 30 | '+Conch::DB::InflateColumn::Time', # inflates 'timestamp with time zone' columns to Conch::Time 31 | '+Conch::DB::Helper::Row::ToJSON', # provides serialization hooks 32 | 'Helper::Row::SelfResultSet', # provides self_rs 33 | ); 34 | 35 | 1; 36 | __END__ 37 | 38 | =pod 39 | 40 | =head1 LICENSING 41 | 42 | Copyright Joyent, Inc. 43 | 44 | This Source Code Form is subject to the terms of the Mozilla Public License, 45 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 46 | one at L. 47 | 48 | =cut 49 | # vim: set sts=2 sw=2 et : 50 | -------------------------------------------------------------------------------- /lib/Conch/Plugin/Features.pm: -------------------------------------------------------------------------------- 1 | package Conch::Plugin::Features; 2 | 3 | use v5.26; 4 | use Mojo::Base 'Mojolicious::Plugin', -signatures; 5 | 6 | =pod 7 | 8 | =head1 NAME 9 | 10 | Conch::Plugin::Features - Sets up a helper to access configured features 11 | 12 | =head1 METHODS 13 | 14 | =head2 register 15 | 16 | Sets up the helpers. 17 | 18 | =head1 HELPERS 19 | 20 | These methods are made available on the C<$c> object (the invocant of all controller methods, 21 | and therefore other helpers). 22 | 23 | =head2 feature 24 | 25 | Checks if a given feature name is enabled. 26 | 27 | if ($c->feature('rollbar') { ... } 28 | 29 | =cut 30 | 31 | sub register ($self, $app, $config) { 32 | $app->helper(feature => sub ($c, $feature_name) { 33 | state $features = $config->{features} // {}; 34 | return $features->{$feature_name}; 35 | }); 36 | } 37 | 38 | 1; 39 | __END__ 40 | 41 | =pod 42 | 43 | =head1 LICENSING 44 | 45 | Copyright Joyent, Inc. 46 | 47 | This Source Code Form is subject to the terms of the Mozilla Public License, 48 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 49 | one at L. 50 | 51 | =cut 52 | # vim: set sts=2 sw=2 et : 53 | -------------------------------------------------------------------------------- /sql/migrations/0128-organizations.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(128, $$ 2 | 3 | alter type user_workspace_role_enum rename to role_enum; 4 | 5 | create table organization ( 6 | id uuid default gen_random_uuid() not null primary key, 7 | name text not null, 8 | description text, 9 | created timestamp with time zone default now() not null, 10 | deactivated timestamp with time zone 11 | ); 12 | create unique index organization_name_key 13 | on organization (name) where deactivated is null; 14 | 15 | create table user_organization_role ( 16 | user_id uuid not null references user_account (id), 17 | organization_id uuid not null references organization (id), 18 | role role_enum default 'ro' not null, 19 | primary key (user_id, organization_id) 20 | ); 21 | 22 | create table organization_workspace_role ( 23 | organization_id uuid not null references organization (id), 24 | workspace_id uuid not null references workspace (id), 25 | role role_enum default 'ro' not null, 26 | primary key (organization_id, workspace_id) 27 | ); 28 | 29 | grant select on all tables in schema public to conch_read_only; 30 | 31 | $$); 32 | -------------------------------------------------------------------------------- /docs/modules/Conch::Controller::DeviceLocation.md: -------------------------------------------------------------------------------- 1 | # Conch::Controller::DeviceLocation 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/DeviceLocation.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/DeviceLocation.pm) 6 | 7 | ## METHODS 8 | 9 | ### get 10 | 11 | Retrieves location data for the current device. **Note:** This information is not considered to 12 | be canonical if the device is in the 'production' phase or later. 13 | 14 | Response uses the DeviceLocation json schema. 15 | 16 | ### set 17 | 18 | Sets the location for a device, given a valid rack id and rack unit. If there is an existing 19 | occupant, it is removed; the new occupant's hardware\_product is updated to match the layout 20 | (and its health is set to unknown if it changed). 21 | 22 | ### delete 23 | 24 | Deletes the location data for a device, provided it has been assigned to a location 25 | 26 | ## LICENSING 27 | 28 | Copyright Joyent, Inc. 29 | 30 | This Source Code Form is subject to the terms of the Mozilla Public License, 31 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 32 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 33 | -------------------------------------------------------------------------------- /lib/Conch/Validation/LinksUp.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::LinksUp; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | 5 | use constant name => 'links_up'; 6 | use constant version => 2; 7 | use constant category => 'NET'; 8 | use constant description => 'Validate that there are at least 4 NICs in the \'up\' state, not counting ipmi1'; 9 | 10 | sub validate { 11 | my ($self, $data) = @_; 12 | 13 | $self->die("Input data must include 'interfaces' hash") 14 | unless $data->{interfaces} && ref($data->{interfaces}) eq 'HASH'; 15 | 16 | my $links_up = 0; 17 | while (my ($name, $nic) = each $data->{interfaces}->%*) { 18 | next if $name eq 'ipmi1'; 19 | $links_up++ if ($nic->{state} && $nic->{state} eq 'up'); 20 | } 21 | 22 | $self->register_result( 23 | expected => 4, 24 | cmp => '>=', 25 | got => $links_up 26 | ); 27 | } 28 | 29 | 1; 30 | __END__ 31 | 32 | =pod 33 | 34 | =head1 LICENSING 35 | 36 | Copyright Joyent, Inc. 37 | 38 | This Source Code Form is subject to the terms of the Mozilla Public License, 39 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 40 | one at L. 41 | 42 | =cut 43 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Result::ValidationPlanMember.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Result::ValidationPlanMember 4 | 5 | # BASE CLASS: [Conch::DB::Result](/modules/Conch::DB::Result) 6 | 7 | # TABLE: `validation_plan_member` 8 | 9 | # ACCESSORS 10 | 11 | ## validation\_id 12 | 13 | ``` 14 | data_type: 'uuid' 15 | is_foreign_key: 1 16 | is_nullable: 0 17 | size: 16 18 | ``` 19 | 20 | ## validation\_plan\_id 21 | 22 | ``` 23 | data_type: 'uuid' 24 | is_foreign_key: 1 25 | is_nullable: 0 26 | size: 16 27 | ``` 28 | 29 | # PRIMARY KEY 30 | 31 | - ["validation\_id"](#validation_id) 32 | - ["validation\_plan\_id"](#validation_plan_id) 33 | 34 | # RELATIONS 35 | 36 | ## validation 37 | 38 | Type: belongs\_to 39 | 40 | Related object: [Conch::DB::Result::Validation](/modules/Conch::DB::Result::Validation) 41 | 42 | ## validation\_plan 43 | 44 | Type: belongs\_to 45 | 46 | Related object: [Conch::DB::Result::ValidationPlan](/modules/Conch::DB::Result::ValidationPlan) 47 | 48 | # LICENSING 49 | 50 | Copyright Joyent, Inc. 51 | 52 | This Source Code Form is subject to the terms of the Mozilla Public License, 53 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 54 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 55 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::WorkspaceUser.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::WorkspaceUser 4 | 5 | # METHODS 6 | 7 | ## list 8 | 9 | Get a list of users for the current workspace. 10 | 11 | Response uses the WorkspaceUsers json schema. 12 | 13 | ## add\_user 14 | 15 | Adds a user to the current workspace (as specified by :workspace\_id in the path), or upgrades an 16 | existing permission to a workspace. 17 | 18 | Optionally takes a query parameter 'send\_mail' (defaulting to true), to send an email 19 | to the user. 20 | 21 | ## remove 22 | 23 | Removes the indicated user from the workspace, as well as all sub-workspaces. 24 | Requires 'admin' permissions on the workspace. 25 | 26 | Note this may not have the desired effect if the user is getting access to the workspace via 27 | a parent workspace. When in doubt, check at `GET /user/`. 28 | 29 | Optionally takes a query parameter 'send\_mail' (defaulting to true), to send an email 30 | to the user. 31 | 32 | # LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 39 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Route::HardwareProduct.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Route::HardwareProduct 4 | 5 | # METHODS 6 | 7 | ## routes 8 | 9 | Sets up the routes for /hardware\_product: 10 | 11 | Unless otherwise noted, all routes require authentication. 12 | 13 | ### `GET /hardware_product` 14 | 15 | - Response: response.yaml#/HardwareProducts 16 | 17 | ### `POST /hardware_product` 18 | 19 | - Requires System Admin Authentication 20 | - Request: input.yaml#/HardwareProductCreate 21 | - Response: Redirect to the created hardware product 22 | 23 | ### `GET /hardware_product/:identifier` 24 | 25 | - Response: response.yaml#/HardwareProduct 26 | 27 | ### `POST /hardware_product/:identifier` 28 | 29 | - Requires System Admin Authentication 30 | - Request: input.yaml#/HardwareProductUpdate 31 | - Response: Redirect to the updated hardware product 32 | 33 | ### `DELETE /hardware_product/:identifier` 34 | 35 | - Requires System Admin Authentication 36 | - Response: `204 NO CONTENT` 37 | 38 | # LICENSING 39 | 40 | Copyright Joyent, Inc. 41 | 42 | This Source Code Form is subject to the terms of the Mozilla Public License, 43 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 44 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 45 | -------------------------------------------------------------------------------- /docs/_resources/roles.er: -------------------------------------------------------------------------------- 1 | title {label: "Conch database schema (as of v3.1.2, 2020-12-10): role management", size: "40"} 2 | 3 | entity {bgcolor: "#ececfc", size: "20"} 4 | 5 | [user_account] 6 | *id 7 | name 8 | password {label: "encrypted"} 9 | created 10 | last_login 11 | email 12 | deactivated 13 | refuse_session_auth 14 | force_password_change 15 | is_admin 16 | last_seen 17 | 18 | [organization] 19 | *id 20 | name 21 | description 22 | created 23 | deactivated 24 | 25 | [build] 26 | *id 27 | name 28 | description 29 | created 30 | started 31 | completed 32 | +completed_user_id 33 | links 34 | completed_status 35 | 36 | [user_build_role] {bgcolor: "#d0e0d0"} 37 | *+user_id 38 | *+build_id 39 | role {label: "ro, rw, admin"} 40 | 41 | [user_organization_role] {bgcolor: "#d0e0d0"} 42 | *+user_id 43 | *+organization_id 44 | role {label: "ro, rw, admin"} 45 | 46 | [organization_build_role] {bgcolor: "#d0e0d0"} 47 | *+organization_id 48 | *+build_id 49 | role {label: "ro, rw, admin"} 50 | 51 | user_organization_role +--1 organization 52 | user_organization_role *--1 user_account 53 | user_build_role +--1 build 54 | user_build_role *--1 user_account 55 | organization_build_role *--1 build 56 | organization_build_role *--1 organization 57 | build *--? user_account {label: "completed by", size: "14"} 58 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::ValidationPlan.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::Validation 4 | 5 | Controller for managing Validation Plans 6 | 7 | # METHODS 8 | 9 | ## create 10 | 11 | Create new Validation Plan. 12 | 13 | ## list 14 | 15 | List all available Validation Plans. 16 | 17 | Response uses the ValidationPlans json schema. 18 | 19 | ## find\_validation\_plan 20 | 21 | Find the Validation Plan specified by uuid or name and put it in the stash as 22 | `validation_plan`. 23 | 24 | ## get 25 | 26 | Get the (active) Validation Plan specified by uuid or name. 27 | 28 | Response uses the ValidationPlan json schema. 29 | 30 | ## list\_validations 31 | 32 | List all Validations associated with the Validation Plan, both active and deactivated. 33 | 34 | Response uses the Validations json schema. 35 | 36 | ## add\_validation 37 | 38 | Add a validation to a validation plan. 39 | 40 | ## remove\_validation 41 | 42 | Remove a Validation associated with the Validation Plan 43 | 44 | # LICENSING 45 | 46 | Copyright Joyent, Inc. 47 | 48 | This Source Code Form is subject to the terms of the Mozilla Public License, 49 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 50 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 51 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::ResultsExist.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::ResultsExist 4 | 5 | # DESCRIPTION 6 | 7 | A component for [Conch::DB::ResultSet](/modules/Conch::DB::ResultSet) classes that provides the `exists` method. 8 | 9 | See also [DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist](https://metacpan.org/pod/DBIx::Class::Helper::ResultSet::Shortcut::ResultsExist), which is not usable in its 10 | present form due to [https://github.com/frioux/DBIx-Class-Helpers/issues/54](https://github.com/frioux/DBIx-Class-Helpers/issues/54). 11 | 12 | This code is postgres-specific. 13 | 14 | # USAGE 15 | 16 | ``` 17 | __PACKAGE__->load_components('+Conch::DB::ResultsExist'); 18 | ``` 19 | 20 | # METHODS 21 | 22 | ## exists 23 | 24 | Efficiently efficiently determines if a result exists, without needing to do a `->count`. 25 | Essentially does: 26 | 27 | ``` 28 | select exists (select 1 from ... rest of your query ...); 29 | ``` 30 | 31 | Returns a value that you can treat as a boolean. 32 | 33 | # LICENSING 34 | 35 | Copyright Joyent, Inc. 36 | 37 | This Source Code Form is subject to the terms of the Mozilla Public License, 38 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 39 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 40 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Plugin::AuthHelpers.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Plugin::AuthHelpers 4 | 5 | # DESCRIPTION 6 | 7 | Contains all convenience handlers for authentication 8 | 9 | # HELPERS 10 | 11 | ## is\_system\_admin 12 | 13 | ``` 14 | return $c->status(403) if not $c->is_system_admin; 15 | ``` 16 | 17 | Verifies that the currently stashed user has the 'is\_admin' flag set 18 | 19 | ## is\_workspace\_admin 20 | 21 | ``` 22 | return $c->status(403) if not $c->is_workspace_admin; 23 | ``` 24 | 25 | Verifies that the currently stashed user\_id has 'admin' permission on the current workspace (as 26 | specified by :workspace\_id in the path) or one of its ancestors. 27 | 28 | ## user\_has\_workspace\_auth 29 | 30 | Verifies that the currently stashed user\_id has (at least) this auth role on the specified 31 | workspace (as indicated by :workspace\_id in the path). 32 | 33 | Users with the admin flag set will always return true, even if no user\_workspace\_role records 34 | are present. 35 | 36 | # LICENSING 37 | 38 | Copyright Joyent, Inc. 39 | 40 | This Source Code Form is subject to the terms of the Mozilla Public License, 41 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 42 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 43 | -------------------------------------------------------------------------------- /lib/Conch/Validation/SasSsdNum.pm: -------------------------------------------------------------------------------- 1 | package Conch::Validation::SasSsdNum; 2 | 3 | use Mojo::Base 'Conch::Validation'; 4 | use v5.20; 5 | 6 | use constant name => 'sas_ssd_num'; 7 | use constant version => 2; 8 | use constant category => 'DISK'; 9 | use constant description => 'Validate expected number of SAS SSDs'; 10 | 11 | sub validate { 12 | my ($self, $data) = @_; 13 | 14 | $self->die("Input data must include 'disks' hash") 15 | unless $data->{disks} && ref($data->{disks}) eq 'HASH'; 16 | 17 | my @disks_with_drive_type = 18 | grep { $_->{drive_type} } (values $data->{disks}->%*); 19 | 20 | my $sas_ssd_count = grep { 21 | fc($_->{drive_type}) eq fc('SAS_SSD') 22 | } @disks_with_drive_type; 23 | 24 | my $sas_ssd_want = $self->hardware_product->sas_ssd_num; 25 | 26 | $self->register_result( 27 | expected => $sas_ssd_want, 28 | got => $sas_ssd_count, 29 | ); 30 | } 31 | 32 | 1; 33 | __END__ 34 | 35 | =pod 36 | 37 | =head1 LICENSING 38 | 39 | Copyright Joyent, Inc. 40 | 41 | This Source Code Form is subject to the terms of the Mozilla Public License, 42 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 43 | one at L. 44 | 45 | =cut 46 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Helper::Row::WithRole.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Helper::Row::WithRole 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/WithRole.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/WithRole.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | A component for [Conch::DB::Result](../modules/Conch%3A%3ADB%3A%3AResult) classes for database tables with a `role` 10 | column, to provide common functionality. 11 | 12 | ## USAGE 13 | 14 | ``` 15 | __PACKAGE__->load_components('+Conch::DB::Helper::Row::WithRole'); 16 | ``` 17 | 18 | ## METHODS 19 | 20 | ### role\_cmp 21 | 22 | Acts like the `cmp` operator, returning -1, 0 or 1 depending on whether the first role is less 23 | than, the same as, or greater than the second role. 24 | 25 | If only one role argument is passed, the role in the current row is compared to the passed-in 26 | role. 27 | 28 | Accepts undef for one or both roles, which always compare as less than a defined role. 29 | 30 | ## LICENSING 31 | 32 | Copyright Joyent, Inc. 33 | 34 | This Source Code Form is subject to the terms of the Mozilla Public License, 35 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 36 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 37 | -------------------------------------------------------------------------------- /docs/modules/Conch::Plugin::AuthHelpers.md: -------------------------------------------------------------------------------- 1 | # Conch::Plugin::AuthHelpers 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/AuthHelpers.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Plugin/AuthHelpers.pm) 6 | 7 | ## METHODS 8 | 9 | ### register 10 | 11 | Sets up all convenience handlers for authentication. 12 | 13 | ## HELPERS 14 | 15 | These methods are made available on the `$c` object (the invocant of all controller methods, 16 | and therefore other helpers). 17 | 18 | ### is\_system\_admin 19 | 20 | ``` 21 | return $c->status(403) if not $c->is_system_admin; 22 | ``` 23 | 24 | Verifies that the currently stashed user has the `is_admin` flag set. 25 | 26 | ### generate\_jwt 27 | 28 | Generates a session token for the specified user and stores it in the database. 29 | Returns the new row and the JWT. 30 | 31 | `expires` is an epoch time. 32 | 33 | ### generate\_jwt\_from\_token 34 | 35 | Given a session token, generate a JWT for it. 36 | 37 | ## LICENSING 38 | 39 | Copyright Joyent, Inc. 40 | 41 | This Source Code Form is subject to the terms of the Mozilla Public License, 42 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 43 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 44 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::ResultSet::DeviceNic.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::ResultSet::DeviceNic 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/DeviceNic.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/ResultSet/DeviceNic.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | Interface to queries involving device network interfaces. 10 | 11 | ## METHODS 12 | 13 | ### nic\_pxe 14 | 15 | Returns a resultset which provides the MAC address of the relevant PXE network interface(s) 16 | (the first-by-name interface whose state = 'up'). 17 | 18 | Suitable for embedding as a sub-query. 19 | 20 | ### nic\_ipmi 21 | 22 | Returns a resultset which provides the MAC address and IP address (as an arrayref) of the 23 | network interface(s) named "ipmi1". 24 | 25 | Suitable for embedding as a sub-query; post-processing will be required to extract the two 26 | columns into the desired format. 27 | 28 | ### fields 29 | 30 | The list of fields associated with each network interface entry. 31 | 32 | ## LICENSING 33 | 34 | Copyright Joyent, Inc. 35 | 36 | This Source Code Form is subject to the terms of the Mozilla Public License, 37 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 38 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 39 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::DB::Result::ValidationStateMember.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::DB::Result::ValidationStateMember 4 | 5 | # BASE CLASS: [Conch::DB::Result](/modules/Conch::DB::Result) 6 | 7 | # TABLE: `validation_state_member` 8 | 9 | # ACCESSORS 10 | 11 | ## validation\_state\_id 12 | 13 | ``` 14 | data_type: 'uuid' 15 | is_foreign_key: 1 16 | is_nullable: 0 17 | size: 16 18 | ``` 19 | 20 | ## validation\_result\_id 21 | 22 | ``` 23 | data_type: 'uuid' 24 | is_foreign_key: 1 25 | is_nullable: 0 26 | size: 16 27 | ``` 28 | 29 | # PRIMARY KEY 30 | 31 | - ["validation\_state\_id"](#validation_state_id) 32 | - ["validation\_result\_id"](#validation_result_id) 33 | 34 | # RELATIONS 35 | 36 | ## validation\_result 37 | 38 | Type: belongs\_to 39 | 40 | Related object: [Conch::DB::Result::ValidationResult](/modules/Conch::DB::Result::ValidationResult) 41 | 42 | ## validation\_state 43 | 44 | Type: belongs\_to 45 | 46 | Related object: [Conch::DB::Result::ValidationState](/modules/Conch::DB::Result::ValidationState) 47 | 48 | # LICENSING 49 | 50 | Copyright Joyent, Inc. 51 | 52 | This Source Code Form is subject to the terms of the Mozilla Public License, 53 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 54 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 55 | -------------------------------------------------------------------------------- /sql/migrations/0131-builds.sql: -------------------------------------------------------------------------------- 1 | SELECT run_migration(131, $$ 2 | 3 | create table build ( 4 | id uuid default gen_random_uuid() not null primary key, 5 | name text not null constraint build_name_key unique, 6 | description text, 7 | created timestamp with time zone default now() not null, 8 | started timestamp with time zone, 9 | completed timestamp with time zone, 10 | completed_user_id uuid references user_account (id) 11 | ); 12 | 13 | create table user_build_role ( 14 | user_id uuid not null references user_account (id), 15 | build_id uuid not null references build (id), 16 | role role_enum default 'ro' not null, 17 | primary key (user_id, build_id) 18 | ); 19 | 20 | create table organization_build_role ( 21 | organization_id uuid not null references organization (id), 22 | build_id uuid not null references build (id), 23 | role role_enum default 'ro' not null, 24 | primary key (organization_id, build_id) 25 | ); 26 | 27 | grant select on all tables in schema public to conch_read_only; 28 | 29 | alter table rack add column build_id uuid default null references build (id); 30 | alter table device add column build_id uuid default null references build (id); 31 | 32 | $$); 33 | -------------------------------------------------------------------------------- /docs/modules/Conch::Controller::DeviceSettings.md: -------------------------------------------------------------------------------- 1 | # Conch::Controller::DeviceSettings 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/DeviceSettings.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/Controller/DeviceSettings.pm) 6 | 7 | ## METHODS 8 | 9 | ### set\_all 10 | 11 | Overrides all settings for a device with the given payload. 12 | Existing settings are deactivated even if they are not being replaced with new ones. 13 | 14 | ### set\_single 15 | 16 | Sets a single setting on a device. If the setting already exists, it is 17 | overwritten, unless the value is unchanged. 18 | 19 | ### get\_all 20 | 21 | Get all settings for a device as a hash 22 | 23 | Response uses the DeviceSettings json schema. 24 | 25 | ### get\_single 26 | 27 | Get a single setting from a device 28 | 29 | Response uses the DeviceSetting json schema. 30 | 31 | ### delete\_single 32 | 33 | Delete a single setting from a device, provide that setting was previously set 34 | 35 | ## LICENSING 36 | 37 | Copyright Joyent, Inc. 38 | 39 | This Source Code Form is subject to the terms of the Mozilla Public License, 40 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 41 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 42 | -------------------------------------------------------------------------------- /docs/modules/Conch::DB::Helper::Row::WithPhase.md: -------------------------------------------------------------------------------- 1 | # Conch::DB::Helper::Row::WithPhase 2 | 3 | ## SOURCE 4 | 5 | [https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/WithPhase.pm](https://github.com/joyent/conch-api/blob/master/lib/Conch/DB/Helper/Row/WithPhase.pm) 6 | 7 | ## DESCRIPTION 8 | 9 | A component for [Conch::DB::Result](../modules/Conch%3A%3ADB%3A%3AResult) classes for database tables with a `phase` column, to 10 | provide common functionality. 11 | 12 | ## USAGE 13 | 14 | ``` 15 | __PACKAGE__->load_components('+Conch::DB::Helper::Row::WithPhase'); 16 | ``` 17 | 18 | ## METHODS 19 | 20 | ### phase\_cmp 21 | 22 | Acts like the `cmp` operator, returning -1, 0 or 1 depending on whether the first phase is 23 | less than, the same as, or greater than the second phase. 24 | 25 | If only one phase argument is passed, the phase in the current row is compared to the passed-in 26 | phase. 27 | 28 | Accepts undef for one or both phases, which always compare as less than a defined phase. 29 | 30 | ## LICENSING 31 | 32 | Copyright Joyent, Inc. 33 | 34 | This Source Code Form is subject to the terms of the Mozilla Public License, 35 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 36 | one at [https://www.mozilla.org/en-US/MPL/2.0/](https://www.mozilla.org/en-US/MPL/2.0/). 37 | -------------------------------------------------------------------------------- /docs/versions/v2/modules/Conch::Controller::DeviceValidation.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Conch::Controller::DeviceValidation 4 | 5 | # METHODS 6 | 7 | ## list\_validation\_states 8 | 9 | Get the latest validation states for a device. Accepts the query parameter 'status', 10 | indicating the desired status(es) (comma-separated) to search for -- one or more of: 11 | pass, fail, error. 12 | 13 | Response uses the ValidationStatesWithResults json schema. 14 | 15 | ## validate 16 | 17 | Validate the device against the specified validation. 18 | 19 | **DOES NOT STORE VALIDATION RESULTS**. 20 | 21 | This is useful for testing and evaluating Validation Plans against a given 22 | device. 23 | 24 | Response uses the ValidationResults json schema. 25 | 26 | ## run\_validation\_plan 27 | 28 | Validate the device against the specified Validation Plan. 29 | 30 | **DOES NOT STORE VALIDATION RESULTS**. 31 | 32 | This is useful for testing and evaluating Validation Plans against a given 33 | device. 34 | 35 | Response uses the ValidationResults json schema. 36 | 37 | # LICENSING 38 | 39 | Copyright Joyent, Inc. 40 | 41 | This Source Code Form is subject to the terms of the Mozilla Public License, 42 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 43 | one at [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/). 44 | -------------------------------------------------------------------------------- /lib/Conch/Route/ValidationState.pm: -------------------------------------------------------------------------------- 1 | package Conch::Route::ValidationState; 2 | 3 | use Mojo::Base -strict; 4 | 5 | =pod 6 | 7 | =head1 NAME 8 | 9 | Conch::Route::ValidationState 10 | 11 | =head1 METHODS 12 | 13 | =head2 routes 14 | 15 | Sets up the routes for /validation_state. 16 | 17 | =cut 18 | 19 | sub routes { 20 | my $class = shift; 21 | my $vs = shift; # secured, under /validation_state 22 | 23 | $vs->to({ controller => 'validation_state' }); 24 | 25 | # GET /validation_state/:validation_state_id 26 | $vs->get('/')->to('#get', response_schema => 'ValidationStateWithResults'); 27 | } 28 | 29 | 1; 30 | __END__ 31 | 32 | =pod 33 | 34 | =head1 ROUTE ENDPOINTS 35 | 36 | All routes require authentication. 37 | 38 | =head2 C 39 | 40 | =over 4 41 | 42 | =item * Controller/Action: L 43 | 44 | =item * Response: F 45 | 46 | =back 47 | 48 | =head1 LICENSING 49 | 50 | Copyright Joyent, Inc. 51 | 52 | This Source Code Form is subject to the terms of the Mozilla Public License, 53 | v.2.0. If a copy of the MPL was not distributed with this file, You can obtain 54 | one at L. 55 | 56 | =cut 57 | # vim: set sts=2 sw=2 et : 58 | --------------------------------------------------------------------------------