Project

General

Profile

Revision f370cc85

Added by Thomas McKay over 6 years ago

fixes #16501 - subnets import not setting proxies

Changed the vcr recording by adding --reload-cache to all the hammer commands. This hopefully will avoid the intermittent failures due to fetching the v2.json.

View differences:

lib/hammer_cli_csv/base.rb
160 160
                yield line
161 161
              rescue RuntimeError => e
162 162
                message = "#{e}\n#{line}"
163
                option_continue_on_error? ? $stderr.puts("Error: #{message}") : raise(message)
163
                option_continue_on_error? ? $stderr.puts(_("Error: %{message}") % {:message => message}) : raise(message)
164 164
              end
165 165
            end
166 166
          end
......
195 195
                                                              :per_page => 999999,
196 196
                                                              'search' => "name=\"#{options[:name]}\""
197 197
                                                            })['results']
198
          raise "Organization '#{options[:name]}' not found" if !organization || organization.empty?
198
          raise _("Organization '%{name}' not found") % {:name => options[:name]} if !organization || organization.empty?
199 199
          options[:id] = organization[0]['id']
200 200
          @organizations[options[:name]] = options[:id]
201 201
        end
......
205 205
        options[:name] = @organizations.key(options[:id])
206 206
        if !options[:name]
207 207
          organization = @api.resource(:organizations).call(:show, {'id' => options[:id]})
208
          raise "Organization 'id=#{options[:id]}' not found" if !organization || organization.empty?
208
          raise _("Organization 'id=%{id}' not found") % {:id => options[:id]} if !organization || organization.empty?
209 209
          options[:name] = organization['name']
210 210
          @organizations[options[:name]] = options[:id]
211 211
        end
......
226 226
                                                      :per_page => 999999,
227 227
                                                      'search' => "name=\"#{options[:name]}\""
228 228
                                                    })['results']
229
          raise "Location '#{options[:name]}' not found" if !location || location.empty?
229
          raise _("Location '%{name}' not found") % {:name => options[:name]} if !location || location.empty?
230 230
          options[:id] = location[0]['id']
231 231
          @locations[options[:name]] = options[:id]
232 232
        end
......
236 236
        options[:name] = @locations.key(options[:id])
237 237
        if !options[:name]
238 238
          location = @api.resource(:locations).call(:show, {'id' => options[:id]})
239
          raise "Location 'id=#{options[:id]}' not found" if !location || location.empty?
239
          raise _("Location 'id=%{id}' not found") % {:id => options[:id]} if !location || location.empty?
240 240
          options[:name] = location['name']
241 241
          @locations[options[:name]] = options[:id]
242 242
        end
......
257 257
                                              :per_page => 999999,
258 258
                                              'search' => "name=\"#{options[:name]}\""
259 259
                                            })['results']
260
          raise "Role '#{options[:name]}' not found" if !role || role.empty?
260
          raise _("Role '%{name}' not found") % {:name => options[:name]} if !role || role.empty?
261 261
          options[:id] = role[0]['id']
262 262
          @roles[options[:name]] = options[:id]
263 263
        end
......
267 267
        options[:name] = @roles.key(options[:id])
268 268
        if !options[:name]
269 269
          role = @api.resource(:roles).call(:show, {'id' => options[:id]})
270
          raise "Role 'id=#{options[:id]}' not found" if !role || role.empty?
270
          raise _("Role 'id=%{id}' not found") % {:id => options[:id]} if !role || role.empty?
271 271
          options[:name] = role['name']
272 272
          @roles[options[:name]] = options[:id]
273 273
        end
......
288 288
                                                          :per_page => 999999,
289 289
                                                          'name' => options[:name]
290 290
                                                        })['results']
291
          raise "Permission '#{options[:name]}' not found" if !permission || permission.empty?
291
          raise _("Permission '%{name}' not found") % {:name => options[:name]} if !permission || permission.empty?
292 292
          options[:id] = permission[0]['id']
293 293
          @permissions[options[:name]] = options[:id]
294 294
        end
......
298 298
        options[:name] = @permissions.key(options[:id])
299 299
        if !options[:name]
300 300
          permission = @api.resource(:permissions).call(:show, {'id' => options[:id]})
