Class: Morpheus::Cli::Roles
- Inherits:
-
Object
- Object
- Morpheus::Cli::Roles
- Includes:
- AccountsHelper, CliCommand, ProvisioningHelper, WhoamiHelper
- Defined in:
- lib/morpheus/cli/commands/roles.rb
Instance Attribute Summary
Attributes included from CliCommand
Instance Method Summary collapse
- #_get(id, options = {}) ⇒ Object
- #add(args) ⇒ Object
- #connect(opts) ⇒ Object
- #get(args) ⇒ Object
- #handle(args) ⇒ Object
- #list(args) ⇒ Object
- #list_permissions(args) ⇒ Object
- #remove(args) ⇒ Object
- #update(args) ⇒ Object
- #update_blueprint_access(args) ⇒ Object
- #update_catalog_item_type_access(args) ⇒ Object
- #update_cloud_access(args) ⇒ Object
- #update_default_blueprint_access(args) ⇒ Object
- #update_default_catalog_item_type_access(args) ⇒ Object
- #update_default_cloud_access(args) ⇒ Object
- #update_default_group_access(args) ⇒ Object
- #update_default_instance_type_access(args) ⇒ Object
- #update_default_persona_access(args) ⇒ Object
- #update_default_report_type_access(args) ⇒ Object
- #update_default_task_access(args) ⇒ Object
- #update_default_vdi_pool_access(args) ⇒ Object
- #update_default_workflow_access(args) ⇒ Object
- #update_feature_access(args) ⇒ Object
- #update_global_blueprint_access(args) ⇒ Object
- #update_global_catalog_item_type_access(args) ⇒ Object
- #update_global_cloud_access(args) ⇒ Object
- #update_global_group_access(args) ⇒ Object
- #update_global_instance_type_access(args) ⇒ Object
- #update_global_report_type_access(args) ⇒ Object
- #update_global_task_access(args) ⇒ Object
- #update_global_vdi_pool_access(args) ⇒ Object
- #update_global_workflow_access(args) ⇒ Object
- #update_group_access(args) ⇒ Object
- #update_instance_type_access(args) ⇒ Object
- #update_persona_access(args) ⇒ Object
- #update_report_type_access(args) ⇒ Object
- #update_task_access(args) ⇒ Object
- #update_vdi_pool_access(args) ⇒ Object
- #update_workflow_access(args) ⇒ Object
Methods included from WhoamiHelper
#current_account, #current_user, #current_user_permissions, included, #is_master_account, #load_whoami
Methods included from ProvisioningHelper
#accounts_interface, #add_perms_options, #api_client, #apps_interface, #cloud_datastores_interface, #clouds_interface, #datastores_interface, #find_app_by_id, #find_app_by_name, #find_app_by_name_or_id, #find_cloud_by_id_for_provisioning, #find_cloud_by_name_for_provisioning, #find_cloud_by_name_or_id_for_provisioning, #find_cloud_resource_pool_by_name_or_id, #find_group_by_id_for_provisioning, #find_group_by_name_for_provisioning, #find_group_by_name_or_id_for_provisioning, #find_host_by_id, #find_host_by_name, #find_host_by_name_or_id, #find_instance_by_id, #find_instance_by_name, #find_instance_by_name_or_id, #find_instance_type_by_code, #find_instance_type_by_id, #find_instance_type_by_name, #find_instance_type_by_name_or_id, #find_instance_type_layout_by_id, #find_server_by_id, #find_server_by_name, #find_server_by_name_or_id, #find_workflow_by_id, #find_workflow_by_name, #find_workflow_by_name_or_id, #format_app_status, #format_blueprint_type, #format_container_connection_string, #format_container_status, #format_instance_connection_string, #format_instance_container_display_name, #format_instance_status, #format_metadata, #format_snapshot_status, #get_available_accounts, #get_available_clouds, #get_available_environments, #get_available_groups, #get_available_plans, #get_provision_type_for_zone_type, #get_static_environments, included, #instance_type_layouts_interface, #instance_types_interface, #instances_interface, #load_balance_protocols_dropdown, #options_interface, #parse_blueprint_type, #parse_host_id_list, #parse_instance_id_list, #parse_metadata, #parse_resource_id_list, #parse_server_id_list, #print_permissions, #prompt_evars, #prompt_exposed_ports, #prompt_instance_load_balancer, #prompt_metadata, #prompt_network_interfaces, #prompt_new_instance, #prompt_permissions, #prompt_permissions_v2, #prompt_resize_volumes, #prompt_security_groups, #prompt_service_plan_options, #prompt_volumes, #provision_types_interface, #reject_service_plan_option_types, #servers_interface
Methods included from AccountsHelper
#account_column_definitions, #account_users_interface, #accounts_interface, #find_account_by_id, #find_account_by_name, #find_account_by_name_or_id, #find_account_from_options, #find_all_user_ids, #find_role_by_id, #find_role_by_name, #find_role_by_name_or_id, #find_user_by_id, #find_user_by_username, #find_user_by_username_or_id, #find_user_group_by_id, #find_user_group_by_name, #find_user_group_by_name_or_id, #format_access_string, #format_role_type, #format_user_role_names, #format_user_status, #get_access_color, #get_access_string, included, #list_account_column_definitions, #list_user_column_definitions, #list_user_group_column_definitions, #role_column_definitions, #roles_interface, #subtenant_role_column_definitions, #user_column_definitions, #user_group_column_definitions, #user_groups_interface
Methods included from CliCommand
#add_query_parameter, #apply_options, #build_common_options, #build_get_options, #build_list_options, #build_option_type_options, #build_payload, #build_standard_add_options, #build_standard_api_options, #build_standard_delete_options, #build_standard_get_options, #build_standard_list_options, #build_standard_post_options, #build_standard_put_options, #build_standard_remove_options, #build_standard_update_options, #command_description, #command_name, #confirm, #confirm!, #default_refresh_interval, #default_sigdig, #default_subcommand, #establish_remote_appliance_connection, #find_all, #find_all_json, #find_by_id, #find_by_name, #find_by_name_or_id, #find_record, #find_record_json, #full_command_usage, #get_interface, #get_list_key, #get_object_key, #get_subcommand_description, #handle_subcommand, included, #interactive?, #my_help_command, #my_terminal, #my_terminal=, #parse_array, #parse_bytes_param, #parse_get_options!, #parse_id_list, #parse_labels, #parse_list_options, #parse_list_options!, #parse_list_subtitles, #parse_parameter_as_resource_id!, #parse_passed_options, #parse_payload, #parse_query_options, #print, #print_error, #println, #prog_name, #puts, #puts_error, #raise_args_error, #raise_command_error, #render_response, #run_command_for_each_arg, #subcommand_aliases, #subcommand_description, #subcommand_usage, #subcommands, #usage, #validate_outfile, #verify_args!, #visible_subcommands
Instance Method Details
#_get(id, options = {}) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/morpheus/cli/commands/roles.rb', line 162 def _get(id, ={}) args = [id] # heh params = {} account = () account_id = account ? account['id'] : nil params.merge!(()) @roles_interface.setopts() if [:dry_run] if args[0].to_s =~ /\A\d{1,}\Z/ print_dry_run @roles_interface.dry.get(account_id, args[0].to_i) else print_dry_run @roles_interface.dry.list(account_id, {name: args[0]}) end return end load_whoami() json_response = nil role = nil if args[0].to_s =~ /\A\d{1,}\Z/ json_response = @roles_interface.get(account_id, args[0].to_i) role = json_response['role'] else role = find_role_by_name_or_id(account_id, args[0]) exit 1 if role.nil? # refetch from show action, argh json_response = @roles_interface.get(account_id, role['id']) role = json_response['role'] end render_response(json_response, , 'role') do print cyan print_h1 "Role Details", print cyan columns = @is_master_account ? role_column_definitions : subtenant_role_column_definitions print_description_list(columns, role, ) print_h2 "Permissions", print cyan if [:include_feature_access] || [:include_all_access] rows = json_response['featurePermissions'].collect do |it| { code: it['code'], name: it['name'], subCategory: it['subCategory'], access: format_access_string(it['access']), } end if [:sort] rows.sort! {|a,b| a[[:sort]] <=> b[[:sort]] } end if [:direction] == 'desc' rows.reverse! end if [:phrase] phrase_regexp = /#{Regexp.escape([:phrase])}/i rows = rows.select {|row| row[:code].to_s =~ phrase_regexp || row[:name].to_s =~ phrase_regexp } end print as_pretty_table(rows, [:code, :name, :subCategory, :access], ) # print reset,"\n" else print cyan,"Use --feature-access to list feature access","\n" end has_group_access = true has_cloud_access = true print_h2 "Default Access", global_access_columns = { "Groups" => lambda {|it| get_access_string(it['globalSiteAccess']) }, "Clouds" => lambda {|it| get_access_string(it['globalZoneAccess']) }, "Instance Types" => lambda {|it| get_access_string(it['globalInstanceTypeAccess']) }, "Blueprints" => lambda {|it| get_access_string(it['globalAppTemplateAccess'] || it['globalBlueprintAccess']) }, "Personas" => lambda {|it| get_access_string(it['globalPersonaAccess']) }, "Report Types" => lambda {|it| get_access_string(it['globalReportTypeAccess']) }, "Catalog Item Types" => lambda {|it| get_access_string(it['globalCatalogItemTypeAccess']) }, "VDI Pools" => lambda {|it| get_access_string(it['globalVdiPoolAccess']) }, "Workflows" => lambda {|it| get_access_string(it['globalTaskSetAccess']) }, "Tasks" => lambda {|it| get_access_string(it['globalTaskAccess']) }, } if role['roleType'].to_s.downcase == 'account' global_access_columns.delete("Groups") has_group_access = false else global_access_columns.delete("Clouds") has_cloud_access = false end print as_pretty_table([json_response], global_access_columns, ) if has_group_access #print_h2 "Group Access: #{get_access_string(json_response['globalSiteAccess'])}", options print cyan if json_response['sites'].find {|it| !it['access'].nil?} print_h2 "Group Access", if [:include_group_access] || [:include_all_access] rows = json_response['sites'].select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","read","full"]), } end print as_pretty_table(rows, [:name, :access], ) else print cyan,"Use -g, --group-access to list custom access","\n" end # print reset,"\n" else # print "\n" # print cyan,bold,"Group Access: #{get_access_string(json_response['globalSiteAccess'])}",reset,"\n" end end if has_cloud_access print cyan #puts "Cloud Access: #{get_access_string(json_response['globalZoneAccess'])}" #print "\n" if json_response['sites'].find{|it| !it['access'].nil?} print_h2 "Cloud Access", if [:include_cloud_access] || [:include_all_access] rows = json_response['zones'].select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","read","full"]), } end print as_pretty_table(rows, [:name, :access], ) else print cyan,"Use -c, --cloud-access to list custom access","\n" end # print reset,"\n" else # print "\n" # print cyan,bold,"Cloud Access: #{get_access_string(json_response['globalZoneAccess'])}",reset,"\n" end end print cyan # puts "Instance Type Access: #{get_access_string(json_response['globalInstanceTypeAccess'])}" # print "\n" instance_type_global_access = json_response['globalInstanceTypeAccess'] = role['instanceTypes'] ? role['instanceTypes'] : (json_response['instanceTypePermissions'] || []) # if have any custom, then we want to show the flag indicator # if including, show if [:include_instance_type_access] || [:include_all_access] print_h2 "Instance Type Access", rows = .collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","read","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Instance Type Access", print cyan,"Use -i, --instance-type-access to list custom access","\n" end blueprint_global_access = json_response['globalAppTemplateAccess'] || json_response['globalBlueprintAccess'] = (role['appTemplates'] || role['blueprints']) ? (role['appTemplates'] || role['blueprints']) : (json_response['appTemplatePermissions'] || json_response['blueprintPermissions'] || []) print cyan if [:include_blueprint_access] || [:include_all_access] print_h2 "Blueprint Access", rows = .select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","read","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Blueprint Access", print cyan,"Use -b, --blueprint-access to list custom access","\n" end catalog_item_type_global_access = json_response['globalCatalogItemTypeAccess'] = role['catalogItemTypes'] ? role['catalogItemTypes'] : (json_response['catalogItemTypePermissions'] || []) print cyan if [:include_catalog_item_type_access] || [:include_all_access] print_h2 "Catalog Item Type Access", rows = .select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","read","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Catalog Item Type Access", print cyan,"Use --catalog-item-type-access to list access","\n" end persona_global_access = json_response['globalPersonaAccess'] = role['personas'] ? role['personas'] : (json_response['personaPermissions'] || []) print cyan if [:include_persona_access] || [:include_all_access] print_h2 "Persona Access", rows = .collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Persona Access", print cyan,"Use --persona-access to list access","\n" end vdi_pool_global_access = json_response['globalVdiPoolAccess'] = role['vdiPools'] ? role['vdiPools'] : (json_response['vdiPoolPermissions'] || []) print cyan if [:include_vdi_pool_access] || [:include_all_access] print_h2 "VDI Pool Access", rows = .select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "VDI Pool Access", print cyan,"Use --vdi-pool-access to list custom access","\n" end report_type_global_access = json_response['globalReportTypeAccess'] = role['reportTypes'] ? role['reportTypes'] : (json_response['reportTypePermissions'] || []) print cyan if [:include_report_type_access] || [:include_all_access] print_h2 "Report Type Access", rows = .select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Report Type Access", print cyan,"Use --report-type-access to list custom access","\n" end task_global_access = json_response['globalTaskAccess'] = role['tasks'] ? role['tasks'] : (json_response['taskPermissions'] || []) print cyan if [:include_task_access] || [:include_all_access] print_h2 "Task Access", rows = .collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Task Access", print cyan,"Use --task-access to list custom access","\n" end workflow_global_access = json_response['globalTaskSetAccess'] = role['taskSets'] ? role['taskSets'] : (json_response['taskSetPermissions'] || []) print cyan if [:include_workflow_access] || [:include_all_access] print_h2 "Workflow", rows = .select {|it| !it['access'].nil?}.collect do |it| { name: it['name'], access: format_access_string(it['access'], ["none","full"]), } end print as_pretty_table(rows, [:name, :access], ) elsif .find {|it| !it['access'].nil?} print_h2 "Workflow", print cyan,"Use --workflow-access to list custom access","\n" end print reset,"\n" return 0, nil end end |
#add(args) ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
# File 'lib/morpheus/cli/commands/roles.rb', line 554 def add(args) = {} params = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[name] [options]") (opts, , add_role_option_types) opts.on('--permissions CODE=ACCESS', String, "Set feature permission access by permission code. Example: dashboard=read,operations-wiki=full" ) do |val| [:permissions] ||= {} parse_access_csv([:permissions], val, args, optparse) end opts.add_hidden_option('--permissions') opts.on('--feature-access CODE=ACCESS', String, "Set feature permission access by permission code. Example: dashboard=read,operations-wiki=full" ) do |val| [:permissions] ||= {} parse_access_csv([:permissions], val, args, optparse) end opts.on('--global-group-access ACCESS', String, "Update the global group (site) access: [none|read|full]" ) do |val| params['globalSiteAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-group-access') opts.on('--default-group-access ACCESS', String, "Update the default group (site) access: [none|read|full]" ) do |val| params['globalSiteAccess'] = val.to_s.downcase end opts.on('--groups ID=ACCESS', String, "Set group (site) to a custom access by group id. Example: 1=none,2=full,3=read" ) do |val| [:group_permissions] ||= {} parse_access_csv([:group_permissions], val, args, optparse) end opts.on('--global-cloud-access ACCESS', String, "Update the global cloud (zone) access: [none|read|full]" ) do |val| params['globalZoneAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-cloud-access') opts.on('--default-cloud-access ACCESS', String, "Update the default cloud (zone) access: [none|read|full]" ) do |val| params['globalZoneAccess'] = val.to_s.downcase end opts.on('--clouds ID=ACCESS', String, "Set cloud (zone) to a custom access by cloud id. Example: 1=none,2=full,3=read" ) do |val| [:cloud_permissions] ||= {} parse_access_csv([:cloud_permissions], val, args, optparse) end opts.on('--global-instance-type-access ACCESS', String, "Update the global instance type access: [none|full]" ) do |val| params['globalInstanceTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-instance-type-access') opts.on('--default-instance-type-access ACCESS', String, "Update the default instance type access: [none|full]" ) do |val| params['globalInstanceTypeAccess'] = val.to_s.downcase end opts.on('--instance-types CODE=ACCESS', String, "Set instance type to a custom access instance type code. Example: nginx=full,apache=none" ) do |val| [:instance_type_permissions] ||= {} parse_access_csv([:instance_type_permissions], val, args, optparse) end opts.on('--global-blueprint-access ACCESS', String, "Update the global blueprint access: [none|full]" ) do |val| params['globalAppTemplateAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-blueprint-access') opts.on('--default-blueprint-access ACCESS', String, "Update the default blueprint access: [none|full]" ) do |val| params['globalAppTemplateAccess'] = val.to_s.downcase end opts.on('--blueprints ID=ACCESS', String, "Set blueprint to a custom access by blueprint id. Example: 1=full,2=none" ) do |val| [:blueprint_permissions] ||= {} parse_access_csv([:blueprint_permissions], val, args, optparse) end opts.on('--global-catalog-item-type-access ACCESS', String, "Update the global catalog item type access: [none|full]" ) do |val| params['globalCatalogItemTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-catalog-item-type-access') opts.on('--default-catalog-item-type-access ACCESS', String, "Update the default catalog item type access: [none|full]" ) do |val| params['globalCatalogItemTypeAccess'] = val.to_s.downcase end opts.on('--catalog-item-types CODE=ACCESS', String, "Set catalog item type to a custom access by catalog item type id. Example: 1=full,2=none" ) do |val| [:catalog_item_type_permissions] ||= {} parse_access_csv([:catalog_item_type_permissions], val, args, optparse) end opts.on('--default-persona-access ACCESS', String, "Update the default persona access: [none|full]" ) do |val| params['globalPersonaAccess'] = val.to_s.downcase end opts.on('--personas CODE=ACCESS', String, "Set persona to a custom access by persona code. Example: standard=full,serviceCatalog=full,vdi=full" ) do |val| [:persona_permissions] ||= {} parse_access_csv([:persona_permissions], val, args, optparse) end opts.on('--global-vdi-pool-access-access ACCESS', String, "Update the global VDI pool access: [none|full]" ) do |val| params['globalVdiPoolAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-vdi-pool-access-access') opts.on('--default-vdi-pool-access-access ACCESS', String, "Update the default VDI pool access: [none|full]" ) do |val| params['globalVdiPoolAccess'] = val.to_s.downcase end opts.on('--vdi-pools ID=ACCESS', String, "Set VDI pool to a custom access by VDI pool id. Example: 1=full,2=none" ) do |val| [:vdi_pool_permissions] ||= {} parse_access_csv([:vdi_pool_permissions], val, args, optparse) end opts.on('--global-report-type-access ACCESS', String, "Update the global report type access: [none|full]" ) do |val| params['globalReportTypeAccess'] = val.to_s.downcase end opts.on('--default-report-type-access ACCESS', String, "Update the default report type access: [none|full]" ) do |val| params['globalReportTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--default-report-type-access') opts.on('--report-types CODE=ACCESS', String, "Set report type to a custom access by report type code. Example: appCost=none,guidance=full" ) do |val| [:report_type_permissions] ||= {} parse_access_csv([:report_type_permissions], val, args, optparse) end opts.on('--global-task-access ACCESS', String, "Set the global task access: [none|full]" ) do |val| params['globalTaskAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-task-access') opts.on('--default-task-access ACCESS', String, "Set the default task access: [none|full]" ) do |val| params['globalTaskAccess'] = val.to_s.downcase end opts.on('--tasks ID=ACCESS', String, "Set task to a custom access by task id. Example: 1=none,2=full" ) do |val| [:task_permissions] ||= {} parse_access_csv([:task_permissions], val, args, optparse) end opts.on('--global-workflow-access ACCESS', String, "Set the default workflow access: [none|full]" ) do |val| params['globalTaskSetAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-workflow-access') opts.on('--default-workflow-access ACCESS', String, "Set the default workflow access: [none|full]" ) do |val| params['globalTaskSetAccess'] = val.to_s.downcase end opts.on('--workflows ID=ACCESS', String, "Set workflow to a custom access by workflow id. Example: 1=none,2=full" ) do |val| [:workflow_permissions] ||= {} parse_access_csv([:workflow_permissions], val, args, optparse) end opts.on('--reset-permissions', "Reset all feature permission access to none. This can be used in conjunction with --permissions to recreate the feature permission access for the role." ) do [:reset_permissions] = true end opts.add_hidden_option('--reset-permissions') opts.on('--reset-feature-access', "Reset all feature permission access to none. This can be used in conjunction with --feature-access to recreate the feature permission access for the role." ) do [:reset_permissions] = true end opts.on('--reset-all-access', "Reset all access to none including permissions, global groups, instance types, etc. This can be used in conjunction with --feature-access to recreate the feature permission access for the role." ) do [:reset_all_access] = true end opts.on('--owner ID', String, "Set the owner/tenant/account for the role by account id. Only master tenants with full permission for Tenant and Role may use this option." ) do |val| params['owner'] = val end opts. = <<-EOT Create a new role. [name] is required. This is a unique name (authority) for the new role. All the role permissions and access values can be configured. Use --feature-access "CODE=ACCESS,CODE=ACCESS" to update access levels for specific feature permissions identified by code. Use --default-instance-type-access custom --instance-types "CODE=ACCESS,CODE=ACCESS" to customize instance type access. Only the specified permissions,instance types, etc. are updated. Use --reset-feature-access to set access to "none" for all unspecified feature permissions. Use --reset-all-access to set access to "none" for all unspecified feature permissions and default access values for groups, instance types, etc. EOT (opts, , [:options, :payload, :json, :dry_run, :remote]) end optparse.parse!(args) verify_args!(args:args, optparse:optparse, max:1) if args[0] [:options]['authority'] = args[0] end connect() begin load_whoami() account = () account_id = account ? account['id'] : nil = [:options] ? [:options].reject {|k,v| k.is_a?(Symbol) } : {} payload = nil if [:payload] payload = [:payload] payload.deep_merge!({'role' => }) unless .empty? else # merge -O options into normally parsed options params.deep_merge!() # argh, some options depend on others here...eg. multitenant is only available when roleType == 'user' #prompt_option_types = update_role_option_types() role_payload = params v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'authority', 'fieldLabel' => 'Name', 'type' => 'text', 'required' => true, 'displayOrder' => 1}], [:options]) role_payload['authority'] = v_prompt['authority'] v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'description', 'fieldLabel' => 'Description', 'type' => 'text', 'displayOrder' => 2}], [:options]) role_payload['description'] = v_prompt['description'] if params['owner'] if @is_master_account && has_complete_access role_payload['owner'] = params['owner'] else print_red_alert "You do not have the necessary authority to use owner option" return end elsif @is_master_account && has_complete_access v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'owner', 'fieldLabel' => 'Owner', 'type' => 'select', 'selectOptions' => , 'defaultValue' => current_account['id'], 'displayOrder' => 3}], [:options]) role_payload['owner'] = v_prompt['owner'] else role_payload['owner'] = current_account['id'] end if @is_master_account && role_payload['owner'] == current_account['id'] v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'roleType', 'fieldLabel' => 'Type', 'type' => 'select', 'selectOptions' => , 'defaultValue' => 'user', 'displayOrder' => 4}], [:options]) role_payload['roleType'] = v_prompt['roleType'] else role_payload['roleType'] = 'user' end v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'baseRole', 'fieldLabel' => 'Copy From Role', 'type' => 'select', 'selectOptions' => (role_payload), 'displayOrder' => 5}], [:options]) if v_prompt['baseRole'].to_s != '' base_role = find_role_by_name_or_id(account_id, v_prompt['baseRole']) exit 1 if base_role.nil? role_payload['baseRoleId'] = base_role['id'] end if @is_master_account && role_payload['owner'] == current_account['id'] if role_payload['roleType'] == 'user' v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'multitenant', 'fieldLabel' => 'Multitenant', 'type' => 'checkbox', 'defaultValue' => 'off', 'description' => 'A Multitenant role is automatically copied into all existing subaccounts as well as placed into a subaccount when created. Useful for providing a set of predefined roles a Customer can use', 'displayOrder' => 5}], [:options]) role_payload['multitenant'] = ['on','true'].include?(v_prompt['multitenant'].to_s) if role_payload['multitenant'] v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'multitenantLocked', 'fieldLabel' => 'Multitenant Locked', 'type' => 'checkbox', 'defaultValue' => 'off', 'description' => 'Prevents subtenants from branching off this role/modifying it.'}], [:options]) role_payload['multitenantLocked'] = ['on','true'].include?(v_prompt['multitenantLocked'].to_s) end end end # v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultPersona', 'fieldLabel' => 'Default Persona', 'type' => 'select', 'optionSource' => 'personas', 'description' => 'Default Persona'}], options[:options], @api_client) v_prompt = Morpheus::Cli::OptionTypes.prompt([{'fieldName' => 'defaultPersona', 'fieldLabel' => 'Default Persona', 'type' => 'select', 'selectOptions' => (), 'description' => 'Default Persona'}], [:options], @api_client) role_payload['defaultPersona'] = {'code' => v_prompt['defaultPersona']} unless v_prompt['defaultPersona'].to_s.strip.empty? # bulk permissions if [:permissions] perms_array = [] [:permissions].each do |k,v| perm_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => perm_code, "access" => access_value} end params['permissions'] = perms_array end if [:group_permissions] perms_array = [] [:group_permissions].each do |k,v| site_id = k access_value = v.to_s.empty? ? "none" : v.to_s if site_id =~ /\A\d{1,}\Z/ perms_array << {"id" => site_id.to_i, "access" => access_value} else perms_array << {"name" => site_id, "access" => access_value} end end params['sites'] = perms_array end if [:cloud_permissions] perms_array = [] [:cloud_permissions].each do |k,v| zone_id = k access_value = v.to_s.empty? ? "none" : v.to_s if zone_id =~ /\A\d{1,}\Z/ perms_array << {"id" => zone_id.to_i, "access" => access_value} else perms_array << {"name" => zone_id, "access" => access_value} end perms_array << {"id" => zone_id, "access" => access_value} end params['zones'] = perms_array end if [:instance_type_permissions] perms_array = [] [:instance_type_permissions].each do |k,v| instance_type_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => instance_type_code, "access" => access_value} end params['instanceTypes'] = perms_array end if [:blueprint_permissions] perms_array = [] [:blueprint_permissions].each do |k,v| blueprint_id = k access_value = v.to_s.empty? ? "none" : v.to_s if blueprint_id =~ /\A\d{1,}\Z/ perms_array << {"id" => blueprint_id.to_i, "access" => access_value} else perms_array << {"name" => blueprint_id, "access" => access_value} end end params['appTemplates'] = perms_array end if [:catalog_item_type_permissions] perms_array = [] [:catalog_item_type_permissions].each do |k,v| catalog_item_type_id = k access_value = v.to_s.empty? ? "none" : v.to_s if catalog_item_type_id =~ /\A\d{1,}\Z/ perms_array << {"id" => catalog_item_type_id.to_i, "access" => access_value} else perms_array << {"name" => catalog_item_type_id, "access" => access_value} end end params['catalogItemTypes'] = perms_array end if [:persona_permissions] perms_array = [] [:persona_permissions].each do |k,v| persona_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => persona_code, "access" => access_value} end params['personas'] = perms_array end if [:vdi_pool_permissions] perms_array = [] [:vdi_pool_permissions].each do |k,v| vdi_pool_id = k access_value = v.to_s.empty? ? "none" : v.to_s if vdi_pool_id =~ /\A\d{1,}\Z/ perms_array << {"id" => vdi_pool_id.to_i, "access" => access_value} else perms_array << {"name" => vdi_pool_id, "access" => access_value} end end params['vdiPools'] = perms_array end if [:report_type_permissions] perms_array = [] [:report_type_permissions].each do |k,v| report_type_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => report_type_code, "access" => access_value} end params['reportTypes'] = perms_array end if [:task_permissions] perms_array = [] [:task_permissions].each do |k,v| task_id = k access_value = v.to_s.empty? ? "none" : v.to_s if task_id =~ /\A\d{1,}\Z/ perms_array << {"id" => task_id.to_i, "access" => access_value} else perms_array << {"name" => task_id, "access" => access_value} end end params['tasks'] = perms_array end if [:workflow_permissions] perms_array = [] [:workflow_permissions].each do |k,v| workflow_id = k access_value = v.to_s.empty? ? "none" : v.to_s if workflow_id =~ /\A\d{1,}\Z/ perms_array << {"id" => workflow_id.to_i, "access" => access_value} else perms_array << {"name" => workflow_id, "access" => access_value} end end params['workflows'] = perms_array end if [:reset_permissions] params["resetPermissions"] = true end if [:reset_all_access] params["resetAllAccess"] = true end payload = {"role" => role_payload} end @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.create(account_id, payload) return end json_response = @roles_interface.create(account_id, payload) if [:json] print JSON.pretty_generate(json_response) print "\n" return end role = json_response['role'] display_name = role['authority'] rescue '' if account print_green_success "Added role #{display_name} to account #{account['name']}" else print_green_success "Added role #{display_name}" end get_args = [role['id']] + ([:remote] ? ["-r",[:remote]] : []) if account get_args.push "--account-id", account['id'].to_s end = [role_payload["authority"]] if account .push "--account-id", account['id'].to_s end if role_payload['owner'] .push "--account-id", role_payload['owner'].to_s end get() rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#connect(opts) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/morpheus/cli/commands/roles.rb', line 27 def connect(opts) @api_client = establish_remote_appliance_connection(opts) @whoami_interface = @api_client.whoami @account_users_interface = @api_client.account_users @accounts_interface = @api_client.accounts @roles_interface = @api_client.roles @groups_interface = @api_client.groups @options_interface = @api_client. @instances_interface = @api_client.instances @instance_types_interface = @api_client.instance_types @blueprints_interface = @api_client.blueprints @active_group_id = Morpheus::Cli::Groups.active_groups[@appliance_name] end |
#get(args) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/morpheus/cli/commands/roles.rb', line 94 def get(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role]") opts.on('-p','--permissions', "Display Permissions [deprecated]") do |val| [:include_feature_access] = true end opts.add_hidden_option('-p,') opts.on('-f','--feature-access', "Display Feature Access") do |val| [:include_feature_access] = true end opts.on('-g','--group-access', "Display Group Access") do [:include_group_access] = true end opts.on('-c','--cloud-access', "Display Cloud Access") do [:include_cloud_access] = true end opts.on('-i','--instance-type-access', "Display Instance Type Access") do [:include_instance_type_access] = true end opts.on('-b','--blueprint-access', "Display Blueprint Access") do [:include_blueprint_access] = true end opts.on(nil,'--catalog-item-type-access', "Display Catalog Item Type Access") do [:include_catalog_item_type_access] = true end opts.on(nil,'--personas', "Display Persona Access") do [:include_persona_access] = true end opts.add_hidden_option('--personas') opts.on(nil,'--persona-access', "Display Persona Access") do [:include_persona_access] = true end opts.on(nil,'--vdi-pool-access', "Display VDI Pool Access") do [:include_vdi_pool_access] = true end opts.on(nil,'--report-type-access', "Display Report Type Access") do [:include_report_type_access] = true end opts.on(nil,'--workflow-access', "Display Workflow Access") do [:include_workflow_access] = true end opts.on(nil,'--task-access', "Display Task Access") do [:include_task_access] = true end opts.on('-a','--all', "Display All Access Lists") do [:include_all_access] = true end opts.on('--account-id ID', String, "Clarify Owner of Role") do |val| if has_complete_access [:account_id] = val.to_s end end (opts, ) opts. = <<-EOT Get details about a role. [role] is required. This is the name (authority) or id of a role. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, min:1) connect() id_list = parse_id_list(args) return run_command_for_each_arg(id_list) do |arg| _get(arg, ) end end |
#handle(args) ⇒ Object
41 42 43 |
# File 'lib/morpheus/cli/commands/roles.rb', line 41 def handle(args) handle_subcommand(args) end |
#list(args) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/morpheus/cli/commands/roles.rb', line 45 def list(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[search phrase]") opts.on( '--tenant TENANT', "Tenant Filter for list of Roles." ) do |val| [:tenant] = val end (opts, ) opts. = "List roles." end optparse.parse!(args) # verify_args!(args:args, optparse:optparse, count:0) [:phrase] = args.join(" ") if args.count > 0 connect() account = () account_id = account ? account['id'] : nil params = {} params.merge!(()) @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.list(account_id, params), return 0, nil end load_whoami() if [:tenant] params[:tenant] = [:tenant] end json_response = @roles_interface.list(account_id, params) render_response(json_response, , "roles") do roles = json_response['roles'] title = "Morpheus Roles" subtitles = [] subtitles += parse_list_subtitles() print_h1 title, subtitles, if roles.empty? print cyan,"No roles found.",reset,"\n" else print cyan columns = @is_master_account ? role_column_definitions : subtenant_role_column_definitions print as_pretty_table(roles, columns.upcase_keys!, ) print_results_pagination(json_response) end print reset,"\n" end return 0, nil end |
#list_permissions(args) ⇒ Object
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/morpheus/cli/commands/roles.rb', line 448 def (args) = {} available_categories = ['feature', 'group', 'cloud', 'instance-type', 'blueprint', 'report-type', 'persona', 'catalog-item-type', 'vdi-pool', 'workflow', 'task'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [category]") (opts, , [:list, :json, :yaml, :csv, :fields, :dry_run, :remote]) opts. = "List the access for a role.\n" + "[role] is required. This is the name or id of a role.\n" + "[category] is optional. Available categories: #{ored_list(available_categories)}" end optparse.parse!(args) verify_args!(args:args, optparse:optparse, min: 1, max:2) connect() category = args[1].to_s.downcase if args[1] if !category.nil? && !available_categories.include?(category) raise_command_error("invalid category: #{category}", args, optparse) end account = () account_id = account ? account['id'] : nil @roles_interface.setopts() if [:dry_run] if args[0].to_s =~ /\A\d{1,}\Z/ print_dry_run @roles_interface.dry.get(account_id, args[0].to_i) else print_dry_run @roles_interface.dry.list(account_id, {name: args[0]}) end return end if args[0].to_s =~ /\A\d{1,}\Z/ role = @roles_interface.get(account_id, args[0].to_i) else role = find_role_by_name_or_id(account_id, args[0]) exit 1 if role.nil? role = @roles_interface.get(account_id, role['id']) end available_categories.reject! {|category| category == 'cloud'} if role['role']['roleType'] == 'user' available_categories.reject! {|category| category == 'group'} if role['role']['roleType'] == 'account' = -> (s) { return 'sites' if s == 'group' return 'zones' if s == 'cloud' s = 'task-set' if s == 'workflow' s = 'app-template' if s == 'blueprint' s.split('-').map.with_index{|s,i| i == 0 ? s : s.capitalize}.join + 'Permissions' } = -> (s) {s.split('-').collect{|s| s.capitalize}.join(' ') + ' Permissions'} if category.nil? = available_categories.reject{|category| role[.call(category)].nil?}.collect{|category| role[.call(category)].map{|perm| perm.merge({'category' => .call(category)})} }.flatten else = role[.call(category)] end if [:json] puts as_json(, ) return 0 elsif [:yaml] puts as_yaml(, ) return 0 elsif [:csv] puts records_as_csv(, :include_fields => ['category', 'id', 'code', 'name', 'access', 'sub category']) return 0 end print cyan print_h1 "Role: [#{role['role']['id']}#{(role['role']['owner'].nil? ? ']' : ", #{role['role']['owner']['name']}]")} #{role['role']['authority']}", (category.nil? ? available_categories : [category]).each do |category| = role[.call(category)] next if .nil? print_h2 "#{.call(category)}", if .size > 0 rows = .collect do |it| { code: it['code'], name: it['name'], access: format_access_string(it['access']), } end if [:sort] rows.sort! {|a,b| a[[:sort]] <=> b[[:sort]] } end if [:direction] == 'desc' rows.reverse! end if [:phrase] phrase_regexp = /#{Regexp.escape([:phrase])}/i rows = rows.select {|row| row[:code].to_s =~ phrase_regexp || row[:name].to_s =~ phrase_regexp } end print as_pretty_table(rows, [:code, :name, :access], ) else puts "No permissions found" end end print reset,"\n" end |
#remove(args) ⇒ Object
1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1292 def remove(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role]") (opts, , [:auto_confirm, :json, :dry_run, :remote]) opts. = <<-EOT Delete a role. [role] is required. This is the name (authority) or id of a role. EOT end optparse.parse!(args) if args.count < 1 puts optparse exit 1 end name = args[0] connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? unless [:yes] || Morpheus::Cli::OptionTypes.confirm("Are you sure you want to delete the role #{role['authority']}?") exit end @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.destroy(account_id, role['id']) return end json_response = @roles_interface.destroy(account_id, role['id']) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} removed" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update(args) ⇒ Object
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 |
# File 'lib/morpheus/cli/commands/roles.rb', line 953 def update(args) = {} params = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [options]") (opts, , update_role_option_types) opts.on('--permissions CODE=ACCESS', String, "Set feature permission access by permission code. Example: dashboard=read,operations-wiki=full" ) do |val| [:permissions] ||= {} parse_access_csv([:permissions], val, args, optparse) end opts.add_hidden_option('--permissions') opts.on('--feature-access CODE=ACCESS', String, "Set feature permission access by permission code. Example: dashboard=read,operations-wiki=full" ) do |val| [:permissions] ||= {} parse_access_csv([:permissions], val, args, optparse) end opts.on('--global-group-access ACCESS', String, "Update the global group (site) access: [none|read|full]" ) do |val| params['globalSiteAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-group-access') opts.on('--default-group-access ACCESS', String, "Update the default group (site) access: [none|read|full]" ) do |val| params['globalSiteAccess'] = val.to_s.downcase end opts.on('--groups ID=ACCESS', String, "Set group (site) to a custom access by group id. Example: 1=none,2=full,3=read" ) do |val| [:group_permissions] ||= {} parse_access_csv([:group_permissions], val, args, optparse) end opts.on('--global-cloud-access ACCESS', String, "Update the global cloud (zone) access: [none|read|full]" ) do |val| params['globalZoneAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-cloud-access') opts.on('--default-cloud-access ACCESS', String, "Update the default cloud (zone) access: [none|read|full]" ) do |val| params['globalZoneAccess'] = val.to_s.downcase end opts.on('--clouds ID=ACCESS', String, "Set cloud (zone) to a custom access by cloud id. Example: 1=none,2=full,3=read" ) do |val| [:cloud_permissions] ||= {} parse_access_csv([:cloud_permissions], val, args, optparse) end opts.on('--global-instance-type-access ACCESS', String, "Update the global instance type access: [none|full]" ) do |val| params['globalInstanceTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-instance-type-access') opts.on('--default-instance-type-access ACCESS', String, "Update the default instance type access: [none|full]" ) do |val| params['globalInstanceTypeAccess'] = val.to_s.downcase end opts.on('--instance-types CODE=ACCESS', String, "Set instance type to a custom access instance type code. Example: nginx=full,apache=none" ) do |val| [:instance_type_permissions] ||= {} parse_access_csv([:instance_type_permissions], val, args, optparse) end opts.on('--global-blueprint-access ACCESS', String, "Update the global blueprint access: [none|full]" ) do |val| params['globalAppTemplateAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-blueprint-access') opts.on('--default-blueprint-access ACCESS', String, "Update the default blueprint access: [none|full]" ) do |val| params['globalAppTemplateAccess'] = val.to_s.downcase end opts.on('--blueprints ID=ACCESS', String, "Set blueprint to a custom access by blueprint id. Example: 1=full,2=none" ) do |val| [:blueprint_permissions] ||= {} parse_access_csv([:blueprint_permissions], val, args, optparse) end opts.on('--global-catalog-item-type-access ACCESS', String, "Update the global catalog item type access: [none|full]" ) do |val| params['globalCatalogItemTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-catalog-item-type-access') opts.on('--default-catalog-item-type-access ACCESS', String, "Update the default catalog item type access: [none|full]" ) do |val| params['globalCatalogItemTypeAccess'] = val.to_s.downcase end opts.on('--catalog-item-types CODE=ACCESS', String, "Set catalog item type to a custom access by catalog item type id. Example: 1=full,2=none" ) do |val| [:catalog_item_type_permissions] ||= {} parse_access_csv([:catalog_item_type_permissions], val, args, optparse) end opts.on('--personas CODE=ACCESS', String, "Set persona to a custom access by persona code. Example: standard=full,serviceCatalog=full,vdi=full" ) do |val| [:persona_permissions] ||= {} parse_access_csv([:persona_permissions], val, args, optparse) end opts.on('--global-vdi-pool-access ACCESS', String, "Update the global VDI pool access: [none|full]" ) do |val| params['globalVdiPoolAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-vdi-pool-access') opts.on('--default-vdi-pool-access ACCESS', String, "Update the default VDI pool access: [none|full]" ) do |val| params['globalVdiPoolAccess'] = val.to_s.downcase end opts.on('--vdi-pools ID=ACCESS', String, "Set VDI pool to a custom access by VDI pool id. Example: 1=full,2=none" ) do |val| [:vdi_pool_permissions] ||= {} parse_access_csv([:vdi_pool_permissions], val, args, optparse) end opts.on('--global-report-type-access ACCESS', String, "Update the global report type access: [none|full]" ) do |val| params['globalReportTypeAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-report-type-access') opts.on('--default-report-type-access ACCESS', String, "Update the default report type access: [none|full]" ) do |val| params['globalReportTypeAccess'] = val.to_s.downcase end opts.on('--report-types CODE=ACCESS', String, "Set report type to a custom access by report type code. Example: appCost=none,guidance=full" ) do |val| [:report_type_permissions] ||= {} parse_access_csv([:report_type_permissions], val, args, optparse) end opts.on('--global-task-access ACCESS', String, "Update the global task access: [none|full]" ) do |val| params['globalTaskAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-task-access') opts.on('--default-task-access ACCESS', String, "Update the default task access: [none|full]" ) do |val| params['globalTaskAccess'] = val.to_s.downcase end opts.on('--tasks ID=ACCESS', String, "Set task to a custom access by task id. Example: 1=none,2=full" ) do |val| [:task_permissions] ||= {} parse_access_csv([:task_permissions], val, args, optparse) end opts.on('--global-workflow-access ACCESS', String, "Update the global workflow access: [none|full]" ) do |val| params['globalTaskSetAccess'] = val.to_s.downcase end opts.add_hidden_option('--global-workflow-access') opts.on('--default-workflow-access ACCESS', String, "Update the default workflow access: [none|full]" ) do |val| params['globalTaskSetAccess'] = val.to_s.downcase end opts.on('--workflows ID=ACCESS', String, "Set workflow to a custom access by workflow id. Example: 1=none,2=full" ) do |val| [:workflow_permissions] ||= {} parse_access_csv([:workflow_permissions], val, args, optparse) end opts.on('--reset-permissions', "Reset all feature permission access to none. This can be used in conjunction with --permissions to recreate the feature permission access for the role." ) do [:reset_permissions] = true end opts.add_hidden_option('--reset-permissions') opts.on('--reset-feature-access', "Reset all feature permission access to none. This can be used in conjunction with --feature-access to recreate the feature permission access for the role." ) do [:reset_permissions] = true end opts.on('--reset-all-access', "Reset all access to none including permissions, global groups, instance types, etc. This can be used in conjunction with --feature-access to recreate the feature permission access for the role." ) do [:reset_all_access] = true end (opts, ) opts. = <<-EOT Update a role. [role] is required. This is the name (authority) or id of a role. All the role permissions and access values can be configured. Use --feature-access "CODE=ACCESS,CODE=ACCESS" to update access levels for specific feature permissions identified by code. Use --default-instance-type-access custom --instance-types "CODE=ACCESS,CODE=ACCESS" to customize instance type access. Only the specified permissions,instance types, etc. are updated. Use --reset-feature-access to set access to "none" for all unspecified feature permissions. Use --reset-all-access to set access to "none" for all unspecified feature permissions and global access values for groups, instance types, etc. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count:1) name = args[0] connect() begin load_whoami() account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? = [:options] ? [:options].reject {|k,v| k.is_a?(Symbol) } : {} payload = nil if [:payload] payload = [:payload] payload.deep_merge!({'role' => }) unless .empty? else # merge -O options into normally parsed options params.deep_merge!() prompt_option_types = update_role_option_types() if !@is_master_account prompt_option_types = prompt_option_types.reject {|it| ['roleType', 'multitenant','multitenantLocked'].include?(it['fieldName']) } end if role['roleType'] != 'user' prompt_option_types = prompt_option_types.reject {|it| ['multitenant','multitenantLocked'].include?(it['fieldName']) } end #params = Morpheus::Cli::OptionTypes.prompt(prompt_option_types, options[:options], @api_client, options[:params]) # bulk permissions if [:permissions] perms_array = [] [:permissions].each do |k,v| perm_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => perm_code, "access" => access_value} end params['permissions'] = perms_array end if [:group_permissions] perms_array = [] [:group_permissions].each do |k,v| site_id = k access_value = v.to_s.empty? ? "none" : v.to_s if site_id =~ /\A\d{1,}\Z/ perms_array << {"id" => site_id.to_i, "access" => access_value} else perms_array << {"name" => site_id, "access" => access_value} end end params['sites'] = perms_array end if [:cloud_permissions] perms_array = [] [:cloud_permissions].each do |k,v| zone_id = k access_value = v.to_s.empty? ? "none" : v.to_s if zone_id =~ /\A\d{1,}\Z/ perms_array << {"id" => zone_id.to_i, "access" => access_value} else perms_array << {"name" => zone_id, "access" => access_value} end perms_array << {"id" => zone_id, "access" => access_value} end params['zones'] = perms_array end if [:instance_type_permissions] perms_array = [] [:instance_type_permissions].each do |k,v| instance_type_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => instance_type_code, "access" => access_value} end params['instanceTypes'] = perms_array end if [:blueprint_permissions] perms_array = [] [:blueprint_permissions].each do |k,v| blueprint_id = k access_value = v.to_s.empty? ? "none" : v.to_s if blueprint_id =~ /\A\d{1,}\Z/ perms_array << {"id" => blueprint_id.to_i, "access" => access_value} else perms_array << {"name" => blueprint_id, "access" => access_value} end end params['appTemplates'] = perms_array end if [:catalog_item_type_permissions] perms_array = [] [:catalog_item_type_permissions].each do |k,v| catalog_item_type_id = k access_value = v.to_s.empty? ? "none" : v.to_s if catalog_item_type_id =~ /\A\d{1,}\Z/ perms_array << {"id" => catalog_item_type_id.to_i, "access" => access_value} else perms_array << {"name" => catalog_item_type_id, "access" => access_value} end end params['catalogItemTypes'] = perms_array end if [:persona_permissions] perms_array = [] [:persona_permissions].each do |k,v| persona_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => persona_code, "access" => access_value} end params['personas'] = perms_array end if [:vdi_pool_permissions] perms_array = [] [:vdi_pool_permissions].each do |k,v| vdi_pool_id = k access_value = v.to_s.empty? ? "none" : v.to_s if vdi_pool_id =~ /\A\d{1,}\Z/ perms_array << {"id" => vdi_pool_id.to_i, "access" => access_value} else perms_array << {"name" => vdi_pool_id, "access" => access_value} end end params['vdiPools'] = perms_array end if [:report_type_permissions] perms_array = [] [:report_type_permissions].each do |k,v| report_type_code = k access_value = v.to_s.empty? ? "none" : v.to_s perms_array << {"code" => report_type_code, "access" => access_value} end params['reportTypes'] = perms_array end if [:task_permissions] perms_array = [] [:task_permissions].each do |k,v| task_id = k access_value = v.to_s.empty? ? "none" : v.to_s if task_id =~ /\A\d{1,}\Z/ perms_array << {"id" => task_id.to_i, "access" => access_value} else perms_array << {"name" => task_id, "access" => access_value} end end params['tasks'] = perms_array end if [:workflow_permissions] perms_array = [] [:workflow_permissions].each do |k,v| workflow_id = k access_value = v.to_s.empty? ? "none" : v.to_s if workflow_id =~ /\A\d{1,}\Z/ perms_array << {"id" => workflow_id.to_i, "access" => access_value} else perms_array << {"name" => workflow_id, "access" => access_value} end end params['taskSets'] = perms_array end if [:reset_permissions] params["resetPermissions"] = true end if [:reset_all_access] params["resetAllAccess"] = true end if params.empty? raise_command_error "Specify at least one option to update.\n#{optparse}" end payload = {"role" => params} end @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update(account_id, role['id'], payload) return end json_response = @roles_interface.update(account_id, role['id'], payload) render_response(json_response, , "role") do role = json_response['role'] display_name = role['authority'] rescue '' print_green_success "Updated role #{display_name}" get_args = [role['id']] + ([:remote] ? ["-r",[:remote]] : []) if account get_args.push "--account-id", account['id'].to_s end get(get_args) end return 0, nil rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_blueprint_access(args) ⇒ Object
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1917 def update_blueprint_access(args) = {} blueprint_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [blueprint] [access]") opts.on( '--blueprint ID', String, "Blueprint ID or Name" ) do |val| blueprint_id = val end opts.on( nil, '--all', "Update all blueprints at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a blueprint or all blueprints.\n" + "[role] is required. This is the name or id of a role.\n" + "--blueprint or --all is required. This is the name or id of a blueprint.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) # usage: update-blueprint-access [role] [access] --all # update-blueprint-access [role] [blueprint] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) blueprint_id = args[1] if args[1] access_value = args[2] if args[2] end if !blueprint_id && !do_all raise_command_error("missing required argument: [blueprint] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) blueprint_global_access = role_json['globalAppTemplateAccess'] || role_json['globalBlueprintAccess'] = role_json['appTemplatePermissions'] || role_json['blueprintPermissions'] || [] # hacky, but support name or code lookup via the list returned in the show payload blueprint = nil if !do_all if blueprint_id.to_s =~ /\A\d{1,}\Z/ blueprint = .find {|b| b['id'] == blueprint_id.to_i } else blueprint = .find {|b| b['name'] == blueprint_id || b['code'] == blueprint_id } end if blueprint.nil? print_red_alert "Blueprint not found: '#{blueprint_id}'" return 1 end end params = {} if do_all params['allAppTemplates'] = true #params['allBlueprints'] = true else params['appTemplateId'] = blueprint['id'] # params['blueprintId'] = blueprint['id'] end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_blueprint(account_id, role['id'], params) return end json_response = @roles_interface.update_blueprint(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all blueprints" else print_green_success "Role #{role['authority']} access updated for blueprint #{blueprint['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_catalog_item_type_access(args) ⇒ Object
2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2079 def update_catalog_item_type_access(args) = {} catalog_item_type_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [catalog-item-type] [access]") opts.on( '--catalog-item-type ID', String, "Catalog Item Type ID or Name" ) do |val| catalog_item_type_id = val end opts.on( nil, '--all', "Update all catalog item types at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a catalog item type or all types.\n" + "[role] is required. This is the name or id of a role.\n" + "--catalog-item-type or --all is required. This is the name or id of a catalog item type.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) # usage: update-catalog_item_type-access [role] [access] --all # update-catalog_item_type-access [role] [catalog-item-type] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) catalog_item_type_id = args[1] if args[1] access_value = args[2] if args[2] end if !catalog_item_type_id && !do_all raise_command_error("missing required argument: [catalog-item-type] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) catalog_item_type_global_access = role_json['globalCatalogItemTypeAccess'] = role_json['catalogItemTypePermissions'] || role_json['catalogItemTypes'] [] # hacky, but support name or code lookup via the list returned in the show payload catalog_item_type = nil if !do_all if catalog_item_type_id.to_s =~ /\A\d{1,}\Z/ catalog_item_type = .find {|b| b['id'] == catalog_item_type_id.to_i } else catalog_item_type = .find {|b| b['name'] == catalog_item_type_id } end if catalog_item_type.nil? print_red_alert "Catalog Item Type not found: '#{catalog_item_type_id}'" return 1 end end params = {} if do_all params['allCatalogItemTypes'] = true else params['catalogItemTypeId'] = catalog_item_type['id'] end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_catalog_item_type(account_id, role['id'], params) return end json_response = @roles_interface.update_catalog_item_type(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all catalog item types" else print_green_success "Role #{role['authority']} access updated for catalog item type #{catalog_item_type['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_cloud_access(args) ⇒ Object
1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1617 def update_cloud_access(args) = {} cloud_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'read', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role]") opts.on( '-c', '--cloud CLOUD', "Cloud name or id" ) do |val| cloud_id = val end opts.on( nil, '--all', "Update all clouds at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update role access for a cloud or all clouds. [role] is required. This is the name or id of a role. --cloud or --all is required. This is the name or id of a cloud. --access is required. This is the new access value: #{ored_list(allowed_access_values)} EOT end optparse.parse!(args) # usage: update-cloud-access [role] [access] --all # update-cloud-access [role] [cloud] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) cloud_id = args[1] if args[1] access_value = args[2] if args[2] end if !cloud_id && !do_all raise_command_error("missing required argument: [cloud] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) cloud = nil if !do_all cloud = find_cloud_by_name_or_id_for_provisioning(nil, cloud_id) return 1 if cloud.nil? cloud_id = cloud['id'] end params = {} if do_all params['allClouds'] = true else params['cloudId'] = cloud_id end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_cloud(account_id, role['id'], params) return end json_response = @roles_interface.update_cloud(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all clouds" else print_green_success "Role #{role['authority']} access updated for cloud #{cloud['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_blueprint_access(args) ⇒ Object
1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1865 def update_default_blueprint_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default blueprint access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'AppTemplate', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default blueprint access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_catalog_item_type_access(args) ⇒ Object
2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2027 def update_default_catalog_item_type_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default catalog item type access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'CatalogItemType', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default catalog item type access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_cloud_access(args) ⇒ Object
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1565 def update_default_cloud_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default cloud access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full, read or none. Only applicable to Tenant roles. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'read', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'ComputeZone', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default cloud access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_group_access(args) ⇒ Object
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1412 def update_default_group_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default group access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full, read, or none. Only applicable to User roles. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'read', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'ComputeSite', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default group access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_instance_type_access(args) ⇒ Object
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1717 def update_default_instance_type_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default instance type access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'InstanceType', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default instance type access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_persona_access(args) ⇒ Object
2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2182 def update_default_persona_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default persona access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) if args.count < 2 puts optparse exit 1 end name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) puts optparse exit 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'Persona', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default persona access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_report_type_access(args) ⇒ Object
2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2484 def update_default_report_type_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default report type access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count: 2) name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) raise_command_error("invalid access value: #{args[1]}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? # note: ReportTypes being plural is odd, the others are singular params = {permissionCode: 'ReportTypes', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default report type access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_task_access(args) ⇒ Object
2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2640 def update_default_task_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default task access for a role. [role] is required. This is the id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count: 2) name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) raise_command_error("invalid access value: #{args[1]}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? # note: ReportTypes being plural is odd, the others are singular params = {permissionCode: 'Task', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default task access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_vdi_pool_access(args) ⇒ Object
2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2329 def update_default_vdi_pool_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default VDI pool access for a role. [role] is required. This is the name (authority) or id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count: 2) name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) raise_command_error("invalid access value: #{args[1]}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? # note: VdiPools being plural is odd, the others are singular params = {permissionCode: 'VdiPools', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default vdi pool access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_default_workflow_access(args) ⇒ Object
2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2793 def update_default_workflow_access(args) = {} optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [access]") (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update default workflow access for a role. [role] is required. This is the id of a role. [access] is required. This is the access level to assign: full or none. EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, count: 2) name = args[0] access_value = args[1].to_s.downcase if !['full', 'none', 'custom'].include?(access_value) raise_command_error("invalid access value: #{args[1]}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: 'TaskSet', access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} default workflow access updated" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_feature_access(args) ⇒ Object
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1337 def update_feature_access(args) = {} allowed_access_values = ["full", "full_decrypted", "group", "listfiles", "managerules", "no", "none", "provision", "read", "rolemappings", "user", "view", "yes"] = nil access_value = nil optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [permission] [access]") opts.on( '-p', '--permission CODE', "Permission code or name" ) do |val| = val end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}] (varies per permission)" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update role access for a permission. [role] is required. This is the name (authority) or id of a role. [permission] is required. This is the code or name of a permission. [access] is required. This is the new access value: #{ored_list(allowed_access_values)} EOT end optparse.parse!(args) verify_args!(args:args, optparse:optparse, min:1, max:3) name = args[0] = args[1] if args[1] access_value = args[2].to_s.downcase if args[2] if ! raise_command_error("missing required argument: [permission]", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end # access_value = access_value.to_s.downcase # if !allowed_access_values.include?(access_value) # raise_command_error("invalid access value: #{access_value}", args, optparse) # end # need to load the permission and then split accessTypes, so just allows all for now, server validates... # if !['full_decrypted','full', 'read', 'custom', 'none'].include?(access_value) # puts optparse # exit 1 # end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) exit 1 if role.nil? params = {permissionCode: , access: access_value} @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.(account_id, role['id'], params) return end json_response = @roles_interface.(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else print_green_success "Role #{role['authority']} permission #{} set to #{access_value}" end rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_global_blueprint_access(args) ⇒ Object
1860 1861 1862 1863 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1860 def update_global_blueprint_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_blueprint_access(args) end |
#update_global_catalog_item_type_access(args) ⇒ Object
2022 2023 2024 2025 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2022 def update_global_catalog_item_type_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_catalog_item_type_access(args) end |
#update_global_cloud_access(args) ⇒ Object
1560 1561 1562 1563 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1560 def update_global_cloud_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_cloud_access(args) end |
#update_global_group_access(args) ⇒ Object
1407 1408 1409 1410 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1407 def update_global_group_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_group_access(args) end |
#update_global_instance_type_access(args) ⇒ Object
1712 1713 1714 1715 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1712 def update_global_instance_type_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_instance_type_access(args) end |
#update_global_report_type_access(args) ⇒ Object
2479 2480 2481 2482 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2479 def update_global_report_type_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_report_type_access(args) end |
#update_global_task_access(args) ⇒ Object
2635 2636 2637 2638 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2635 def update_global_task_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_task_access(args) end |
#update_global_vdi_pool_access(args) ⇒ Object
2324 2325 2326 2327 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2324 def update_global_vdi_pool_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_vdi_pool_access(args) end |
#update_global_workflow_access(args) ⇒ Object
2788 2789 2790 2791 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2788 def update_global_workflow_access(args) puts "#{yellow}DEPRECATED#{reset}" update_default_workflow_access(args) end |
#update_group_access(args) ⇒ Object
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1464 def update_group_access(args) = {} name = nil group_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'read', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [group] [access]") opts.on( '-g', '--group GROUP', "Group name or id" ) do |val| group_id = val end opts.on( nil, '--all', "Update all groups at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = <<-EOT Update role access for a group or all groups. [role] is required. This is the name or id of a role. --group or --all is required. This is the name or id of a group. --access is required. This is the new access value: #{ored_list(allowed_access_values)} EOT end optparse.parse!(args) # usage: update-group-access [role] [access] --all # update-group-access [role] [group] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) group_id = args[1] if args[1] access_value = args[2] if args[2] end if !group_id && !do_all raise_command_error("missing required argument: [group] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? group = nil if !do_all group = find_group_by_name_or_id_for_provisioning(group_id) return 1 if group.nil? group_id = group['id'] end params = {} if do_all params['allGroups'] = true else params['groupId'] = group_id end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_group(account_id, role['id'], params) return end json_response = @roles_interface.update_group(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all groups" else print_green_success "Role #{role['authority']} access updated for group #{group['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_instance_type_access(args) ⇒ Object
1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 |
# File 'lib/morpheus/cli/commands/roles.rb', line 1769 def update_instance_type_access(args) = {} instance_type_name = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [type] [access]") opts.on( '--instance-type INSTANCE_TYPE', String, "Instance Type name" ) do |val| instance_type_name = val end opts.on( nil, '--all', "Update all instance types at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for an instance type or all instance types.\n" + "[role] is required. This is the name or id of a role.\n" + "--instance-type or --all is required. This is the name of an instance type.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) if args.count < 1 puts optparse return 1 end name = args[0] # support old usage: [role] [instance-type] [access] instance_type_name ||= args[1] access_value ||= args[2] if (!instance_type_name && !do_all) || !access_value puts optparse return 1 end access_value = access_value.to_s.downcase if !['full', 'none'].include?(access_value) puts optparse return 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) instance_type = nil if !do_all instance_type = find_instance_type_by_name(instance_type_name) return 1 if instance_type.nil? end params = {} if do_all params['allInstanceTypes'] = true else params['instanceTypeId'] = instance_type['id'] end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_instance_type(account_id, role['id'], params) return end json_response = @roles_interface.update_instance_type(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all instance types" else print_green_success "Role #{role['authority']} access updated for instance type #{instance_type['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_persona_access(args) ⇒ Object
2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2233 def update_persona_access(args) = {} persona_id = nil name = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [persona] [access]") opts.on( '--persona CODE', String, "Persona Code" ) do |val| persona_id = val end opts.on( nil, '--all', "Update all personas at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a persona or all personas.\n" + "[role] is required. This is the name or id of a role.\n" + "--persona or --all is required. This is the code of a persona. Service Catalog, Standard, or Virtual Desktop\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) # usage: update-persona-access [role] [access] --all # update-persona-access [role] [persona] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) persona_id = args[1] if args[1] access_value = args[2] if args[2] end if !persona_id && !do_all raise_command_error("missing required argument: [persona] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) # no lookup right now, pass the code serviceCatalog|standard persona_code = persona_id params = {} if do_all params['allPersonas'] = true else params['personaCode'] = persona_code end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_persona(account_id, role['id'], params) return end json_response = @roles_interface.update_persona(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all personas" else print_green_success "Role #{role['authority']} access updated for persona #{persona_code}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_report_type_access(args) ⇒ Object
2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2530 def update_report_type_access(args) = {} report_type_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [report-type] [access]") opts.on( '--report-type ID', String, "Report Type ID or Name" ) do |val| report_type_id = val end opts.on( nil, '--all', "Update all report types at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a report type or all report types.\n" + "[role] is required. This is the name or id of a role.\n" + "--report-type or --all is required. This is the name or id of a report type.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) # usage: update-report-type-access [role] [access] --all # update-report-type-access [role] [report-type] [access] name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) report_type_id = args[1] if args[1] access_value = args[2] if args[2] end if !report_type_id && !do_all raise_command_error("missing required argument: [report-type] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) puts optparse return 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) report_type_global_access = role_json['globalReportTypeAccess'] = role_json['reportTypePermissions'] || role_json['reportTypes'] || [] # hacky, but support name or code lookup via the list returned in the show payload report_type = nil if !do_all if report_type_id.to_s =~ /\A\d{1,}\Z/ report_type = .find {|b| b['id'] == report_type_id.to_i } else report_type = .find {|b| b['name'] == report_type_id } end if report_type.nil? print_red_alert "Report Type not found: '#{report_type_id}'" return 1 end end params = {} if do_all params['allReportTypes'] = true else params['reportTypeId'] = report_type['id'] end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_report_type(account_id, role['id'], params) return end json_response = @roles_interface.update_report_type(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all report types" else print_green_success "Role #{role['authority']} access updated for report type #{report_type['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_task_access(args) ⇒ Object
2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2686 def update_task_access(args) = {} task_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [task] [access]") opts.on( '--task ID', String, "Task ID, code or name" ) do |val| report_type_id = val end opts.on( nil, '--all', "Update all tasks at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a task or all tasks.\n" + "[role] is required. This is the name, code or id of a task.\n" + "--task or --all is required. This is the name, code or id of a task.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) task_id = args[1] if args[1] access_value = args[2] if args[2] end if !task_id && !do_all raise_command_error("missing required argument: [task] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) puts optparse return 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) = role_json['taskPermissions'] || role_json['tasks'] || [] # hacky, but support name or code lookup via the list returned in the show payload task = nil if !do_all if task_id.to_s =~ /\A\d{1,}\Z/ task = .find {|b| b['id'] == task_id.to_i } else task = .find {|b| b['name'] == task_id || b['code'] == task_id } end if task.nil? print_red_alert "Task not found: '#{task_id}'" return 1 end end params = {} if do_all params['allTasks'] = true else params['taskId'] = task['id'] end params['access'] = access_value == 'default' ? nil : access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_task(account_id, role['id'], params) return end json_response = @roles_interface.update_task(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all tasks" else print_green_success "Role #{role['authority']} access updated for task #{task['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_vdi_pool_access(args) ⇒ Object
2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2376 def update_vdi_pool_access(args) = {} vdi_pool_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [vdi-pool] [access]") opts.on( '--vdi-pool ID', String, "VDI Pool ID or Name" ) do |val| vdi_pool_id = val end opts.on( nil, '--all', "Update all VDI pools at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a VDI pool or all VDI pools.\n" + "[role] is required. This is the name or id of a role.\n" + "--vdi-pool or --all is required. This is the name or id of a VDI pool.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) vdi_pool_id = args[1] if args[1] access_value = args[2] if args[2] end if !vdi_pool_id && !do_all raise_command_error("missing required argument: [vdi-pool] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) puts optparse return 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) vdi_pool_global_access = role_json['globalVdiPoolAccess'] = role_json['vdiPoolPermissions'] || role_json['vdiPools'] || [] # hacky, but support name or code lookup via the list returned in the show payload vdi_pool = nil if !do_all if vdi_pool_id.to_s =~ /\A\d{1,}\Z/ vdi_pool = .find {|b| b['id'] == vdi_pool_id.to_i } else vdi_pool = .find {|b| b['name'] == vdi_pool_id } end if vdi_pool.nil? print_red_alert "VDI Pool not found: '#{vdi_pool_id}'" return 1 end end params = {} if do_all params['allVdiPools'] = true else params['vdiPoolId'] = vdi_pool['id'] end params['access'] = access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_vdi_pool(account_id, role['id'], params) return end json_response = @roles_interface.update_vdi_pool(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all VDI pools" else print_green_success "Role #{role['authority']} access updated for VDI pool #{vdi_pool['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |
#update_workflow_access(args) ⇒ Object
2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 |
# File 'lib/morpheus/cli/commands/roles.rb', line 2838 def update_workflow_access(args) = {} workflow_id = nil access_value = nil do_all = false allowed_access_values = ['full', 'none', 'default'] optparse = Morpheus::Cli::OptionParser.new do |opts| opts. = subcommand_usage("[role] [workflow] [access]") opts.on( '--workflow ID', String, "Workflow ID, code or Name" ) do |val| workflow_id = val end opts.on( nil, '--all', "Update all workflows at once." ) do do_all = true end opts.on( '--access VALUE', String, "Access value [#{allowed_access_values.join('|')}]" ) do |val| access_value = val end (opts, , [:json, :dry_run, :remote]) opts. = "Update role access for a workflow or all workflows.\n" + "[role] is required. This is the name or id of a role.\n" + "--workflow or --all is required. This is the name, code or id of a workflow.\n" + "--access is required. This is the new access value: #{ored_list(allowed_access_values)}" end optparse.parse!(args) name = args[0] if do_all verify_args!(args:args, optparse:optparse, min:1, max:2) access_value = args[1] if args[1] else verify_args!(args:args, optparse:optparse, min:1, max:3) workflow_id = args[1] if args[1] access_value = args[2] if args[2] end if !workflow_id && !do_all raise_command_error("missing required argument: [workflow] or --all", args, optparse) end if !access_value raise_command_error("missing required argument: [access]", args, optparse) end access_value = access_value.to_s.downcase if !allowed_access_values.include?(access_value) raise_command_error("invalid access value: #{access_value}", args, optparse) puts optparse return 1 end connect() begin account = () account_id = account ? account['id'] : nil role = find_role_by_name_or_id(account_id, name) return 1 if role.nil? role_json = @roles_interface.get(account_id, role['id']) = role_json['taskSetPermissions'] || role_json['taskSets'] || [] # hacky, but support name or code lookup via the list returned in the show payload workflow = nil if !do_all if workflow_id.to_s =~ /\A\d{1,}\Z/ workflow = .find {|b| b['id'] == workflow_id.to_i } else workflow = .find {|b| b['name'] == workflow_id } end if workflow.nil? print_red_alert "Workflow not found: '#{workflow_id}'" return 1 end end params = {} if do_all params['allTaskSets'] = true else params['taskSetId'] = workflow['id'] end params['access'] = access_value == 'default' ? nil : access_value @roles_interface.setopts() if [:dry_run] print_dry_run @roles_interface.dry.update_task_set(account_id, role['id'], params) return end json_response = @roles_interface.update_task_set(account_id, role['id'], params) if [:json] print JSON.pretty_generate(json_response) print "\n" else if do_all print_green_success "Role #{role['authority']} access updated for all workflows" else print_green_success "Role #{role['authority']} access updated for workflow #{workflow['name']}" end end return 0 rescue RestClient::Exception => e print_rest_exception(e, ) exit 1 end end |