Example #1
0
	def test_basic0(self):

		radl = """
network publica ( outbound = 'yes')
system main (
cpu.arch='x86_64' and
cpu.count>=1 and
memory.size>=512m and
net_interfaces.count = 1 and
net_interface.0.connection='publica' and
disk.0.os.name='linux' and
disk.0.os.flavour='ubuntu'
)
system wn (
cpu.arch='x86_64' and
cpu.count>=1 and
memory.size>=524288k and
disk.0.os.name='linux'
)		"""

		r = parse_radl_text(radl)
		self.radl_check(r, [1, 2, 0, 0, 0])
		s = r.get(system("main"))
		self.assertEqual(s.getValue("cpu.arch"), "x86_64")
		self.assertEqual(s.getValue("net_interface.0.connection").getId(), "publica")
Example #2
0
	def test_system_merge0(self):

		radl = """
network public0 (outbound = 'yes' and attr0 = 'val0')
network public1 (outbound = 'yes' and attr1 = 'val1')
system s0 (
net_interface.0.connection = 'public0'
)
system s1 (
net_interface.0.connection = 'public1'
)		"""

		r = parse_radl_text(radl)
		self.radl_check(r)
		s0, s1 = r.get(system("s0")), r.get(system("s1"))
		s0.merge(s1, missing="other")
		pub0 = s0.getValue("net_interface.0.connection")
		self.assertIsInstance(pub0, network)
		self.assertEqual(pub0.getValue("attr0", None), None)
		self.assertEqual(pub0.getValue("attr1"), "val1")
Example #3
0
    def test_cluster_store(self, mo, makedirs, listdirs, requests):
        listdirs.return_value = ["cluster1"]
        res = ClusterStore.list()
        self.assertEqual(["cluster1"], res)

        requests.side_effect = self.get_response
        res = ClusterStore.load("cluster1", True)
        s = res.get(system("front"))
        self.assertEqual(s.getValue("__infrastructure_id"), "infid")
        self.assertIn(".ec3/clusters/cluster1", mo.call_args_list[-1][0][0])
        if sys.version_info < (3, 0):
            expected_res = """network public (\n  outbound = \'yes\'\n)\n\nsystem front (\n  net_interface.0.ip = \'8.8.8.8\' and\n  __infrastructure_id = \'infid\' and\n  auth = \'[{"type": "InfrastructureManager", "username": "******", "password": "******"}]\' and\n  __im_server = \'http://server.com:8800\' and\n  net_interface.0.connection = \'public\' and\n  nodes = 1 and\n  contextualization_output = \'contmsg\'\n)"""
            self.assertEqual(mo.mock_calls[-2][1][0], expected_res)
Example #4
0
    def test_cluster_store(self, mo, makedirs, listdirs, requests):
        listdirs.return_value = ["cluster1"]
        res = ClusterStore.list()
        self.assertEqual(["cluster1"], res)

        requests.side_effect = self.get_response
        res = ClusterStore.load("cluster1", True)
        s = res.get(system("front"))
        self.assertEqual(s.getValue("__infrastructure_id"), "infid")
        self.assertIn(".ec3/clusters/cluster1", mo.call_args_list[-1][0][0])
        if sys.version_info < (3, 0):
            expected_res = """network public (\n  outbound = \'yes\'\n)\n\nsystem front (\n  net_interface.0.ip = \'8.8.8.8\' and\n  __infrastructure_id = \'infid\' and\n  auth = \'[{"type": "InfrastructureManager", "username": "******", "password": "******"}]\' and\n  __im_server = \'http://server.com:8800\' and\n  net_interface.0.connection = \'public\' and\n  nodes = 1 and\n  contextualization_output = \'contmsg\'\n)"""
            self.assertEqual(mo.mock_calls[-2][1][0], expected_res)
Example #5
0
 def gen_radl(self):
     radl = RADL()
     n = network("public")
     n.setValue("outbound", "yes")
     s = system("front")
     s.setValue("ec3aas.username", "user")
     s.setValue("state", "configured")
     s.setValue("nodes", "1")
     s.setValue("net_interface.0.connection", n)
     s.setValue("net_interface.0.ip", "8.8.8.8")
     s.setValue("disk.0.os.credentials.password", "pass")
     s.setValue("disk.0.os.credentials.username", "user")
     radl.add(s)
     return radl, s
Example #6
0
	def test_features_hash(self):

		radl = """
network public0 (outbound = 'yes' and attr0 = 'val0')
system s0 (
price <= 5.0 and
net_interface.0.connection = 'public0'
)		"""

		r = parse_radl_text(radl)
		self.radl_check(r)
		def f(s, i):
			s = s.clone()
			s.setId(i)
		self.assertEqual(len(set([ f(r.get(system("s0")), i) for i in range(4) ])), 1)