301
          raise "Permission 'id=#{options[:id]}' not found" if !permission || permission.empty?
301
          raise _("Permission 'id=%{id}' not found") % {:id => options[:id]} if !permission || permission.empty?
302 302
          options[:name] = permission['name']
303 303
          @permissions[options[:name]] = options[:id]
304 304
        end
......
333 333
                                                            :per_page => 999999,
334 334
                                                            'search' => "name=\"#{ options[:name] }\""
335 335
                                                          })['results']
336
          raise "Puppet environment '#{options[:name]}' not found" if !environment || environment.empty?
336
          raise _("Puppet environment '%{name}' not found") % {:name => options[:name]} if !environment || environment.empty?
337 337
          options[:id] = environment[0]['id']
338 338
          @environments[options[:name]] = options[:id]
339 339
        end
......
343 343
        options[:name] = @environments.key(options[:id])
344 344
        if !options[:name]
345 345
          environment = @api.resource(:environments).call(:show, {'id' => options[:id]})
346
          raise "Puppet environment '#{options[:name]}' not found" if !environment || environment.empty?
346
          raise _("Puppet environment 'id=%{id}' not found") % {:id => options[:id]} if !environment || environment.empty?
347 347
          options[:name] = environment['name']
348 348
          @environments[options[:name]] = options[:id]
349 349
        end
......
364 364
                                              :per_page => 999999,
365 365
                                              'search' => "name=\"#{options[:name]}\""
366 366
                                            })['results']
367
          raise "Template kind '#{options[:name]}' not found" if !template_kind || template_kind.empty?
367
          raise _("Template kind '%{name}' not found") % {:name => options[:name]} if !template_kind || template_kind.empty?
368 368
          options[:id] = template_kind[0]['id']
369 369
          @template_kinds[options[:name]] = options[:id]
370 370
        end
......
374 374
        options[:name] = @template_kinds.key(options[:id])
375 375
        if !options[:name]
376 376
          template_kind = @api.resource(:template_kinds).call(:show, {'id' => options[:id]})
377
          raise "Template kind 'id=#{options[:id]}' not found" if !template_kind || template_kind.empty?
377
          raise _("Template kind 'id=%{id}' not found") % {:id => options[:id]} if !template_kind || template_kind.empty?
378 378
          options[:name] = template_kind['name']
379 379
          @template_kinds[options[:name]] = options[:id]
380 380
        end
......
398 398
                                                                     'search' => search
399 399
                                                                   })['results']
400 400
          operatingsystem = operatingsystems[0]
401
          raise "Operating system '#{options[:name]}' not found" if !operatingsystem || operatingsystem.empty?
401
          raise _("Operating system '%{name}' not found") % {:name => options[:name]} if !operatingsystem || operatingsystem.empty?
402 402
          options[:id] = operatingsystem['id']
403 403
          @operatingsystems[options[:name]] = options[:id]
404 404
        end
......
408 408
        options[:name] = @operatingsystems.key(options[:id])
409 409
        if !options[:name]
410 410
          operatingsystem = @api.resource(:operatingsystems).call(:show, {'id' => options[:id]})
411
          raise "Operating system 'id=#{options[:id]}' not found" if !operatingsystem || operatingsystem.empty?
411
          raise _("Operating system 'id=%{id}' not found") % {:id => options[:id]} if !operatingsystem || operatingsystem.empty?
412 412
          options[:name] = build_os_name(operatingsystem['name'],
413 413
                                         operatingsystem['major'],
414 414
                                         operatingsystem['minor'])
......
431 431
                                                              :per_page => 999999,
432 432
                                                              'search' => "name=\"#{options[:name]}\""
433 433
                                                            })['results']
434
          raise "Architecture '#{options[:name]}' not found" if !architecture || architecture.empty?
434
          raise _("Architecture '%{name}' not found") % {:name => options[:name]} if !architecture || architecture.empty?
435 435
          options[:id] = architecture[0]['id']
436 436
          @architectures[options[:name]] = options[:id]
437 437
        end
......
441 441
        options[:name] = @architectures.key(options[:id])
442 442
        if !options[:name]
443 443
          architecture = @api.resource(:architectures).call(:show, {'id' => options[:id]})
