Re: Where is the source for "charm build" binary?

2017-05-21 Thread Nobuto Murata
Hi,

2017-05-22 11:37 GMT+09:00 fengxia :
> I have used "charm build" to build my own charms. I noticed /usr/bin/charm
> is a binary file. Where is the source?

I believe the master repository is:
https://github.com/juju/charm-tools

-- 
Nobuto Murata / 村田信人

-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Where is the source for "charm build" binary?

2017-05-21 Thread fengxia

Hi Juju,

I have used "charm build" to build my own charms. I noticed 
/usr/bin/charm is a binary file. Where is the source?


--
Feng xia
Engineer
Lenovo USA

Phone: 5088011794
fx...@lenovo.com

Lenovo.com
Twitter | Facebook | Instagram | Blogs | Forums


--
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Here is how to make Juju charm working on CentOS7

2017-05-21 Thread fengxia

Juju,

As part of my research of juju charms, we have a requirement to make 
charm compatible with Centos7 and RHEL. However, charm is now using 
Python3 (in some places) and it will fail at "import yum" on CentOS7. I 
have googled it for a few days now and there is limited information on 
how to resolve. this.


So to make things simpler (or more complicated down the road?), I have 
decided to make a Python2-compatible charm. Be warned this is currently 
as a quick hack that I just put together yesterday and proved working. I 
will produce a better documentation later. But for ppl who are in this 
same boat, this may save your headaches or ease your concerns knowing 
that there is a way to "work around".


Objective: Build a Python2 compatible charm that includes layer-basic to 
run on centos7


Two dists: test1 is from default "charm build -s centos7", test25 is 
modified build.


What to modify:

1. Anywhere you see /usr/bin/python3, change to /usr/bin/python. Most of 
these are in /hooks.


2. Add a blank "__init__.py" in /lib/charms. Python2 module search path 
differently from python3.


3. charmhelpers: yes you have to make a modification in charmhelpers: 
/usr/lib/python2.7/site-packages/charmhelpers/fetch/__init__.py.


*if __platform__ == "ubuntu":
apt_cache = fetch.apt_cache
apt_install = fetch.install
apt_update = fetch.update
apt_upgrade = fetch.upgrade
apt_purge = fetch.purge
apt_mark = fetch.apt_mark
apt_hold = fetch.apt_hold
apt_unhold = fetch.apt_unhold
get_upstream_version = fetch.get_upstream_version
elif __platform__ == "centos":
yum_search = fetch.yum_search

# FENG: centos mapping
apt_install = fetch.install
apt_upgrade = fetch.upgrade
apt_update = fetch.update
apt_purge = fetch.purge
apt_cache = fetch.yum_search
*

4. charms.reactive: yes you need to modify this too. Only one place, 
charms.reactive-0.4.7/charms/reactive/relations.py:


class RelationBase(object):
__metaclass__=AutoAccessors

Now for details of diff of files changed and contents I modified to make 
this work:


1. Files to modify:

Files test1/bin/layer_option and test25/bin/layer_option differ
Files test1/.build.manifest and test25/.build.manifest differ
Files test1/hooks/config-changed and test25/hooks/config-changed differ
Files test1/hooks/hook.template and test25/hooks/hook.template differ
Files test1/hooks/install and test25/hooks/install differ
Files test1/hooks/leader-elected and test25/hooks/leader-elected differ
Files test1/hooks/leader-settings-changed and 
test25/hooks/leader-settings-changed differ

Files test1/hooks/start and test25/hooks/start differ
Files test1/hooks/stop and test25/hooks/stop differ
Files test1/hooks/update-status and test25/hooks/update-status differ
Files test1/hooks/upgrade-charm and test25/hooks/upgrade-charm differ
Files test1/layer.yaml and test25/layer.yaml differ
Only in test25/lib/charms: __init__.py
Files test1/lib/charms/layer/basic.py and 
test25/lib/charms/layer/basic.py differ

