aboutsummaryrefslogtreecommitdiffstats
path: root/docker/services/nova-vnc-proxy.yaml
blob: 35e69494bae05195c508868e5a4ecb430944c433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
heat_template_version: pike

description: >
  OpenStack containerized Nova Vncproxy service

parameters:
  DockerNamespace:
    description: namespace
    default: 'tripleoupstream'
    type: string
  DockerNovaVncProxyImage:
    description: image
    default: 'centos-binary-nova-novncproxy:latest'
    type: string
  DockerNovaConfigImage:
    description: The container image to use for the nova config_volume
    default: 'centos-binary-nova-base:latest'
    type: string
  EndpointMap:
    default: {}
    description: Mapping of service endpoint -> protocol. Typically set
                 via parameter_defaults in the resource registry.
    type: json
  ServiceNetMap:
    default: {}
    description: Mapping of service_name -> network name. Typically set
                 via parameter_defaults in the resource registry.  This
                 mapping overrides those in ServiceNetMapDefaults.
    type: json
  DefaultPasswords:
    default: {}
    type: json
  RoleName:
    default: ''
    description: Role name on which the service is applied
    type: string
  RoleParameters:
    default: {}
    description: Parameters specific to the role
    type: json

resources:

  ContainersCommon:
    type: ./containers-common.yaml

  NovaVncProxyPuppetBase:
    type: ../../puppet/services/nova-vnc-proxy.yaml
    properties:
      EndpointMap: {get_param: EndpointMap}
      ServiceNetMap: {get_param: ServiceNetMap}
      DefaultPasswords: {get_param: DefaultPasswords}
      RoleName: {get_param: RoleName}
      RoleParameters: {get_param: RoleParameters}

outputs:
  role_data:
    description: Role data for the Nova Vncproxy service.
    value:
      service_name: {get_attr: [NovaVncProxyPuppetBase, role_data, service_name]}
      config_settings: {get_attr: [NovaVncProxyPuppetBase, role_data, config_settings]}
      step_config: &step_config
        get_attr: [NovaVncProxyPuppetBase, role_data, step_config]
      service_config_settings: {get_attr: [NovaVncProxyPuppetBase, role_data, service_config_settings]}
      # BEGIN DOCKER SETTINGS
      puppet_config:
        config_volume: nova
        puppet_tags: nova_config
        step_config: *step_config
        config_image:
          list_join:
          - '/'
          - [ {get_param: DockerNamespace}, {get_param: DockerNovaConfigImage} ]
      kolla_config:
        /var/lib/kolla/config_files/nova_vnc_proxy.json:
          command: /usr/bin/nova-novncproxy --web /usr/share/novnc/
          config_files:
            - source: "/var/lib/kolla/config_files/src/*"
              dest: "/"
              merge: true
              preserve_properties: true
          permissions:
            - path: /var/log/nova
              owner: nova:nova
              recurse: true
      docker_config:
        step_4:
          nova_vnc_proxy:
            image:
              list_join:
                - '/'
                - [ {get_param: DockerNamespace}, {get_param: DockerNovaVncProxyImage} ]
            net: host
            privileged: false
            restart: always
            volumes:
              list_concat:
                - {get_attr: [ContainersCommon, volumes]}
                -
                  - /var/lib/kolla/config_files/nova_vnc_proxy.json:/var/lib/kolla/config_files/config.json:ro
                  - /var/lib/config-data/puppet-generated/nova/:/var/lib/kolla/config_files/src:ro
                  - /var/log/containers/nova:/var/log/nova
            environment:
              - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS
      host_prep_tasks:
        - name: create persistent logs directory
          file:
            path: /var/log/containers/nova
            state: directory
      upgrade_tasks:
        - name: Stop and disable nova_vnc_proxy service
          tags: step2
          service: name=openstack-nova-novncproxy state=stopped enabled=no