444
          raise "Architecture 'id=#{options[:id]}' not found" if !architecture || architecture.empty?
444
          raise _("Architecture 'id=%{id}' not found") % {:id => options[:id]} if !architecture || architecture.empty?
445 445
          options[:name] = architecture['name']
446 446
          @architectures[options[:name]] = options[:id]
447 447
        end
......
462 462
                                                  :per_page => 999999,
463 463
                                                  'search' => "name=\"#{options[:name]}\""
464 464
                                                })['results']
465
          raise "Domain '#{options[:name]}' not found" if !domain || domain.empty?
465
          raise _("Domain '%{name}' not found") % {:name => options[:name]} if !domain || domain.empty?
466 466
          options[:id] = domain[0]['id']
467 467
          @domains[options[:name]] = options[:id]
468 468
        end
......
472 472
        options[:name] = @domains.key(options[:id])
473 473
        if !options[:name]
474 474
          domain = @api.resource(:domains).call(:show, {'id' => options[:id]})
475
          raise "Domain 'id=#{options[:id]}' not found" if !domain || domain.empty?
475
          raise _("Domain 'id=%{id}' not found") % {:id => options[:id]} if !domain || domain.empty?
476 476
          options[:name] = domain['name']
477 477
          @domains[options[:name]] = options[:id]
478 478
        end
......
493 493
                                                  :per_page => 999999,
494 494
                                                  'search' => "name=\"#{options[:name]}\""
495 495
                                                })['results']
496
          raise "Partition table '#{options[:name]}' not found" if !ptable || ptable.empty?
496
          raise _("Partition table '%{name}' not found") % {:name => options[:name]} if !ptable || ptable.empty?
497 497
          options[:id] = ptable[0]['id']
498 498
          @ptables[options[:name]] = options[:id]
499 499
        end
......
525 525
                                                  :per_page => 999999,
526 526
                                                  'search' => "name=\"#{options[:name]}\""
527 527
                                                })['results']
528
          raise "Partition table '#{options[:name]}' not found" if !ptable || ptable.empty?
528
          raise _("Partition table '%{name}' not found") % {:name => options[:name]} if !ptable || ptable.empty?
529 529
          options[:id] = ptable[0]['id']
530 530
          @media[options[:name]] = options[:id]
531 531
        end
......
557 557
                                              :per_page => 999999,
558 558
                                              'search' => "name=\"#{options[:name]}\""
559 559
                                            })['results']
560
          raise "Host '#{options[:name]}' not found" if !host || host.empty?
560
          raise _("Host '%{name}' not found") % {:name => options[:name]} if !host || host.empty?
561 561
          options[:id] = host[0]['id']
562 562
          @query_hosts[options[:name]] = options[:id]
563 563
        end
......
567 567
        options[:name] = @query_hosts.key(options[:id])
568 568
        if !options[:name]
569 569
          host = @api.resource(:hosts).call(:show, {'id' => options[:id]})
570
          raise "Host 'id=#{options[:id]}' not found" if !host || host.empty?
570
          raise _("Host 'id=%{id}' not found") % {:id => options[:id]} if !host || host.empty?
571 571
          options[:name] = host['name']
572 572
          @query_hosts[options[:name]] = options[:id]
573 573
        end
......
588 588
                                              :per_page => 999999,
589 589
                                              'search' => "name=\"#{options[:name]}\""
590 590
                                            })['results']
591
          raise "Host Group '#{options[:name]}' not found" if !hostgroup || hostgroup.empty?
591
          raise _("Host Group '%{name}' not found") % {:name => options[:name]} if !hostgroup || hostgroup.empty?
592 592
          options[:id] = hostgroup[0]['id']
593 593
          @query_hostgroups[options[:name]] = options[:id]
594 594
        end
......
598 598
        options[:name] = @query_hostgroups.key(options[:id])
599 599
        if !options[:name]
600 600
          hostgroup = @api.resource(:hostgroups).call(:show, {'id' => options[:id]})
601
          raise "Host Group 'id=#{options[:id]}' not found" if !hostgroup || hostgroup.empty?
601
          raise _("Host Group 'id=%{id}' not found") % {:id => options[:id]} if !hostgroup || hostgroup.empty?
