From fd425f60b6805d9dd3d7320cd3bf112c7706252f Mon Sep 17 00:00:00 2001 From: Shini31 Date: Wed, 8 Jun 2016 15:17:07 +0200 Subject: [PATCH] add check options --- cloud/openstack/restapi/mode/hypervisor.pm | 21 +++++++++++++++++++ cloud/openstack/restapi/mode/instance.pm | 21 +++++++++++++++++++ .../openstack/restapi/mode/listhypervisors.pm | 17 +++++++++++++++ cloud/openstack/restapi/mode/listinstances.pm | 17 +++++++++++++++ cloud/openstack/restapi/mode/listnetworks.pm | 13 ++++++++++++ cloud/openstack/restapi/mode/listvolumes.pm | 17 +++++++++++++++ cloud/openstack/restapi/mode/network.pm | 17 +++++++++++++++ cloud/openstack/restapi/mode/port.pm | 17 +++++++++++++++ cloud/openstack/restapi/mode/volume.pm | 21 +++++++++++++++++++ 9 files changed, 161 insertions(+) diff --git a/cloud/openstack/restapi/mode/hypervisor.pm b/cloud/openstack/restapi/mode/hypervisor.pm index 8f1ad7284..7655a153e 100644 --- a/cloud/openstack/restapi/mode/hypervisor.pm +++ b/cloud/openstack/restapi/mode/hypervisor.pm @@ -85,6 +85,27 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hypervisor_id}) || $self->{option_results}->{hypervisor_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hypervisor-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/instance.pm b/cloud/openstack/restapi/mode/instance.pm index 1057cae41..6cd5b5bc6 100644 --- a/cloud/openstack/restapi/mode/instance.pm +++ b/cloud/openstack/restapi/mode/instance.pm @@ -93,6 +93,27 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{instance_id}) || $self->{option_results}->{instance_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --instance-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/listhypervisors.pm b/cloud/openstack/restapi/mode/listhypervisors.pm index 658e1910a..f6763f998 100644 --- a/cloud/openstack/restapi/mode/listhypervisors.pm +++ b/cloud/openstack/restapi/mode/listhypervisors.pm @@ -62,6 +62,23 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/listinstances.pm b/cloud/openstack/restapi/mode/listinstances.pm index a3836c5ff..323589ad7 100644 --- a/cloud/openstack/restapi/mode/listinstances.pm +++ b/cloud/openstack/restapi/mode/listinstances.pm @@ -62,6 +62,23 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/listnetworks.pm b/cloud/openstack/restapi/mode/listnetworks.pm index 5cd37c8e4..162f0f6b1 100644 --- a/cloud/openstack/restapi/mode/listnetworks.pm +++ b/cloud/openstack/restapi/mode/listnetworks.pm @@ -61,6 +61,19 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/listvolumes.pm b/cloud/openstack/restapi/mode/listvolumes.pm index 76cbac987..1ad82ef90 100644 --- a/cloud/openstack/restapi/mode/listvolumes.pm +++ b/cloud/openstack/restapi/mode/listvolumes.pm @@ -62,6 +62,23 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/network.pm b/cloud/openstack/restapi/mode/network.pm index b97807980..f1b4ba91c 100644 --- a/cloud/openstack/restapi/mode/network.pm +++ b/cloud/openstack/restapi/mode/network.pm @@ -86,6 +86,23 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{network_id}) || $self->{option_results}->{network_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --network-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/port.pm b/cloud/openstack/restapi/mode/port.pm index ac17a3aa1..51c51e703 100644 --- a/cloud/openstack/restapi/mode/port.pm +++ b/cloud/openstack/restapi/mode/port.pm @@ -86,6 +86,23 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{port_id}) || $self->{option_results}->{port_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --port-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) } diff --git a/cloud/openstack/restapi/mode/volume.pm b/cloud/openstack/restapi/mode/volume.pm index 7f9fb8b3d..3ca349c5d 100644 --- a/cloud/openstack/restapi/mode/volume.pm +++ b/cloud/openstack/restapi/mode/volume.pm @@ -94,6 +94,27 @@ sub check_options { push @{$self->{overload_th}->{$section}}, {filter => $filter, status => $status}; } + if (!defined($self->{option_results}->{header}) || $self->{option_results}->{header} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --header option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{data}) || $self->{option_results}->{data} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --data option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{hostname}) || $self->{option_results}->{hostname} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --hostname option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{tenant_id}) || $self->{option_results}->{tenant_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --tenant-id option."); + $self->{output}->option_exit(); + } + if (!defined($self->{option_results}->{volume_id}) || $self->{option_results}->{volume_id} eq '') { + $self->{output}->add_option_msg(short_msg => "You need to specify --volume-id option."); + $self->{output}->option_exit(); + } + $self->{http}->set_options(%{$self->{option_results}}) }