ss="n">reg |= HB_PLL_EXT_ENA; writel(reg, hbclk->reg); return 0; } static void clk_pll_disable(struct clk_hw *hwclk) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 reg; reg = readl(hbclk->reg); reg &= ~HB_PLL_EXT_ENA; writel(reg, hbclk->reg); } static unsigned long clk_pll_recalc_rate(struct clk_hw *hwclk, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); unsigned long divf, divq, vco_freq, reg; reg = readl(hbclk->reg); if (reg & HB_PLL_EXT_BYPASS) return parent_rate; divf = (reg & HB_PLL_DIVF_MASK) >> HB_PLL_DIVF_SHIFT; divq = (reg & HB_PLL_DIVQ_MASK) >> HB_PLL_DIVQ_SHIFT; vco_freq = parent_rate * (divf + 1); return vco_freq / (1 << divq); } static void clk_pll_calc(unsigned long rate, unsigned long ref_freq, u32 *pdivq, u32 *pdivf) { u32 divq, divf; unsigned long vco_freq; if (rate < HB_PLL_MIN_FREQ) rate = HB_PLL_MIN_FREQ; if (rate > HB_PLL_MAX_FREQ) rate = HB_PLL_MAX_FREQ; for (divq = 1; divq <= 6; divq++) { if ((rate * (1 << divq)) >= HB_PLL_VCO_MIN_FREQ) break; } vco_freq = rate * (1 << divq); divf = (vco_freq + (ref_freq / 2)) / ref_freq; divf--; *pdivq = divq; *pdivf = divf; } static long clk_pll_round_rate(struct clk_hw *hwclk, unsigned long rate, unsigned long *parent_rate) { u32 divq, divf; unsigned long ref_freq = *parent_rate; clk_pll_calc(rate, ref_freq, &divq, &divf); return (ref_freq * (divf + 1)) / (1 << divq); } static int clk_pll_set_rate(struct clk_hw *hwclk, unsigned long rate, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 divq, divf; u32 reg; clk_pll_calc(rate, parent_rate, &divq, &divf); reg = readl(hbclk->reg); if (divf != ((reg & HB_PLL_DIVF_MASK) >> HB_PLL_DIVF_SHIFT)) { /* Need to re-lock PLL, so put it into bypass mode */ reg |= HB_PLL_EXT_BYPASS; writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg); writel(reg | HB_PLL_RESET, hbclk->reg); reg &= ~(HB_PLL_DIVF_MASK | HB_PLL_DIVQ_MASK); reg |= (divf << HB_PLL_DIVF_SHIFT) | (divq << HB_PLL_DIVQ_SHIFT); writel(reg | HB_PLL_RESET, hbclk->reg); writel(reg, hbclk->reg); while ((readl(hbclk->reg) & HB_PLL_LOCK) == 0) ; while ((readl(hbclk->reg) & HB_PLL_LOCK_500) == 0) ; reg |= HB_PLL_EXT_ENA; reg &= ~HB_PLL_EXT_BYPASS; } else { writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg); reg &= ~HB_PLL_DIVQ_MASK; reg |= divq << HB_PLL_DIVQ_SHIFT; writel(reg | HB_PLL_EXT_BYPASS, hbclk->reg); } writel(reg, hbclk->reg); return 0; } static const struct clk_ops clk_pll_ops = { .prepare = clk_pll_prepare, .unprepare = clk_pll_unprepare, .enable = clk_pll_enable, .disable = clk_pll_disable, .recalc_rate = clk_pll_recalc_rate, .round_rate = clk_pll_round_rate, .set_rate = clk_pll_set_rate, }; static unsigned long clk_cpu_periphclk_recalc_rate(struct clk_hw *hwclk, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 div = (readl(hbclk->reg) & HB_A9_PCLK_DIV) ? 8 : 4; return parent_rate / div; } static const struct clk_ops a9periphclk_ops = { .recalc_rate = clk_cpu_periphclk_recalc_rate, }; static unsigned long clk_cpu_a9bclk_recalc_rate(struct clk_hw *hwclk, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 div = (readl(hbclk->reg) & HB_A9_BCLK_DIV_MASK) >> HB_A9_BCLK_DIV_SHIFT; return parent_rate / (div + 2); } static const struct clk_ops a9bclk_ops = { .recalc_rate = clk_cpu_a9bclk_recalc_rate, }; static unsigned long clk_periclk_recalc_rate(struct clk_hw *hwclk, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 div; div = readl(hbclk->reg) & 0x1f; div++; div *= 2; return parent_rate / div; } static long clk_periclk_round_rate(struct clk_hw *hwclk, unsigned long rate, unsigned long *parent_rate) { u32 div; div = *parent_rate / rate; div++; div &= ~0x1; return *parent_rate / div; } static int clk_periclk_set_rate(struct clk_hw *hwclk, unsigned long rate, unsigned long parent_rate) { struct hb_clk *hbclk = to_hb_clk(hwclk); u32 div; div = parent_rate / rate; if (div & 0x1) return -EINVAL; writel(div >> 1, hbclk->reg); return 0; } static const struct clk_ops periclk_ops = { .recalc_rate = clk_periclk_recalc_rate, .round_rate = clk_periclk_round_rate, .set_rate = clk_periclk_set_rate, }; static __init struct clk *hb_clk_init(struct device_node *node, const struct clk_ops *ops) { u32 reg; struct clk *clk; struct hb_clk *hb_clk; const char *clk_name = node->name; const char *parent_name; struct clk_init_data init; struct device_node *srnp; int rc; rc = of_property_read_u32(node, "reg", &reg); if (WARN_ON(rc)) return NULL; hb_clk = kzalloc(sizeof(*hb_clk), GFP_KERNEL); if (WARN_ON(!hb_clk)) return NULL; /* Map system registers */ srnp = of_find_compatible_node(NULL, NULL, "calxeda,hb-sregs"); hb_clk->reg = of_iomap(srnp, 0); BUG_ON(!hb_clk->reg); hb_clk->reg += reg; of_property_read_string(node, "clock-output-names", &clk_name); init.name = clk_name; init.ops = ops; init.flags = 0; parent_name = of_clk_get_parent_name(node, 0); init.parent_names = &parent_name; init.num_parents = 1; hb_clk->hw.init = &init; clk = clk_register(NULL, &hb_clk->hw); if (WARN_ON(IS_ERR(clk))) { kfree(hb_clk); return NULL; } rc = of_clk_add_provider(node, of_clk_src_simple_get, clk); return clk; } static void __init hb_pll_init(struct device_node *node) { hb_clk_init(node, &clk_pll_ops); } CLK_OF_DECLARE(hb_pll, "calxeda,hb-pll-clock", hb_pll_init); static void __init hb_a9periph_init(struct device_node *node) { hb_clk_init(node, &a9periphclk_ops); } CLK_OF_DECLARE(hb_a9periph, "calxeda,hb-a9periph-clock", hb_a9periph_init); static void __init hb_a9bus_init(struct device_node *node) { struct clk *clk = hb_clk_init(node, &a9bclk_ops); clk_prepare_enable(clk); } CLK_OF_DECLARE(hb_a9bus, "calxeda,hb-a9bus-clock", hb_a9bus_init); static void __init hb_emmc_init(struct device_node *node) { hb_clk_init(node, &periclk_ops); } CLK_OF_DECLARE(hb_emmc, "calxeda,hb-emmc-clock", hb_emmc_init);