602 602
          options[:name] = hostgroup['name']
603 603
          @query_hostgroups[options[:name]] = options[:id]
604 604
        end
......
619 619
                                              :per_page => 999999,
620 620
                                              'search' => "name=\"#{options[:name]}\""
621 621
                                            })['results']
622
          raise "Provisioning template '#{options[:name]}' not found" if !config_template || config_template.empty?
622
          raise _("Provisioning template '%{name}' not found") % {:name => options[:name]} if !config_template || config_template.empty?
623 623
          options[:id] = config_template[0]['id']
624 624
          @query_config_templates[options[:name]] = options[:id]
625 625
        end
......
629 629
        options[:name] = @query_config_templates.key(options[:id])
630 630
        if !options[:name]
631 631
          config_template = @api.resource(:config_templates).call(:show, {'id' => options[:id]})
632
          raise "Provisioning template 'id=#{options[:id]}' not found" if !config_template || config_template.empty?
632
          raise _("Provisioning template 'id=%{id}' not found") % {:id => options[:id]} if !config_template || config_template.empty?
633 633
          options[:name] = config_template['name']
634 634
          @query_config_templates[options[:name]] = options[:id]
635 635
        end
......
650 650
                                              :per_page => 999999,
651 651
                                              'search' => "name=\"#{options[:name]}\""
652 652
                                            })['results']
653
          raise "Smart Proxy '#{options[:name]}' not found" if !smart_proxy || smart_proxy.empty?
653
          raise _("Smart Proxy '%{name}' not found") % {:name => options[:name]} if !smart_proxy || smart_proxy.empty?
654 654
          options[:id] = smart_proxy[0]['id']
655 655
          @query_smart_proxies[options[:name]] = options[:id]
656 656
        end
......
660 660
        options[:name] = @query_smart_proxies.key(options[:id])
661 661
        if !options[:name]
662 662
          smart_proxy = @api.resource(:smart_proxies).call(:show, {'id' => options[:id]})
663
          raise "Smart Proxy 'id=#{options[:id]}' not found" if !smart_proxy || smart_proxy.empty?
663
          raise _("Smart Proxy 'id=%{id}' not found") % {:id => options[:id]} if !smart_proxy || smart_proxy.empty?
664 664
          options[:name] = smart_proxy['name']
665 665
          @query_smart_proxies[options[:name]] = options[:id]
666 666
        end
......
686 686
            @lifecycle_environments[organization][environment['name']] = environment['id']
687 687
          end
688 688
          options[:id] = @lifecycle_environments[organization][options[:name]]
689
          raise "Lifecycle environment '#{options[:name]}' not found" if !options[:id]
689
          raise _("Lifecycle environment '%{name}' not found") % {:name => options[:name]} if !options[:id]
690 690
        end
691 691
        result = options[:id]
692 692
      else
......
694 694
        options[:name] = @lifecycle_environments.key(options[:id])
695 695
        if !options[:name]
696 696
          environment = @api.resource(:lifecycle_environments).call(:show, {'id' => options[:id]})
697
          raise "Lifecycle environment '#{options[:name]}' not found" if !environment || environment.empty?
697
          raise _("Lifecycle environment '%{name}' not found") % {:name => options[:name]} if !environment || environment.empty?
698 698
          options[:name] = environment['name']
699 699
          @lifecycle_environments[options[:name]] = options[:id]
700 700
        end
......
719 719
            @contentviews[organization][contentview['name']] = contentview['id']
720 720
          end
721 721
          options[:id] = @contentviews[organization][options[:name]]
722
          raise "Content view '#{options[:name]}' not found" if !options[:id]
722
          raise _("Content view '%{name}' not found") % {:name => options[:name]} if !options[:id]
723 723
        end
724 724
        result = options[:id]
725 725
      else
......
727 727
        options[:name] = @contentviews.key(options[:id])
728 728
        if !options[:name]
729 729
          contentview = @api.resource(:content_views).call(:show, {'id' => options[:id]})
730
          raise "Puppet contentview '#{options[:name]}' not found" if !contentview || contentview.empty?
730
          raise _("Puppet contentview 'id=%{id}' not found") % {:id => options[:id]} if !contentview || contentview.empty?
731 731
          options[:name] = contentview['name']
