#
# Author:: NagaLakshmi (<nagalakshmi.n@cusdelight.com>)
# Copyright:: Copyright (c) Computenext
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'chef/knife/computenext_base'

class Chef
  class Knife
    class ComputenextVolumestorageAttach < Knife

      include Knife::ComputenextBase

      banner "knife computenext volumestorage attach [VOLUME STORAGE ID] [TARGET VM ID] [DEVICE NAME]"
	  category "computenext volumestorage"

      def run
		volume_storage_id = @name_args[0]
		target_vm_id = @name_args[1]
		device_name = @name_args[2]		
		data = connection.attach_volume(volume_storage_id,target_vm_id,device_name).body
		puts JSON.pretty_generate(data)
		puts "Volume attache request submitted successfully!!! Please check the request status using 'knife computenext request retrieve status [REQUEST ID]'"		
      end     
    end
  end
end



