misty 0.9.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +12 -8
 - data/lib/misty/http/client.rb +1 -1
 - data/lib/misty/http/request.rb +3 -3
 - data/lib/misty/version.rb +1 -1
 - data/test/integration/compute_test.rb +4 -2
 - data/test/integration/network_test.rb +4 -3
 - data/test/integration/orchestration_test.rb +8 -4
 - data/test/unit/http/direct_test.rb +8 -8
 - data/test/unit/service_helper.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: '08884c370b4d79670e9d2b9c8adbbed79f1663a5'
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 121229f87354ccfd1c492cc168b9e5ccaed57363
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d537db25e7d1bcbf6d3e6d55bd480367261d5a6011351c8d0f32dddba91c12af99e2141db3a58051ed1c9a4040c3cdbf5a7f2d9a2ab138e8f72f6ff7f3e8825f
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c32da00cd2ba16c7d5a559ff3905a6e3fdca8a4e97d868a6594f6fc0ae1858b0f3eb84f03a6882bec4c8036206ca14c721bf8ef2d925ba1d415d1e329dfbd638
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,16 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Introduction
         
     | 
| 
       2 
     | 
    
         
            -
            Misty is a HTTP client for OpenStack APIs, aiming to be fast  
     | 
| 
       3 
     | 
    
         
            -
            APIs  
     | 
| 
      
 2 
     | 
    
         
            +
            Misty is a HTTP client for OpenStack APIs, aiming to be fast, flexible and exhaustive.
         
     | 
| 
      
 3 
     | 
    
         
            +
            Misty acts as a conduit to OpenStack APIs by handling requests as transparently as possible.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            ## Features
         
     | 
| 
       6 
6 
     | 
    
         
             
            * Flexible Openstack APIs integration
         
     | 
| 
       7 
