Commit Graph

12 Commits

Author SHA1 Message Date
M V P Nitesh 580677eedc Replace six.iteritems() with .items()
1.As mentioned in [1], we should avoid using six.iteritems to achieve
iterators. We can use dict.items instead, as it will return iterators
in PY3 as well. And dict.items/keys will more readable.
2.In py2, the performance about list should be negligible, see the
link [2].
[1] https://wiki.openstack.org/wiki/Python3
[2] http://lists.openstack.org/pipermail/openstack-dev/2015-June/066391.html

Change-Id: I45fa65427318e1c35bb521de46e81ea12ca7b770
2017-05-03 09:17:18 +00:00
Stan Lagun 0a835b87f0 Refactoring of the ObjectStore passing in DSL
ObjectStore is a container for all of the objects that are either
loaded from object model or created at runtime. Thus ObjectStore
instance is required in order to either use new() function or use
class() contract with object model snippet.

In current implementation each object had a object_store property
that was pointing to the ObjectStore instance used to create it (the
one that has the object). In order to create new object an ObjectStore
of the $this object was used for that purpose. This approach caused
several issues:
* There is no $this object in static methods and thus no way to obtain
   current ObjectStore
* Objects are bind to their stores so temporary ObjectStore instances
  cannot be used to load object graphs

 This refactoring moves ObjectStore instances to the thread-local attribute.
 Thus there is always a "current" ObjectStore.

 Also because ObjectStore has a reference to the MuranoDslExecutor instance
 it becomes possible to get current executor and everything else that it contains
 (current execution session, attribute store, package loader) from the local
 thread storage without passing it in the hidden context variables.

Change-Id: I19a08b391486c1ae1b98ca559c8d3fafaca6e1ef
2016-07-27 02:32:18 +00:00
Stan Lagun 73f798da57 Extension methods were introduced to MuranoPL
* New method type: extension methods. Extension methods enable you
   to "add" methods to existing types without modifying the original type.

   Extension methods are a special kind of static method, but they are
   called as if they were instance methods on the extended type.

   Extension methods are identified by "Usage: Extension" and the
   type they extend is determined by their first argument contract.
   Thus such methods must have at lease one parameter.

* New type-level keyword "Import" which can be either list or
   scalar that specifies type names which extensions methods
   should be imported into class context and thus become available
   to type members.

Change-Id: If757327857376ac66784acd4bd29471e6f28b612
2016-03-03 15:01:30 +00:00
Stan Lagun 7c200d66f1 Use more generic "type" name instead of "murano_class"
Because the're going to be many different types of classes
(like meta-classes) it is reasonable to distinguish murano_class
from a "type", that can refer to any type of class (type)

Change-Id: I05993eb7a37627aaeacbc6c828250791e145d706
2016-02-26 17:25:25 +03:00
Stan Lagun 4f9ab7a321 Refactoring of smart-types defined in DSL
* MuranoType and MuranoObjectParameterType smart types
  were merged into a single smart type because their functionality overlap
  to a large degree. New smart type is called MuranoObjectParameter
* Other smart types were renamed to have the same name pattern:
   ThisParameterType -> ThisParameter,
   InterfacesParameterType -> InterfacesParameter
* For MuranoObjectInterface instead of saying obj.data().propertyName
   the syntax now is obj.properties.propertyName

Change-Id: I3c925d1ba1a4ac0864987377a3e90c6f166823a7
2016-02-25 02:06:38 +03:00
Stan Lagun f4ff2fb482 Basic reflection capabilities were added to MuranoPL
Now it is possible to get type info with typeinfo() function and using
it as a starting point obtain information about the class, its methods
and properties as well as the package of the class.
See TestReflection.yaml for detailed usage.

Also some refactoring to existing code model were made.

Change-Id: Ic8a719e874126d735c26b956a49cb790d434c64c
2016-02-18 22:22:11 +00:00
Stan Lagun 2c5f1454bf Migration to yaql 1.1
* Remove all code that now available as part of yaql 1.1
* New format version MuranoPL/1.3 that is identical to 1.2
  but protects apps that uses yaql 1.1 new features from being
  imported to Murano Liberty

Change-Id: I2d8fc7050403be082e9389ebe5e682816ec6aca1
2016-02-18 12:00:59 +00:00
Ravi Shekhar Jethani 859888d62a Python3: Replace dict.iteritems with six.iteritems
This also adds a check to murano/hacking/checks.py that
should catch this error in the future.

Blueprint murano-python-3-support
Change-Id: Ib8b2b91a40577d18739f0c1bf2c37b7cf4060560
2016-01-15 03:15:23 -08:00
Ekaterina Chernova 448186d99c Fix test class property access in mocks
Previously property was looked up in the original class.
Add unit test to check this situation.

Closes-Bug: #1525890

Change-Id: I7ba9efc58fbcc4b8ff281909473d1c972f0a2507
2015-12-24 14:58:31 +03:00
Ekaterina Chernova b9b2a9b881 [mocking-machinery] Add original method function
This commit adds opportunity to call original method
in mock method. Corresponding test is attached.

Targets blueprint mocking-machinery

Change-Id: I889bb576e708d28a083c0a25f66c999a6492057f
2015-12-14 15:36:07 +03:00
Ekaterina Chernova d321757468 [mocking-machinery] Add inject YAQL functions
Functions for injecting class methods or objects with mocks are added:
* mock can be provided as method name
* mock can be provided as YAQL expression

* Also, withOriginal function is added.

  withOriginal allows to use data from the original context in mock function.

Targets blueprint mock-context-manager

Depends-On: I9a55d07188ff06bdf98248f011a700c297e33417

Change-Id: Iefee767390209bfad0cca4f39389e0205cd3c9e2
2015-12-10 17:50:22 +03:00
Ekaterina Chernova fd59720b1b Add MockContextManager
It is used in murano-test-runner.

Mocks are inserted into new context, that is created
from the current context:
If mock for the current object exist, new linked context
   (``murano.dsl.linked_context.LinkedContext``) will be returned. It links
   existing context with the new context, where mock definition is presented.
   So if mocked function will be called, context will contain two
   definitions with that function: mock and original one, but mock will have
   higher priority.

If there is no mock for the current object or class, existing context
   will be returned. If there is no existing context, *None* will be returned.

Targets blueprint mock-context-manager

Depends-On: I9eccdf3af1802c731bfdfb93df92c4ad902a4d34
Change-Id: I9a55d07188ff06bdf98248f011a700c297e33417
2015-12-08 14:10:22 +03:00