Example #7
0
	def test_system_merge1(self):

		radl0 = """
network public0 (outbound = 'yes' and attr0 = 'val0')
system s0 (
net_interface.0.connection = 'public0'
)		"""
		radl1 = """
network public0 (outbound = 'yes' and attr0 = 'val1')
system s1 (
net_interface.0.connection = 'public0'
)		"""


		r0 = parse_radl_text(radl0)
		self.radl_check(r0)
		r1 = parse_radl_text(radl1)
		self.radl_check(r1)
		s0, s1 = r0.get(system("s0")), r1.get(system("s1"))
		with self.assertRaises(RADLConflict) as ex:
			s0.merge(s1, missing="other")
		self.assertEqual(ex.exception.f0.prop, "attr0")
		self.assertEqual(ex.exception.f0.value, "val0")
		self.assertEqual(ex.exception.f1.value, "val1")
Example #8
0
 def gen_radl(self):
     radl = RADL()
     n = network("public")
     n.setValue("outbound", "yes")
     s = system("front")
     s.setValue("ec3aas.username", "user")
     s.setValue("state", "configured")
     s.setValue("nodes", "1")
     s.setValue("net_interface.0.connection", n)
     s.setValue("net_interface.0.ip", "8.8.8.8")
     s.setValue("disk.0.os.credentials.password", "pass")
     s.setValue("disk.0.os.credentials.username", "user")
     s.setValue("provider.type", "OpenStack")
     radl.add(s)
     return radl, s
Example #9
0
	def test_system_concrete(self):

		radl = """
system main (
cpu.arch='x86_64' and
cpu.count>=1 and
memory.size>=512m and
disk.0.os.name='linux' and
disk.0.os.flavour='ubuntu' and
soft 100 (
  cpu.arch='x86_64' and
  cpu.count>=2 and
  memory.size>=1G
) and
soft 101 (
  disk.0.os.flavour='ubuntu' and
  disk.0.os.version='12.04'
) and
soft 50 (
  disk.0.os.name='windows'
)
)
system wn (
cpu.arch='x86_64' and
cpu.count>=1 and
memory.size>=512m and
disk.0.os.name='linux'
)		"""

		r = parse_radl_text(radl)
		self.radl_check(r)
		s = r.get(system("main"))
		self.assertIsInstance(s, system)
		concrete_s, score = s.concrete()
		self.assertIsInstance(concrete_s, system)
		self.assertEqual(score, 201)
Example #10
0
	def test_basic(self):

		radl = """
network publica (outbound = 'yes')
system cursoaws (
cpu.arch='x86_64' and
cpu.count>=1 and
memory.size>=512m and
net_interface.0.connection = 'publica' and
net_interface.0.dns_name = 'cursoaws' and
disk.0.os.name='linux' and
disk.0.os.flavour='ubuntu' and
disk.0.os.version='12.04' and
disk.0.applications contains (name='org.grycap.cursoaws') and
disk.0.os.credentials.public_key = 'alucloud00-keypair' and
disk.0.os.credentials.private_key = '-----BEGIN RSA PRIVATE KEY-----
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-----END RSA PRIVATE KEY-----' and
escape_var = 'this is a \\'test\\'' and
soft 1 (
  cpu.count <= 10 and
  memory.size <= 1G and
  disk.0.os.flavour='ubuntu'
)
)

configure cursoaws (
@begin
---
  - vars:
    ak_00: BBBBBBBBBBBBBBB0AA
    sk_00: ffffffffffff23202m/Sfasf/Ahaspe70efsa
    PBS_SERVER_CONF: |
      create queue batch
      set queue batch queue_type = Execution
      set queue batch resources_default.nodes = 1
      set queue batch enabled = True
      set queue batch started = True
      set server default_queue = batch
    tasks:
    - name: Create user
      user: name=alucloud00 password=1234
    - shell: |
        for i in `seq 0 {{NNODES-1}}`; do
           item="{{VNODES_PREFIX}}${i}{{VNODES_SUFFIX}}";
           grep -q ${item} /etc/hosts || echo "127.0.0.1 ${item}.localdomain ${item}" >> /etc/hosts;
        done
      args:
        sudo: yes
@end
)

configure Ubuntu (
@begin
  TORQUE_PATH: /var/spool/torque
  MOM_SERVICE: torque-mom
@end
)

deploy cursoaws 1
		"""
		r = parse_radl_text(radl)
		self.radl_check(r, [1, 1, 1, 2, 0])
		s = r.get(system("cursoaws"))
		self.assertIsInstance(s, system)
		self.assertEqual(len(s.features), 13)
		self.assertEqual(s.getValue("disk.0.os.name"), "linux")