732 732
          @contentviews[options[:name]] = options[:id]
733 733
        end
......
760 760
          end
761 761
        end
762 762
        id = @contentviewversions[organization][versionname]
763
        raise "Content view version '#{name}' with version '#{version}' not found" if !id
763
        raise _("Content view version '%{name}' with version '%{version}' not found") % {:name => name, :version => version} if !id
764 764
      end
765 765

  
766 766
      id
......
781 781
            @repositories[organization][repository['name']] = repository['id']
782 782
          end
783 783
          options[:id] = @repositories[organization][options[:name]]
784
          raise "Repository '#{options[:name]}' not found" if !options[:id]
784
          raise _("Repository '%{name}' not found") % {:name => options[:name]} if !options[:id]
785 785
        end
786 786
        result = options[:id]
787 787
      else
......
789 789
        options[:name] = @repositories.key(options[:id])
790 790
        if !options[:name]
791 791
          repository = @api.resource(:repositories).call(:show, {'id' => options[:id]})
792
          raise "Puppet repository '#{options[:name]}' not found" if !repository || repository.empty?
792
          raise _("Puppet repository 'id=%{id}' not found") % {:id => options[:id]} if !repository || repository.empty?
793 793
          options[:name] = repository['name']
794 794
          @repositoriesr[options[:name]] = options[:id]
795 795
        end
......
816 816
            @hostcollections[organization][hostcollection['name']] = hostcollection['id'] if hostcollection
817 817
          end
818 818
          options[:id] = @hostcollections[organization][options[:name]]
819
          raise "Host collection '#{options[:name]}' not found" if !options[:id]
819
          raise _("Host collection '%{name}' not found") % {:name => options[:name]} if !options[:id]
820 820
        end
821 821
        result = options[:id]
822 822
      else
......
824 824
        options[:name] = @hostcollections.key(options[:id])
825 825
        if !options[:name]
826 826
          hostcollection = @api.resource(:host_collections).call(:show, {'id' => options[:id]})
827
          raise "Host collection '#{options[:name]}' not found" if !hostcollection || hostcollection.empty?
827
          raise _("Host collection 'id=%{id}' not found") % {:id => options[:id]} if !hostcollection || hostcollection.empty?
828 828
          options[:name] = hostcollection['name']
829 829
          @hostcollections[options[:name]] = options[:id]
830 830
        end
......
851 851
            @products[organization][product['name']] = product['id'] if product
852 852
          end
853 853
          options[:id] = @products[organization][options[:name]]
854
          raise "Host collection '#{options[:name]}' not found" if !options[:id]
854
          raise _("Host collection '%{name}' not found") % {:name => options[:name]} if !options[:id]
855 855
        end
856 856
        result = options[:id]
857 857
      else
......
859 859
        options[:name] = @products.key(options[:id])
860 860
        if !options[:name]
861 861
          product = @api.resource(:host_collections).call(:show, {'id' => options[:id]})
862
          raise "Host collection '#{options[:name]}' not found" if !product || product.empty?
862
          raise _("Host collection 'id=%{id}' not found") % {:id => options[:id]} if !product || product.empty?
863 863
          options[:name] = product['name']
864 864
          @products[options[:name]] = options[:id]
865 865
        end
......
880 880
                                                       :per_page => 999999,
881 881
                                                       'search' => "name=\"#{options[:name]}\""
882 882
                                                     })['results']
883
          raise "Container '#{options[:name]}' not found" if !container || container.empty?
883
          raise _("Container '%{name}' not found") % {:name => options[:name]} if !container || container.empty?
884 884
          options[:id] = container[0]['id']
885 885
          @containers[options[:name]] = options[:id]
886 886
        end
......
890 890
        options[:name] = @containers.key(options[:id])
891 891
        if !options[:name]
892 892
          container = @api.resource(:containers).call(:show, {'id' => options[:id]})
893
          raise "Container 'id=#{options[:id]}' not found" if !container || container.empty?
893
          raise _("Container 'id=%{id}' not found") % {:id => options[:id]} if !container || container.empty?
894 894
          options[:name] = container['name']
895 895
          @containers[options[:name]] = options[:id]
896 896
        end

Also available in: Unified diff