ish_models 0.0.33.287 → 0.0.33.292
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ish_models.rb +2 -0
- data/lib/office/email_action.rb +6 -0
- data/lib/office/email_attachment.rb +12 -0
- data/lib/office/email_conversation.rb +3 -0
- data/lib/office/email_message.rb +2 -0
- data/lib/wco/appliance.rb +18 -1
- data/lib/wco/appliance_tmpl.rb +23 -2
- data/lib/wco/leadset.rb +17 -0
- data/lib/wco/serverhost.rb +48 -46
- data/lib/wco/serverhost.rb-trash +45 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8106a24a63e76e7d3905e8412c43d2725ea74ccc2e7ec16f8fc9957f1ab2db89
|
4
|
+
data.tar.gz: b2f9624e52ab4087e8e03fc2ba259b48dacee46398dc0826f898b3dc216bb7c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7aa35e292ef1b467e8d57b22795742ceed93d14c43bb4774fe0bd6646c9b73691a72b03bec3461a9786516e1d9d15b19fdf8d24622cc4c935b81449bd0b8b46
|
7
|
+
data.tar.gz: d7b5656b4e08cc5d8dd1ba9da5d9dbe9a1980d74fa4c73607aefdfeb790a33cc8ed018c0c7e1c31185540f0f71f3d01c5ff61b70c0a3878a22d39ca5728542bb
|
data/lib/ish_models.rb
CHANGED
@@ -68,6 +68,7 @@ require 'office/action_tie'
|
|
68
68
|
require 'office/admin_message'
|
69
69
|
require 'office/email_action'
|
70
70
|
require 'office/email_action_tie'
|
71
|
+
require 'office/email_attachment'
|
71
72
|
require 'office/email_conversation'
|
72
73
|
require 'office/email_conversation_lead'
|
73
74
|
require 'office/email_conversation_tag'
|
@@ -81,6 +82,7 @@ require 'office/scheduled_email_action'
|
|
81
82
|
|
82
83
|
require 'wco/appliance'
|
83
84
|
require 'wco/appliance_tmpl'
|
85
|
+
require 'wco/leadset'
|
84
86
|
require 'wco/price'
|
85
87
|
require 'wco/product'
|
86
88
|
require 'wco/serverhost'
|
data/lib/office/email_action.rb
CHANGED
@@ -24,5 +24,11 @@ class Office::EmailAction
|
|
24
24
|
|
25
25
|
has_many :email_filters, class_name: 'Office::EmailFilter', inverse_of: :email_action
|
26
26
|
|
27
|
+
field :deleted_at, default: nil, type: :time
|
28
|
+
|
29
|
+
def self.list
|
30
|
+
[[nil,nil]] + Office::EmailAction.where({ :deleted_at => nil }).map { |a| [ a.slug, a.id ] }
|
31
|
+
end
|
32
|
+
|
27
33
|
end
|
28
34
|
EAct = Office::EmailAction
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
class Office::EmailAttachment
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
belongs_to :email_message, class_name: 'Office::EmailMessage', inverse_of: :email_attachments
|
7
|
+
|
8
|
+
field :content
|
9
|
+
field :content_type
|
10
|
+
field :filename
|
11
|
+
|
12
|
+
end
|
@@ -10,10 +10,13 @@ class Office::EmailConversation
|
|
10
10
|
field :state
|
11
11
|
|
12
12
|
field :subject
|
13
|
+
index({ subject: -1 })
|
14
|
+
|
13
15
|
field :latest_at
|
14
16
|
index({ latest_at: -1 })
|
15
17
|
|
16
18
|
field :from_emails, type: :array, default: []
|
19
|
+
index({ from_emails: -1 })
|
17
20
|
|
18
21
|
has_many :lead_ties, class_name: 'Office::EmailConversationLead'
|
19
22
|
# def lead_ids
|
data/lib/office/email_message.rb
CHANGED
@@ -51,6 +51,8 @@ class Office::EmailMessage
|
|
51
51
|
email_conversation
|
52
52
|
end
|
53
53
|
|
54
|
+
has_many :email_attachments, class_name: 'Office::EmailAttachment', inverse_of: :email_message
|
55
|
+
|
54
56
|
def preview_str
|
55
57
|
body = part_html || part_html || 'Neither part_html nor part_txt!'
|
56
58
|
body = ::ActionView::Base.full_sanitizer.sanitize( body ).gsub(/\s+/, ' ')
|
data/lib/wco/appliance.rb
CHANGED
@@ -5,7 +5,10 @@ class Wco::Appliance
|
|
5
5
|
|
6
6
|
field :name
|
7
7
|
validates :name, uniqueness: { scope: :leadset_id }, presence: true
|
8
|
+
|
8
9
|
field :kind
|
10
|
+
|
11
|
+
field :service_name
|
9
12
|
field :environment
|
10
13
|
|
11
14
|
field :subdomain
|
@@ -19,7 +22,21 @@ class Wco::Appliance
|
|
19
22
|
Leadset.find leadset_id
|
20
23
|
end
|
21
24
|
|
22
|
-
belongs_to :
|
25
|
+
belongs_to :appliance_tmpl, class_name: 'Wco::ApplianceTmpl'
|
26
|
+
def tmpl
|
27
|
+
appliance_tmpl
|
28
|
+
end
|
29
|
+
|
30
|
+
belongs_to :serverhost, class_name: 'Wco::Serverhost'
|
31
|
+
belongs_to :wco_leadset, class_name: 'Wco::Leadset', inverse_of: :appliances
|
32
|
+
|
33
|
+
# field :ip
|
34
|
+
field :port
|
35
|
+
|
36
|
+
STATE_PENDING = 'state-pending'
|
37
|
+
STATE_LIVE = 'state-live'
|
38
|
+
STATE_TERM = 'state-term'
|
39
|
+
field :state, default: STATE_PENDING
|
23
40
|
|
24
41
|
end
|
25
42
|
|
data/lib/wco/appliance_tmpl.rb
CHANGED
@@ -4,12 +4,33 @@ class Wco::ApplianceTmpl
|
|
4
4
|
include Mongoid::Timestamps
|
5
5
|
|
6
6
|
field :kind
|
7
|
-
validates :kind, uniqueness:
|
7
|
+
validates :kind, uniqueness: { scope: :version }, presence: true
|
8
|
+
|
9
|
+
field :version, type: :string, default: '0.0.0'
|
10
|
+
validates :version, uniqueness: { scope: :kind }, presence: true
|
11
|
+
index({ kind: -1, version: -1 }, { name: :kind_version })
|
12
|
+
|
13
|
+
field :descr, type: :string
|
8
14
|
|
9
15
|
field :image
|
10
16
|
validates :image, presence: true
|
11
17
|
|
18
|
+
field :volume_zip
|
19
|
+
validates :volume_zip, presence: true
|
20
|
+
|
12
21
|
KIND_CORPHOME1 = 'corphome1'
|
22
|
+
KIND_DRUPAL = 'drupal'
|
13
23
|
KIND_HELLOWORLD = 'helloworld'
|
14
|
-
KINDS = [ '
|
24
|
+
# KINDS = [ 'smt', 'emailcrm', KIND_CORPHOME1, KIND_HELLOWORLD, KIND_DRUPAL,
|
25
|
+
# 'mautic', 'matomo',
|
26
|
+
# 'irowor', 'eCommerce' ]
|
27
|
+
KINDS = [ KIND_HELLOWORLD ]
|
28
|
+
|
29
|
+
has_many :appliances, class_name: 'Wco::Appliance'
|
30
|
+
|
31
|
+
def self.latest_of kind
|
32
|
+
where({ kind: kind }).order_by({ version: :desc }).first
|
33
|
+
end
|
34
|
+
|
15
35
|
end
|
36
|
+
AppTmpl = Wco::ApplianceTmpl
|
data/lib/wco/leadset.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class Wco::Leadset
|
3
|
+
include Mongoid::Document
|
4
|
+
include Mongoid::Timestamps
|
5
|
+
|
6
|
+
field :name
|
7
|
+
|
8
|
+
field :domains, type: :string, default: 'orbital.city'
|
9
|
+
|
10
|
+
has_many :serverhosts, class_name: 'Wco::Serverhost', inverse_of: :wco_leadset
|
11
|
+
def next_serverhost
|
12
|
+
serverhosts.first
|
13
|
+
end
|
14
|
+
|
15
|
+
has_many :appliances, class_name: 'Wco::Appliance', inverse_of: :wco_leadset
|
16
|
+
|
17
|
+
end
|
data/lib/wco/serverhost.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
|
2
2
|
require 'net/scp'
|
3
|
-
# require 'autoinc'
|
4
3
|
|
5
4
|
class Wco::Serverhost
|
6
5
|
include Mongoid::Document
|
@@ -8,17 +7,19 @@ class Wco::Serverhost
|
|
8
7
|
# include Mongoid::Autoinc
|
9
8
|
|
10
9
|
field :name, type: :string
|
11
|
-
validates :name, uniqueness: { scope: :leadset_id }, presence: true
|
10
|
+
# validates :name, uniqueness: { scope: :leadset_id }, presence: true
|
11
|
+
validates :name, uniqueness: { scope: :wco_leadset }, presence: true
|
12
12
|
|
13
|
-
field :
|
14
|
-
#
|
13
|
+
# field :leadset_id, type: :integer
|
14
|
+
# has_and_belongs_to_many :leadsets, class_name: 'Wco::Leadset', inverse_of: :serverhosts
|
15
|
+
belongs_to :wco_leadset, class_name: 'Wco::Leadset'
|
15
16
|
|
16
|
-
field :
|
17
|
+
field :next_port, type: :integer, default: 8000
|
17
18
|
|
18
19
|
## net-ssh, sshkit
|
19
20
|
field :ssh_host
|
20
|
-
field :ssh_username
|
21
|
-
field :ssh_key
|
21
|
+
# field :ssh_username
|
22
|
+
# field :ssh_key
|
22
23
|
field :nginx_root, default: '/opt/nginx'
|
23
24
|
|
24
25
|
has_many :appliances, class_name: 'Wco::Appliance'
|
@@ -50,49 +51,50 @@ class Wco::Serverhost
|
|
50
51
|
|
51
52
|
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
puts
|
63
|
-
|
54
|
+
WORKDIR = "/opt/projects/docker"
|
55
|
+
|
56
|
+
def add_docker_service app={}
|
57
|
+
puts! app, '#add_docker_service'
|
58
|
+
|
59
|
+
ac = ActionController::Base.new
|
60
|
+
ac.instance_variable_set( :@app, app )
|
61
|
+
ac.instance_variable_set( :@workdir, WORKDIR )
|
62
|
+
rendered_str = ac.render_to_string("docker-compose/dc-#{app[:kind]}")
|
63
|
+
puts '+++ add_docker_service rendered_str:'
|
64
|
+
print rendered_str
|
65
|
+
|
66
|
+
file = Tempfile.new('prefix')
|
67
|
+
file.write rendered_str
|
68
|
+
file.close
|
69
|
+
puts! file.path, 'file.path'
|
64
70
|
|
65
|
-
|
66
|
-
|
71
|
+
`scp #{file.path} #{ssh_host}:#{WORKDIR}/dc-#{app[:service_name]}.yml`
|
72
|
+
`ssh #{ssh_host} 'cd #{WORKDIR} ; \
|
73
|
+
docker compose -f dc-#{app[:service_name]}.yml up -d #{app[:service_name]} ; \
|
74
|
+
echo ok #add_docker_service ' `
|
67
75
|
end
|
68
76
|
|
77
|
+
def create_volume app={}
|
78
|
+
# puts! app, '#create_volume'
|
69
79
|
|
70
|
-
|
80
|
+
ac = ActionController::Base.new
|
81
|
+
ac.instance_variable_set( :@app, app )
|
82
|
+
ac.instance_variable_set( :@workdir, WORKDIR )
|
83
|
+
rendered_str = ac.render_to_string("scripts/create_volume")
|
84
|
+
# puts '+++ create_volume rendered_str:'
|
85
|
+
# print rendered_str
|
86
|
+
|
87
|
+
file = Tempfile.new('prefix')
|
88
|
+
file.write rendered_str
|
89
|
+
file.close
|
90
|
+
# puts! file.path, 'file.path'
|
71
91
|
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
|
76
|
-
#
|
77
|
-
# end
|
78
|
-
# end
|
79
|
-
# private
|
80
|
-
# def start
|
81
|
-
# Net::SSH.start(ip, 'ubuntu', keys: "mykey.pem" ) do |ssh|
|
82
|
-
# yield ssh
|
83
|
-
# end
|
84
|
-
# end
|
85
|
-
# end
|
86
|
-
|
87
|
-
|
88
|
-
## works:
|
89
|
-
# nginx_root = '/opt/nginx'
|
90
|
-
# config = { service_name: 'abba', }
|
91
|
-
# Net::SSH.start( "18.209.12.11", "ubuntu", keys: "access/mac_id_rsa_3.pem" ) do |ssh|
|
92
|
-
# out = ssh.scp.upload! "tmp/#{config[:service_name]}", "/opt/tmp/two.txt" do |ch, name, sent, total|
|
93
|
-
# puts "#{name}: #{sent}/#{total}"
|
94
|
-
# end
|
95
|
-
# puts! out, 'out'
|
96
|
-
# end
|
92
|
+
`scp #{file.path} #{ssh_host}:#{WORKDIR}/scripts/create_volume`
|
93
|
+
`ssh #{ssh_host} 'chmod a+x #{WORKDIR}/scripts/create_volume ; \
|
94
|
+
#{WORKDIR}/scripts/create_volume ' `
|
95
|
+
end
|
96
|
+
# alias_method :create_volume, :create_volume_2
|
97
97
|
|
98
98
|
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
# WORKDIR = "/Users/piousbox/projects/docker_wco"
|
5
|
+
|
6
|
+
# class Instance
|
7
|
+
# def chmod
|
8
|
+
# start do |ssh|
|
9
|
+
# ssh.exec "sudo chmod +x /tmp/provision.sh"
|
10
|
+
# # other operations on ssh
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
# private
|
14
|
+
# def start
|
15
|
+
# Net::SSH.start(ip, 'ubuntu', keys: "mykey.pem" ) do |ssh|
|
16
|
+
# yield ssh
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
|
22
|
+
## works:
|
23
|
+
# nginx_root = '/opt/nginx'
|
24
|
+
# config = { service_name: 'abba', }
|
25
|
+
# Net::SSH.start( "18.209.12.11", "ubuntu", keys: "access/mac_id_rsa_3.pem" ) do |ssh|
|
26
|
+
# out = ssh.scp.upload! "tmp/#{config[:service_name]}", "/opt/tmp/two.txt" do |ch, name, sent, total|
|
27
|
+
# puts "#{name}: #{sent}/#{total}"
|
28
|
+
# end
|
29
|
+
# puts! out, 'out'
|
30
|
+
# end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def create_volume_1 config={}
|
36
|
+
puts! config, '#create_volume'
|
37
|
+
|
38
|
+
out = ` cd #{WORKDIR} ; \
|
39
|
+
[ ! -e #{config[:kind]}__prototype.zip ] && wget #{config.tmpl.volume_zip} ; \
|
40
|
+
[ ! -e #{config[:kind]}__prototype ] && unzip #{config[:kind]}__prototype.zip ; \
|
41
|
+
mv #{config[:kind]}__prototype #{config[:service_name]}_data ; \
|
42
|
+
echo ok #create_volume
|
43
|
+
`;
|
44
|
+
puts! out, 'out'
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ish_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.33.
|
4
|
+
version: 0.0.33.292
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
@@ -218,6 +218,7 @@ files:
|
|
218
218
|
- lib/office/admin_message.rb
|
219
219
|
- lib/office/email_action.rb
|
220
220
|
- lib/office/email_action_tie.rb
|
221
|
+
- lib/office/email_attachment.rb
|
221
222
|
- lib/office/email_conversation.rb
|
222
223
|
- lib/office/email_conversation_lead.rb
|
223
224
|
- lib/office/email_conversation_tag.rb
|
@@ -233,9 +234,11 @@ files:
|
|
233
234
|
- lib/video.rb
|
234
235
|
- lib/wco/appliance.rb
|
235
236
|
- lib/wco/appliance_tmpl.rb
|
237
|
+
- lib/wco/leadset.rb
|
236
238
|
- lib/wco/price.rb
|
237
239
|
- lib/wco/product.rb
|
238
240
|
- lib/wco/serverhost.rb
|
241
|
+
- lib/wco/serverhost.rb-trash
|
239
242
|
- lib/wco/subscription.rb
|
240
243
|
homepage: https://wasya.co
|
241
244
|
licenses:
|