Example #1
0
func (s *ExposeSuite) TestServiceExpose(c *C) {
	charm := s.AddTestingCharm(c, "dummy")
	serviceNames := []string{"dummy-service", "exposed-service"}
	svcs := make([]*state.Service, len(serviceNames))
	var err error
	for i, name := range serviceNames {
		svcs[i], err = s.State.AddService(name, charm)
		c.Assert(err, IsNil)
		c.Assert(svcs[i].IsExposed(), Equals, false)
	}
	err = svcs[1].SetExposed()
	c.Assert(err, IsNil)
	c.Assert(svcs[1].IsExposed(), Equals, true)

	for i, t := range serviceExposeTests {
		c.Logf("test %d. %s", i, t.about)
		err = statecmd.ServiceExpose(s.State, params.ServiceExpose{
			ServiceName: t.service,
		})
		if t.err != "" {
			c.Assert(err, ErrorMatches, t.err)
		} else {
			c.Assert(err, IsNil)
			service, err := s.State.Service(t.service)
			c.Assert(err, IsNil)
			c.Assert(service.IsExposed(), Equals, t.exposed)
		}
	}

	for _, s := range svcs {
		err = s.Destroy()
		c.Assert(err, IsNil)
	}
}
Example #2
0
// Run changes the juju-managed firewall to expose any
// ports that were also explicitly marked by units as open.
func (c *ExposeCommand) Run(_ *cmd.Context) error {
	conn, err := juju.NewConnFromName(c.EnvName)
	if err != nil {
		return err
	}
	defer conn.Close()

	params := params.ServiceExpose{
		ServiceName: c.ServiceName,
	}
	return statecmd.ServiceExpose(conn.State, params)
}
Example #3
0
// ServiceExpose changes the juju-managed firewall to expose any ports that
// were also explicitly marked by units as open.
func (c *Client) ServiceExpose(args params.ServiceExpose) error {
	return statecmd.ServiceExpose(c.api.state, args)
}