7 
     | 
    
         
             
            * Standardized Openstack APIs: [Based upon API-ref](https://developer.openstack.org/api-guide/quick-start/)
         
     | 
| 
       8 
     | 
    
         
            -
            *  
     | 
| 
      
 8 
     | 
    
         
            +
            * Automatically generated API schemas - Any request can be overridden
         
     | 
| 
      
 9 
     | 
    
         
            +
            * Versions and Microversions
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Transparent Request data hanlding
         
     | 
| 
      
 11 
     | 
    
         
            +
            * Response data format of choice: JSON or raw (Ruby)
         
     | 
| 
      
 12 
     | 
    
         
            +
            * Custom HTTP Methods for special needs
         
     | 
| 
       9 
13 
     | 
    
         
             
            * On demand services - Auto loads required versions
         
     | 
| 
       10 
     | 
    
         
            -
            * Low 
     | 
| 
       11 
     | 
    
         
            -
            *  
     | 
| 
       12 
     | 
    
         
            -
            * Persistent HTTP connections (default since HTTP 1.1 anyway) but for the authentication bootstrapping
         
     | 
| 
       13 
     | 
    
         
            -
            * Direct HTTP Methods for custom needs
         
     | 
| 
      
 14 
     | 
    
         
            +
            * Low dependency - Use standard Net/HTTP and JSON gem only
         
     | 
| 
      
 15 
     | 
    
         
            +
            * Persistent HTTP connections (default since HTTP 1.1 anyway)
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
17 
     | 
    
         
             
            ## A solid KISS
         
     | 
| 
       16 
18 
     | 
    
         
             
            For REST transactions Misty relies on standard Net/HTTP library.  
         
     | 
| 
         @@ -76,7 +78,8 @@ Each service name (i.e. `compute`) is the object handling API requests. 
     | 
|
| 
       76 
78 
     | 
    
         
             
            openstack = Misty::Cloud.new(:auth => { ... })
         
     | 
| 
       77 
79 
     | 
    
         
             
            openstack.compute.list_servers
         
     | 
| 
       78 
80 
     | 
    
         
             
            openstack.network.list_networks
         
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
            data = Misty.to_json('network': {'name': 'my-network'})
         
     | 
| 
      
 82 
     | 
    
         
            +
            openstack.network.create_network(data)
         
     | 
| 
       80 
83 
     | 
    
         
             
            ```
         
     | 
| 
       81 
84 
     | 
    
         | 
| 
       82 
85 
     | 
    
         
             
            To obtain the list of supported services:
         
     | 
| 
         @@ -316,6 +319,7 @@ openstack.network.post('/v2.0/qos/policies/48985e6b8da145699d411f12a3459fca/dscp 
     | 
|
| 
       316 
319 
     | 
    
         
             
            # Requirements
         
     | 
| 
       317 
320 
     | 
    
         | 
| 
       318 
321 
     | 
    
         
             
            ## Ruby versions tested
         
     | 
| 
      
 322 
     | 
    
         
            +
            * Ruby MRI 2.4.2
         
     | 
| 
       319 
323 
     | 
    
         
             
            * Ruby MRI 2.4.1
         
     | 
| 
       320 
324 
     | 
    
         
             
            * Ruby MRI 2.4.0
         
     | 
| 
       321 
325 
     | 
    
         
             
            * Ruby MRI 2.3.4
         
     | 
    
        data/lib/misty/http/client.rb
    CHANGED
    
    | 
         @@ -74,7 +74,7 @@ module Misty 
     | 
|
| 
       74 
74 
     | 
    
         | 
| 
       75 
75 
     | 
    
         
             
                  def headers
         
     | 
| 
       76 
76 
     | 
    
         
             
                    header = {}
         
     | 
| 
       77 
     | 
    
         
            -
                    header.merge!({' 
     | 
| 
      
 77 
     | 
    
         
            +
                    header.merge!({'Accept' => 'application/json; q=1.0'})
         
     | 
| 
       78 
78 
     | 
    
         
             
                    header.merge!('X-Auth-Token' => @auth.get_token.to_s)
         
     | 
| 
       79 
79 
     | 
    
         
             
                    header.merge!(@config.headers) if @config.headers
         
     | 
| 
       80 
80 
     | 
    
         
             
                    header.merge!(@options.headers) if @options.headers
         
     | 
    
        data/lib/misty/http/request.rb
    CHANGED
    
    | 
         @@ -54,21 +54,21 @@ module Misty 
     | 
|
| 
       54 
54 
     | 
    
         
             
                  def http_patch(path, headers, data)
         
     | 
| 
       55 
55 
     | 
    
         
             
                    @config.log.info(http_to_s(path, headers, data))
         
     | 
| 
       56 
56 
     | 
    
         
             
                    request = Net::HTTP::Patch.new(path, headers)
         
     | 
| 
       57 
     | 
    
         
            -
                    request.body =  
     | 
| 
      
 57 
     | 
    
         
            +
                    request.body = data
         
     | 
| 
       58 
58 
     | 
    
         
             
                    http(request)
         
     | 
| 
       59 
59 
     | 
    
         
             
                  end
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                  def http_post(path, headers, data)
         
     | 
| 
       62 
62 
     | 
    
         
             
                    @config.log.info(http_to_s(path, headers, data))
         
     | 
| 
       63 
63 
     | 
    
         
             
                    request = Net::HTTP::Post.new(path, headers)
         
     | 
| 
       64 
     | 
    
         
            -
                    request.body =  
     | 
| 
      
 64 
     | 
    
         
            +
                    request.body = data
         
     | 
| 
       65 
65 
     | 
    
         
             
                    http(request)
         
     | 
| 
       66 
66 
     | 
    
         
             
                  end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
                  def http_put(path, headers, data)
         
     | 
| 
       69 
69 
     | 
    
         
             
                    @config.log.info(http_to_s(path, headers, data))
         
     | 
| 
       70 
70 
     | 
    
         
             
                    request = Net::HTTP::Put.new(path, headers)
         
     | 
| 
       71 
     | 
    
         
            -
                    request.body =  
     | 
| 
      
 71 
     | 
    
         
            +
                    request.body = data
         
     | 
| 
       72 
72 
     | 
    
         
             
                    http(request)
         
     | 
| 
       73 
73 
     | 
    
         
             
                  end
         
     | 
| 
       74 
74 
     | 
    
         | 
    
        data/lib/misty/version.rb
    CHANGED
    
    
| 
         @@ -7,7 +7,8 @@ describe 'Compute Service Nova v2.1 features' do 
     | 
|
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  # POST with body data
         
     | 
| 
       9 
9 
     | 
    
         
             
                  server = { 'name': 'test_create_server', 'flavorRef': '1', 'imageRef': 'c091ccf2-a4ae-4fa0-a716-defd6376b5dc', 'networks': [{'uuid': '9c6e43b6-3d1d-4106-ad45-5fc3f5e371ee'}]}
         
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
      
 10 
     | 
    
         
            +
                  data = Misty.to_json('server' => server)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  response = cloud.compute.create_server(data)
         
     | 
| 
       11 
12 
     | 
    
         
             
                  response.code.must_equal '202'
         
     | 
| 
       12 
13 
     | 
    
         
             
                  id = response.body['server']['id']
         
     | 
| 
       13 
14 
     | 
    
         
             
                  id.wont_be_empty
         
     | 
| 
         @@ -24,7 +25,8 @@ describe 'Compute Service Nova v2.1 features' do 
     | 
|
| 
       24 
25 
     | 
    
         | 
| 
       25 
26 
     | 
    
         
             
                  # PUT with URI value and body data
         
     | 
| 
       26 
27 
     | 
    
         
             
                  update_server = { 'name': 'test_updated_server' }
         
     | 
| 
       27 
     | 
    
         
            -
                   
     | 
| 
      
 28 
     | 
    
         
            +
                  data = Misty.to_json('server' => update_server)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  response = cloud.compute.update_server(id, data)
         
     | 
| 
       28 
30 
     | 
    
         
             
                  response.code.must_equal '200'
         
     | 
| 
       29 
31 
     | 
    
         
             
                  response.body['server']['name'].must_equal 'test_updated_server'
         
     | 
| 
       30 
32 
     | 
    
         | 
| 
         @@ -6,7 +6,8 @@ describe 'Network Service Neutron v2.0 features' do 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  cloud = Misty::Cloud.new(:auth => auth, :network => {:api_version => 'v2.0'})
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
                  # POST with body data
         
     | 
| 
       9 
     | 
    
         
            -
                   
     | 
| 
      
 9 
     | 
    
         
            +
                  data = Misty.to_json('network' => { 'name': 'test_network' })
         
     | 
| 
      
 10 
     | 
    
         
            +
                  response = cloud.network.create_network(data)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  response.code.must_equal '201'
         
     | 
| 
       11 
12 
     | 
    
         
             
                  id = response.body['network']['id']
         
     | 
| 
       12 
13 
     | 
    
         
             
                  id.wont_be_empty
         
     | 
| 
         @@ -22,8 +23,8 @@ describe 'Network Service Neutron v2.0 features' do 
     | 
|
| 
       22 
23 
     | 
    
         
             
                  response.body['network']['name'].must_equal 'test_network'
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
                  # PUT with URI value and body data
         
     | 
| 
       25 
     | 
    
         
            -
                   
     | 
| 
       26 
     | 
    
         
            -
                  response = cloud.network.update_network(id,  
     | 
| 
      
 26 
     | 
    
         
            +
                  data = Misty.to_json('network' => { 'name': 'test_updated_network' })
         
     | 
| 
      
 27 
     | 
    
         
            +
                  response = cloud.network.update_network(id, data)
         
     | 
| 
       27 
28 
     | 
    
         
             
                  response.code.must_equal '200'
         
     | 
| 
       28 
29 
     | 
    
         
             
                  response.body['network']['name'].must_equal 'test_updated_network'
         
     | 
| 
       29 
30 
     | 
    
         | 
| 
         @@ -53,12 +53,14 @@ describe 'Orchestration Service using Heat v1' do 
     | 
|
| 
       53 
53 
     | 
    
         
             
                  cloud = Misty::Cloud.new(:auth => auth, :orchestration => {:api_version => 'v1'})
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
       55 
55 
     | 
    
         
             
                  # POST with body data
         
     | 
| 
       56 
     | 
    
         
            -
                   
     | 
| 
      
 56 
     | 
    
         
            +
                  data_heat_template1 = Misty.to_json(heat_template1)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  response = cloud.orchestration.create_stack(data_heat_template1)
         
     | 
| 
       57 
58 
     | 
    
         
             
                  response.code.must_equal '201'
         
     | 
| 
       58 
59 
     | 
    
         
             
                  id1 = response.body['stack']['id']
         
     | 
| 
       59 
60 
     | 
    
         
             
                  id1.wont_be_empty
         
     | 
| 
       60 
61 
     | 
    
         | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
      
 62 
     | 
    
         
            +
                  data_heat_template2 = Misty.to_json(heat_template2)
         
     | 
| 
      
 63 
     | 
    
         
            +
                  response = cloud.orchestration.create_stack(data_heat_template2)
         
     | 
| 
       62 
64 
     | 
    
         
             
                  response.code.must_equal '201'
         
     | 
| 
       63 
65 
     | 
    
         
             
                  id2 = response.body['stack']['id']
         
     | 
| 
       64 
66 
     | 
    
         
             
                  id2.wont_be_empty
         
     | 
| 
         @@ -77,11 +79,13 @@ describe 'Orchestration Service using Heat v1' do 
     | 
|
| 
       77 
79 
     | 
    
         
             
                  # Updating the network template because it's faster to execute
         
     | 
| 
       78 
80 
     | 
    
         
             
                  # therefore more likely to be in ready state before updating
         
     | 
| 
       79 
81 
     | 
    
         
             
                  heat_template1[:template][:description] = 'Updated test template'
         
     | 
| 
       80 
     | 
    
         
            -
                   
     | 
| 
      
 82 
     | 
    
         
            +
                  data_heat_template1 = Misty.to_json(heat_template1)
         
     | 
| 
      
 83 
     | 
    
         
            +
                  response = cloud.orchestration.update_stack('test_stack1', id1, data_heat_template1)
         
     | 
| 
       81 
84 
     | 
    
         
             
                  response.code.must_equal '202'
         
     | 
| 
       82 
85 
     | 
    
         | 
| 
       83 
86 
     | 
    
         
             
                  # PATCH with URI values
         
     | 
| 
       84 
     | 
    
         
            -
                   
     | 
| 
      
 87 
     | 
    
         
            +
                  data = Misty.to_json('disable_rollback': false)
         
     | 
| 
      
 88 
     | 
    
         
            +
                  response = cloud.orchestration.update_stack_patch('test_stack1', id1, data)
         
     | 
| 
       85 
89 
     | 
    
         
             
                  response.code.must_equal '202'
         
     | 
| 
       86 
90 
     | 
    
         | 
| 
       87 
91 
     | 
    
         
             
                  # DELETE with URI value
         
     | 
| 
         @@ -61,19 +61,19 @@ describe Misty::HTTP::Direct do 
     | 
|
| 
       61 
61 
     | 
    
         
             
              describe '#post' do
         
     | 
| 
       62 
62 
     | 
    
         
             
                it 'successful without providing a base url' do
         
     | 
| 
       63 
63 
     | 
    
         
             
                  stub_request(:post, 'http://localhost/resource/test').
         
     | 
| 
       64 
     | 
    
         
            -
                    with(:body =>  
     | 
| 
      
 64 
     | 
    
         
            +
                    with(:body => 'data', :headers => request_header).
         
     | 
| 
       65 
65 
     | 
    
         
             
                    to_return(:status => 201, :body => '', :headers => {})
         
     | 
| 
       66 
66 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
                  response = service.post('/resource/test', 'data' 
     | 
| 
      
 67 
     | 
    
         
            +
                  response = service.post('/resource/test', 'data')
         
     | 
| 
       68 
68 
     | 
    
         
             
                  response.must_be_kind_of Net::HTTPCreated
         
     | 
| 
       69 
69 
     | 
    
         
             
                  response.body.must_be_nil
         
     | 
| 
       70 
70 
     | 
    
         
             
                end
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
72 
     | 
    
         
             
                it 'successful with a base url' do
         
     | 
| 
       73 
73 
     | 
    
         
             
                  stub_request(:post, 'http://localhost/another-base/resource/test').
         
     | 
| 
       74 
     | 
    
         
            -
                    with(:body =>  
     | 
| 
      
 74 
     | 
    
         
            +
                    with(:body => 'data', :headers => request_header).
         
     | 
| 
       75 
75 
     | 
    
         
             
                    to_return(:status => 201, :body => '', :headers => {})
         
     | 
| 
       76 
     | 
    
         
            -
                  response = service.post('/resource/test',  
     | 
| 
      
 76 
     | 
    
         
            +
                  response = service.post('/resource/test', 'data', '/another-base')
         
     | 
| 
       77 
77 
     | 
    
         
             
                  response.must_be_kind_of Net::HTTPCreated
         
     | 
| 
       78 
78 
     | 
    
         
             
                  response.body.must_be_nil
         
     | 
| 
       79 
79 
     | 
    
         
             
                end
         
     | 
| 
         @@ -82,20 +82,20 @@ describe Misty::HTTP::Direct do 
     | 
|
| 
       82 
82 
     | 
    
         
             
              describe '#put' do
         
     | 
| 
       83 
83 
     | 
    
         
             
                it 'successful without providing a base url' do
         
     | 
| 
       84 
84 
     | 
    
         
             
                  stub_request(:put, 'http://localhost/resource/test').
         
     | 
| 
       85 
     | 
    
         
            -
                    with(:body =>  
     | 
| 
      
 85 
     | 
    
         
            +
                    with(:body => 'data', :headers => request_header).
         
     | 
| 
       86 
86 
     | 
    
         
             
                    to_return(:status => 200, :body => '', :headers => {})
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                  response = service.put('/resource/test', 'data' 
     | 
| 
      
 88 
     | 
    
         
            +
                  response = service.put('/resource/test', 'data')
         
     | 
| 
       89 
89 
     | 
    
         
             
                  response.must_be_kind_of Net::HTTPOK
         
     | 
| 
       90 
90 
     | 
    
         
             
                  response.body.must_be_nil
         
     | 
| 
       91 
91 
     | 
    
         
             
                end
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
93 
     | 
    
         
             
                it 'successful with a base url' do
         
     | 
| 
       94 
94 
     | 
    
         
             
                  stub_request(:put, 'http://localhost/another-base/resource/test').
         
     | 
| 
       95 
     | 
    
         
            -
                    with(:body =>  
     | 
| 
      
 95 
     | 
    
         
            +
                    with(:body => 'data', :headers => request_header).
         
     | 
| 
       96 
96 
     | 
    
         
             
                    to_return(:status => 200, :body => '', :headers => {})
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
                  response = service.put('/resource/test',  
     | 
| 
      
 98 
     | 
    
         
            +
                  response = service.put('/resource/test', 'data', '/another-base')
         
     | 
| 
       99 
99 
     | 
    
         
             
                  response.must_be_kind_of Net::HTTPOK
         
     | 
| 
       100 
100 
     | 
    
         
             
                  response.body.must_be_nil
         
     | 
| 
       101 
101 
     | 
    
         
             
                end
         
     | 
    
        data/test/unit/service_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: misty
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Gilles Dubreuil
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-10- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-10-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: json
         
     |