pec 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 40647fc979435e780b1ed75ef3d5d5c69cef8430
4
- data.tar.gz: bd561098ca4192c67f9ddb18f2b0f1dd0874ad7d
3
+ metadata.gz: ff9692ce800f020d84648166b9b0efd0dd706850
4
+ data.tar.gz: 1bc2f21a9975f5b961e6a7546a1bfc39047b79aa
5
5
  SHA512:
6
- metadata.gz: caaf7f0b8c4b9f453734816999f23241ed1a319abc73c4c08b9cd545b08176f9fdc4c74aea9f400c07ec91244913ca13b26ef5046b10ee2a3cf2cd72aa5c6cdd
7
- data.tar.gz: 2e70c4393bbb7cad5c0ab3b2485ddd78e4e59f7412ab9edeb9465ea51277be691387611937022528fb9f457b2189bb4102ef2873c23e22c7a9cb270c2f156d6a
6
+ metadata.gz: 516b5d1eb608325daa9896903b29998c8475b69455336bc5872ca67877774a9a7f4b2a2e47c1a6b64535014e55e0b066affbdc703b52840f75a01ded22aeff57
7
+ data.tar.gz: d279871aacbbde8bdf9f7df4994531c755abca182486e3c8fd55d3cbadfd1e34c5eab43b75514328e0ad06d41b665cf7e5f294fea2ff0445d0787c98b7a2d59f
@@ -28,14 +28,14 @@ module Pec
28
28
  ifcfg_content["type"] = ether.options['type'] ||'Ethernet'
29
29
  ifcfg_content["onboot"] = ether.options['onboot'] || 'yes'
30
30
  ifcfg_content["hwaddr"] = ether.find_port(ports).mac_address
31
- path = ether.options['path'] || "/etc/sysconfig/network-scripts/ifcfg-#{ether.name}"
32
-
33
31
  if ether.bootproto == "static"
34
32
  ifcfg_content["netmask"] = ether.find_port(ports).netmask
35
33
  ifcfg_content["ipaddr"] = ether.find_port(ports).ip_address
36
34
  end
35
+
37
36
  ifcfg_content.merge!(ether.options)
38
37
 
38
+ path = ether.options['path'] || "/etc/sysconfig/network-scripts/ifcfg-#{ether.name}"
39
39
  {
40
40
  'content' => ifcfg_content.map {|k,v| "#{k.upcase}=#{v}"}.join("\n"),
41
41
  'owner' => "root:root",
@@ -22,8 +22,8 @@ module Pec
22
22
  end if host.networks
23
23
  end
24
24
 
25
- def get_nics(ports)
26
- { 'nics' => ports.map { |port| { port_id: port.id } }}
25
+ def set_nics(options, ports)
26
+ ports ? options.merge({ 'nics' => ports.map { |port| { port_id: port.id } } }) : options
27
27
  end
28
28
 
29
29
  def get_security_group_id(security_groups)
@@ -20,8 +20,7 @@ module Pec
20
20
  flavor_ref = Pec::Compute::Flavor.get_ref(host.flavor)
21
21
  image_ref = Pec::Compute::Image.get_ref(host.image)
22
22
  options = { "user_data" => Pec::Configure::UserData.make(host, ports) }
23
-
24
- options.merge!(Pec::Director::Helper.get_nics(ports))
23
+ options = Pec::Director::Helper.set_nics(options, ports)
25
24
 
26
25
  Pec::Compute::Server.create(host.name, image_ref, flavor_ref, options)
27
26
  end
@@ -21,14 +21,9 @@ module Pec
21
21
  Pec::Network::PortState.new(name, assign_port)
22
22
  end
23
23
 
24
- def get_free_port_ip(ip, subnet)
25
- port = fetch_free_port(subnet)
26
- port ? IP.new("#{port["fixed_ips"][0]["ip_address"]}/#{ip.pfxlen}") : ip
27
- end
28
-
29
24
  def create(ip, subnet, security_group_ids)
30
- options = set_security_group(security_group_ids)
31
- options = set_fixed_ip(options, subnet, ip)
25
+ options = set_security_group(security_group_ids)
26
+ options = set_fixed_ip(options, subnet, ip)
32
27
  response = Pec::Resource.get.create_port(subnet["network_id"], options)
33
28
 
34
29
  raise(Pec::Errors::Port, "ip:#{ip.to_addr} is not created!") unless response
@@ -45,6 +40,11 @@ module Pec
45
40
  ip.to_s != subnet["cidr"] ? options.merge({ fixed_ips: [{ subnet_id: subnet["id"], ip_address: ip.to_addr}]}) : options
46
41
  end
47
42
 
43
+ def get_free_port_ip(ip, subnet)
44
+ port = fetch_free_port(subnet)
45
+ port ? IP.new("#{port["fixed_ips"][0]["ip_address"]}/#{ip.pfxlen}") : ip
46
+ end
47
+
48
48
  def delete(ip)
49
49
  target_port = fetch_by_ip(ip.to_addr)
50
50
  response = Pec::Resource.get.delete_port(target_port["id"]) if target_port
@@ -1,3 +1,3 @@
1
1
  module Pec
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kazuhiko yamashita