Only in test25/lib/charms/layer: basic.py.old
Files test1/lib/charms/layer/execd.py and 
test25/lib/charms/layer/execd.py differ

Files test1/metadata.yaml and test25/metadata.yaml differ
Files test1/wheelhouse/charmhelpers-0.15.0.tar.gz and 
test25/wheelhouse/charmhelpers-0.15.0.tar.gz differ
Files test1/wheelhouse/charms.reactive-0.4.7.tar.gz and 
test25/wheelhouse/charms.reactive-0.4.7.tar.gz differ


2. File contents diff:

diff -r test1/bin/layer_option test25/bin/layer_option
1c1
< #!/usr/bin/env python3
---
> #!/usr/bin/env python
4c4,5
< sys.path.append('lib')
---
> import os
> sys.path.append(os.path.join(os.getcwd(),'lib'))
diff -r test1/.build.manifest test25/.build.manifest
4c4
< "test1",
---
> "test25",
31c31
< "621b556cd208005e131e9f648859294347da9376609745a73ca2e808dd2032f9"
---
> "cf7f9c2bec7447406495c1bec5a549276ff26d9220b5bee3c3994253cad86b3d"
34c34
<   "test1",
---
>   "test25",
89c89
<   "test1",
---
>   "test25",
91c91,96
< "f2986d765f3980311b0064cccebdd9080e218a7c25100ae66d52b78f8fb2243c"
---
> "3d93ebb41e22cd44db352b5d87296a3fd67f5deb87729ee17f8b24b5fcd48955"
> ],
> "lib/charms/__init__.py": [
>   "layer:basic",
>   "static",
> "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
101c106,111
< "d09706ef3a224eb60d34366a2867c382791aa30157ab5b77eda37f29731df2e2"
---
> "80389fe735b9d9766515ed36d9134321838fc5bb88c225cdace57a50bbf739e1"
> ],
> "lib/charms/layer/basic.py.old": [
>   "layer:basic",
>   "static",
> "0f353699ba6b5213596354add24a7283273a4cee665a1a038556128f3fdd28db"
106c116
< "af1f2409869f990cdb33cffc4120fb6713876e8e680ac5f064ea510bbdca1073"
---
> "b7a88558cfd3511ea1eff0564524d0caef6e16daa5bf12b80f01183a1e73e4ff"
109c119
<   "test1",
---
>   "test25",
111c121
< "a3ff3ba5321d2b502dd1b9454976e62cc4dfc146d36c18626066c1dfc19787eb"
---
> "2949e0b71e303ac97855af82a938207fd3a1d52aee3f87780b5c48910ce1dad8"
119c129
<   "test1",

Re: charm build -s centos7 does nothing special?

2017-05-21 Thread fengxia
Anyone can shed some lights on this? I think charm build -s centos7 does 
nothing special to the build.


Btw, /usr/bin/charm is a binary. Where can I find the source?

On 05/20/2017 02:07 AM, fengxia wrote:

Hi Juju,

I made a hello world charm based on charm tutorial, which includes 
layer-basic. I noticed that "charm build" can take a switch "-s 
series". I specified "-s centos7", and diff the result from default 
built which is "trusty". There is no material different between two 
builds.


Is this expected?



--
Feng xia
Engineer
Lenovo USA

Phone: 5088011794
fx...@lenovo.com

Lenovo.com
Twitter | Facebook | Instagram | Blogs | Forums


--
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


Re: django charm broken or am I just doing it wrong?

2017-05-21 Thread John Meinel
I believe Tim Penhey makes active use of the python-django charm, but it's
possible he uses it in a different fashion.

John
=:->

On May 21, 2017 14:25, "Erik Lönroth"  wrote:

> Hello!
>
> I'm trying out the django charm to deploy a django website I was going to
> try to create with juju.
>
> * I followed the instructions here: https://jujucharms.com/python-django/
>
> * My website repo is here: https://github.com/erik78se/dsite
>
> It has installed the website from github but there is an error:
>
> unit-dsite-1: 12:22:13 INFO unit.dsite/1.pgsql-relation-changed 0
> upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
> unit-dsite-1: 12:22:14 DEBUG unit.dsite/1.juju-log pgsql:2: found django
> admin: /usr/bin/django-admin
> unit-dsite-1: 12:22:14 DEBUG unit.dsite/1.juju-log pgsql:2:
> PYTHONPATH=/srv/dsite/../ /usr/bin/django-admin syncdb --noinput
> --settings=dsite.settings
> unit-dsite-1: 12:22:14 ERROR unit.dsite/1.juju-log pgsql:2: status=1,
> output=Traceback (most recent call last):
>   File "/usr/bin/django-admin", line 5, in 
> management.execute_from_command_line()
>   File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 399, in execute_from_command_line
> utility.execute()
>   File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 261, in fetch_command
> commands = get_commands()
>   File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py",
> line 107, in get_commands
> apps = settings.INSTALLED_APPS
>   File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line
> 54, in __getattr__
> self._setup(name)
>   File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line
> 49, in _setup
> self._wrapped = Settings(settings_module)
>   File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line
> 132, in __init__
> % (self.SETTINGS_MODULE, e)
> ImportError: Could not import settings 'dsite.settings' (Is it on
> sys.path? Is there an import error in the settings file?): No module named
> dsite.settings
>
> unit-dsite-1: 12:22:14 ERROR juju.worker.uniter.operation hook
> "pgsql-relation-changed" failed: exit status 1
> unit-dsite-1: 12:22:14 INFO juju.worker.uniter awaiting error resolution
> for "relation-changed" hook
>
> As I'm not sure if I'm doing anything wrong or the charm is broken, I
> wonder what your suggestion is in how to resolve this issue or if I'm just
> doing it wrong.
>
> /Erik Lönroth
>
> --
> Juju mailing list
> Juju@lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/
> mailman/listinfo/juju
>
>
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju


django charm broken or am I just doing it wrong?

2017-05-21 Thread Erik Lönroth
Hello!

I'm trying out the django charm to deploy a django website I was going to
try to create with juju.

* I followed the instructions here: https://jujucharms.com/python-django/

* My website repo is here: https://github.com/erik78se/dsite

It has installed the website from github but there is an error:

unit-dsite-1: 12:22:13 INFO unit.dsite/1.pgsql-relation-changed 0 upgraded,
0 newly installed, 0 to remove and 0 not upgraded.
unit-dsite-1: 12:22:14 DEBUG unit.dsite/1.juju-log pgsql:2: found django
admin: /usr/bin/django-admin
unit-dsite-1: 12:22:14 DEBUG unit.dsite/1.juju-log pgsql:2:
PYTHONPATH=/srv/dsite/../ /usr/bin/django-admin syncdb --noinput
--settings=dsite.settings
unit-dsite-1: 12:22:14 ERROR unit.dsite/1.juju-log pgsql:2: status=1,
output=Traceback (most recent call last):
  File "/usr/bin/django-admin", line 5, in 
management.execute_from_command_line()
  File
"/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line
399, in execute_from_command_line
utility.execute()
  File
"/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line
392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File
"/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line
261, in fetch_command
commands = get_commands()
  File
"/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line
107, in get_commands
apps = settings.INSTALLED_APPS
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 54,
in __getattr__
self._setup(name)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 49,
in _setup
self._wrapped = Settings(settings_module)
  File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line
132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'dsite.settings' (Is it on sys.path?
Is there an import error in the settings file?): No module named
dsite.settings

unit-dsite-1: 12:22:14 ERROR juju.worker.uniter.operation hook
"pgsql-relation-changed" failed: exit status 1
unit-dsite-1: 12:22:14 INFO juju.worker.uniter awaiting error resolution
for "relation-changed" hook

As I'm not sure if I'm doing anything wrong or the charm is broken, I
wonder what your suggestion is in how to resolve this issue or if I'm just
doing it wrong.

/Erik Lönroth
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju