Skip to content

Commit

Permalink
Merge 6deb314 into ffa4733
Browse files Browse the repository at this point in the history
  • Loading branch information
manishsethi committed Feb 17, 2014
2 parents ffa4733 + 6deb314 commit 1a30618
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Vagrant.configure("2") do |config|
# Security Groups defaults to ["default"]
# rs.security_groups = ["group1", "group2"]
rs.floating_ip ="33.33.33.10" # Optional
rs.network = ["830744ee-38a8-4618-a1eb-7c06fcsdf78", "Test_Network"] # Optional
end
end
```
Expand Down
22 changes: 16 additions & 6 deletions lib/vagrant-hp/action/connect_hp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,24 @@ def call(env)

@logger.info('Connecting to HP...')
env[:hp_compute] = Fog::Compute.new(
provider: 'HP',
version: 'v2',
hp_access_key: access_key,
hp_secret_key: secret_key,
hp_tenant_id: tenant_id,
hp_avl_zone: availability_zone,
provider: 'HP',
version: :v2,
hp_access_key: access_key,
hp_secret_key: secret_key,
hp_tenant_id: tenant_id,
hp_avl_zone: availability_zone,
)

# If network is provided
if config.network
env[:hp_network] = Fog::HP::Network.new(
hp_access_key: access_key,
hp_secret_key: secret_key,
hp_tenant_id: tenant_id,
hp_avl_zone: availability_zone
)
end

@app.call(env)
end

Expand Down
11 changes: 11 additions & 0 deletions lib/vagrant-hp/action/create_server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def call(env)
security_groups: config.security_groups
}

# Find network if provided in Vagrantfile
if config.network
networks = Array.new
env[:ui].info(I18n.t('vagrant_hp.finding_network'))
config.network.each do |net|
network = find_match(env[:hp_network].networks, net)
networks.push(network.id) if network
end
options[:networks] = networks
end

# Create the server
server = env[:hp_compute].servers.create(options)

Expand Down
8 changes: 8 additions & 0 deletions lib/vagrant-hp/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Config < Vagrant.plugin('2', :config)

attr_accessor :floating_ip

attr_accessor :network

def initialize(region_specific = false)
@access_key = UNSET_VALUE
@secret_key = UNSET_VALUE
Expand All @@ -44,6 +46,9 @@ def initialize(region_specific = false)
@ssh_private_key_path = UNSET_VALUE
@ssh_username = UNSET_VALUE
@flavor = UNSET_VALUE
@network = UNSET_VALUE
@config = UNSET_VALUE


@__compiled_region_configs = {}
@__finalized = false
Expand Down Expand Up @@ -110,6 +115,9 @@ def finalize!
@ssh_private_key_path = nil if @ssh_private_key_path == UNSET_VALUE
@ssh_username = nil if @ssh_username == UNSET_VALUE

# The network values.
@network = [] if @network == UNSET_VALUE

# Mark that we finalized
@__finalized = true
end
Expand Down
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ en:
Finding image for server...
finding_floating_ip: |-
Finding floating-ip...
finding_network: |-
Finding network...
deleting_floating_ip: |-
"Attempting to delete floating-ip..."
Expand Down

0 comments on commit 1a30618

Please sign in to comment.